From 0904e7ecf266ebe6844dfc4b178441dc8d81296b Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Wed, 8 Jul 2020 01:25:37 -0400 Subject: 12944 remove long obsolete libsys Reviewed by: Robert Mustacchi Reviewed by: Toomas Soome Approved by: Dan McDonald --- usr/src/lib/Makefile | 1 - usr/src/lib/libsys/Makefile | 43 ---- usr/src/lib/libsys/Makefile.com | 36 --- usr/src/lib/libsys/Makefile.targ | 39 --- usr/src/lib/libsys/common/libsys.sh | 53 ---- usr/src/lib/libsys/common/mapfile-vers | 451 --------------------------------- usr/src/lib/libsys/i386/Makefile | 37 --- usr/src/lib/libsys/i386/libsys.list | 192 -------------- usr/src/lib/libsys/sparc/Makefile | 38 --- usr/src/lib/libsys/sparc/libsys.list | 207 --------------- usr/src/lib/libsys/sparc/libsys.sh | 39 --- usr/src/lib/libsys/sparc/libsyss.list | 10 - 12 files changed, 1146 deletions(-) delete mode 100644 usr/src/lib/libsys/Makefile delete mode 100644 usr/src/lib/libsys/Makefile.com delete mode 100644 usr/src/lib/libsys/Makefile.targ delete mode 100644 usr/src/lib/libsys/common/libsys.sh delete mode 100644 usr/src/lib/libsys/common/mapfile-vers delete mode 100644 usr/src/lib/libsys/i386/Makefile delete mode 100644 usr/src/lib/libsys/i386/libsys.list delete mode 100644 usr/src/lib/libsys/sparc/Makefile delete mode 100644 usr/src/lib/libsys/sparc/libsys.list delete mode 100644 usr/src/lib/libsys/sparc/libsys.sh delete mode 100644 usr/src/lib/libsys/sparc/libsyss.list (limited to 'usr/src/lib') diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 7b87fe98e9..08fabd7093 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -221,7 +221,6 @@ SUBDIRS += \ libstmfproxy \ libsum \ libsun_ima \ - libsys \ libsysevent \ libtecla \ libtermcap \ diff --git a/usr/src/lib/libsys/Makefile b/usr/src/lib/libsys/Makefile deleted file mode 100644 index f956efa735..0000000000 --- a/usr/src/lib/libsys/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -include ../Makefile.lib - -SUBDIRS = $(MACH) - -all := TARGET= all -clean := TARGET= clean -clobber := TARGET= clobber -install := TARGET= install - -.KEEP_STATE: - -all clean clobber install: $(SUBDIRS) - - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/libsys/Makefile.com b/usr/src/lib/libsys/Makefile.com deleted file mode 100644 index cd829c5c1b..0000000000 --- a/usr/src/lib/libsys/Makefile.com +++ /dev/null @@ -1,36 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. -# - -LIBRARY = libsys.a -VERS = .1 - -# Define libsys to be a filter on libc. The ABI requires the runtime linker as -# the soname. -SONAME = /usr/lib/ld.so.1 -DYNFLAGS += -F /usr/lib/libc.so.1 - -COMSRC = $(COMOBJ:%.o=%.c) -MACHSRC = $(MACHOBJ:%.o=%.s) - -CLOBBERFILES += $(COMSRC) $(MACHSRC) diff --git a/usr/src/lib/libsys/Makefile.targ b/usr/src/lib/libsys/Makefile.targ deleted file mode 100644 index e025958f2f..0000000000 --- a/usr/src/lib/libsys/Makefile.targ +++ /dev/null @@ -1,39 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# Copyright 2019 Peter Tribble. -# - -BUILD.SO += $(PICS) - -$(COMSRC): ../common/libsys.sh libsys.list - sh ../common/libsys.sh - -$(MACHSRC): libsys.sh libsyss.list - sh ./libsys.sh - -pics/%.o := ASFLAGS += $(AS_PICFLAGS) - -pics/%.o: %.s - $(COMPILE.s) -o $@ $< - $(POST_PROCESS_S_O) diff --git a/usr/src/lib/libsys/common/libsys.sh b/usr/src/lib/libsys/common/libsys.sh deleted file mode 100644 index 4da1d42b66..0000000000 --- a/usr/src/lib/libsys/common/libsys.sh +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -#ident "%Z%%M% %I% %E% SMI" - -# Stub library for programmer's interface to libsys. Used to satisfy ld(1) -# processing, and serves as a precedence place-holder at execution-time. - -awk ' -/.*/ { - if ($2 == "1") { - printf("#pragma weak %s = _%s\n", $3, $3); - flag = "_"; - } else - flag = ""; - if ($1 == "f") { - printf("void *\n%s%s()\n{\n", flag, $3); - printf("\t/*NOTREACHED*/\n\treturn (0);\n}\n\n"); - } else { - if ($4 == "1") - printf("%s %s%s %s %s\n\n", $5, flag, $3, $6, $7); - else if ($4 == "2") - printf("%s %s %s%s %s %s\n\n", $5, $6, flag, $3, $7, $8); - else if ($4 == "3") - printf("%s %s %s%s%s %s %s %s\n\n", $5, $6, flag, $3, $7, $8, $9, $10); - } -} -' libsys.list > libsys.c diff --git a/usr/src/lib/libsys/common/mapfile-vers b/usr/src/lib/libsys/common/mapfile-vers deleted file mode 100644 index c847354409..0000000000 --- a/usr/src/lib/libsys/common/mapfile-vers +++ /dev/null @@ -1,451 +0,0 @@ -# -# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -$if !_ELF32 -$error libsys is only supported in 32-bit form -$endif - -$if _sparc -SYMBOL_VERSION SISCD_2.3 { - global: - SISCD_2.3; -} SYSVABI_1.3; -$endif - -SYMBOL_VERSION SYSVABI_1.3 { - global: - _makecontext; - makecontext; - _swapcontext; - swapcontext; - local: - *; -} SYSVABI_1.2; - -SYMBOL_VERSION SYSVABI_1.2 { - global: - _access; - access; - _acct; - acct; - _alarm; - alarm; - _altzone; - atexit; - calloc; - _catclose; - catclose; - _catgets; - catgets; - _catopen; - catopen; - _chdir; - chdir; - _chmod; - chmod; - _chown; - chown; - _chroot; - chroot; - _close; - close; - _closedir; - closedir; - _creat; - creat; - __ctype; - _daylight; - daylight; - _dup; - dup; - _environ; - environ; - _execl; - execl; - _execle; - execle; - _execlp; - execlp; - _execv; - execv; - _execve; - execve; - _execvp; - execvp; - _exit; - exit; - _fattach; - fattach; - _fchdir; - fchdir; - _fchmod; - fchmod; - _fchown; - fchown; - _fcntl; - fcntl; - _fdetach; - fdetach; - _fork; - fork; - _fpathconf; - fpathconf; - free; - _fstat; - fstat; - _fstatvfs; - fstatvfs; - _fsync; - fsync; - _ftok; - ftok; - _getcontext; - getcontext; - _getcwd; - getcwd; - _getegid; - getegid; - _geteuid; - geteuid; - _getgid; - getgid; - _getgrgid; - getgrgid; - _getgrnam; - getgrnam; - _getgroups; - getgroups; - _getlogin; - getlogin; - _getmsg; - getmsg; - _getpgid; - getpgid; - _getpgrp; - getpgrp; - _getpid; - getpid; - _getpmsg; - getpmsg; - _getppid; - getppid; - _getpwnam; - getpwnam; - _getpwuid; - getpwuid; - _getrlimit; - getrlimit; - _getsid; - getsid; - _gettxt; - gettxt; - _getuid; - getuid; - _grantpt; - grantpt; - __huge_val; - _initgroups; - initgroups; - _ioctl; - ioctl; - _isastream; - isastream; - _kill; - kill; - _lchown; - lchown; - _link; - link; - localeconv; - _lseek; - lseek; - _lstat; - lstat; - malloc; - _memcntl; - memcntl; - _mkdir; - mkdir; - _mknod; - mknod; - _mlock; - mlock; - mmap; - _mount; - mount; - _mprotect; - mprotect; - _msgctl; - msgctl; - _msgget; - msgget; - _msgrcv; - msgrcv; - _msgsnd; - msgsnd; - _msync; - msync; - _munlock; - munlock; - _munmap; - munmap; - _nice; - nice; - _numeric; - _open; - open; - _opendir; - opendir; - _pathconf; - pathconf; - _pause; - pause; - _pipe; - pipe; - _poll; - poll; - _profil; - profil; - _ptrace; - ptrace; - _ptsname; - ptsname; - _putmsg; - putmsg; - _putpmsg; - putpmsg; - _read; - read; - _readdir; - readdir; - _readlink; - readlink; - _readv; - readv; - realloc; - remove; - _rename; - rename; - _rewinddir; - rewinddir; - _rmdir; - rmdir; - _seekdir; - seekdir; - _semctl; - semctl; - _semget; - semget; - _semop; - semop; - _setcontext; - setcontext; - _setgid; - setgid; - _setgroups; - setgroups; - setlocale; - _setpgid; - setpgid; - _setpgrp; - setpgrp; - _setrlimit; - setrlimit; - _setsid; - setsid; - _setuid; - setuid; - _shmat; - shmat; - _shmctl; - shmctl; - _shmdt; - shmdt; - _shmget; - shmget; - _sigaction; - sigaction; - _sigaddset; - sigaddset; - _sigaltstack; - sigaltstack; - _sigdelset; - sigdelset; - _sigemptyset; - sigemptyset; - _sigfillset; - sigfillset; - _sighold; - sighold; - _sigignore; - sigignore; - _sigismember; - sigismember; - _siglongjmp; - siglongjmp; - signal; - _sigpause; - sigpause; - _sigpending; - sigpending; - _sigprocmask; - sigprocmask; - _sigrelse; - sigrelse; - _sigsend; - sigsend; - _sigsendset; - sigsendset; - _sigset; - sigset; - _sigsetjmp; - sigsetjmp; - _sigsuspend; - sigsuspend; - _stat; - stat; - _statvfs; - statvfs; - _stime; - stime; - strcoll; - strerror; - strftime; - strxfrm; - _symlink; - symlink; - _sync; - sync; - _sysconf; - sysconf; - system; - _telldir; - telldir; - _time; - time; - _times; - times; - _timezone; - timezone; - _ttyname; - ttyname; - _tzname; - tzname; - _ulimit; - ulimit; - _umask; - umask; - _umount; - umount; - _uname; - uname; - _unlink; - unlink; - _unlockpt; - unlockpt; - _utime; - utime; - _wait; - wait; - _waitid; - waitid; - _waitpid; - waitpid; - _write; - write; - _writev; - writev; - -$if _sparc - # Sparc-only interfaces - _Q_add; - _Q_cmp; - _Q_cmpe; - _Q_div; - _Q_dtoq; - _Q_feq; - _Q_fge; - _Q_fgt; - _Q_fle; - _Q_flt; - _Q_fne; - _Q_itoq; - _Q_mul; - _Q_neg; - _Q_qtod; - _Q_qtoi; - _Q_qtos; - _Q_qtou; - _Q_sqrt; - _Q_stoq; - _Q_sub; - _Q_utoq; - .div; - __dtou; - __ftou; - _mmap { FLAGS = NODYNSORT }; - .mul; - .rem; - .stret1; - .stret2; - .stret4; - .stret8; - .udiv; - .umul; - .urem; -$endif - -$if _x86 - # X86-only interfaces - __flt_rounds; - _fp_hw; - _fpstart; - _fxstat; - _lxstat; - _mmap; - _nuname; - nuname; - _sbrk; - sbrk; - _xmknod; - _xstat; -$endif - - -}; diff --git a/usr/src/lib/libsys/i386/Makefile b/usr/src/lib/libsys/i386/Makefile deleted file mode 100644 index 6e0d26d1db..0000000000 --- a/usr/src/lib/libsys/i386/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# Define objects first to trigger $(PIC) rules in Makefile.lib - -COMOBJ = libsys.o -OBJECTS = $(COMOBJ) - -include $(SRC)/lib/Makefile.filter.com -include ../Makefile.com - -install: all $(ROOTLIBDIR) .WAIT $(ROOTLIBS) $(ROOTLINKS) - -include $(SRC)/lib/Makefile.filter.targ -include ../Makefile.targ diff --git a/usr/src/lib/libsys/i386/libsys.list b/usr/src/lib/libsys/i386/libsys.list deleted file mode 100644 index 847377f256..0000000000 --- a/usr/src/lib/libsys/i386/libsys.list +++ /dev/null @@ -1,192 +0,0 @@ -f 1 access -f 1 acct -f 1 alarm -f 1 catclose -f 1 catgets -f 1 catopen -f 1 chdir -f 1 chmod -f 1 chown -f 1 chroot -f 1 close -f 1 closedir -f 1 creat -f 1 dup -f 1 execl -f 1 execle -f 1 execlp -f 1 execv -f 1 execve -f 1 execvp -f 1 fattach -f 1 fchdir -f 1 fchmod -f 1 fchown -f 1 fcntl -f 1 fdetach -f 1 fork -f 1 fpathconf -f 1 fstat -f 1 fstatvfs -f 1 fsync -f 1 ftok -f 1 getcontext -f 1 getcwd -f 1 getegid -f 1 geteuid -f 1 getgid -f 1 getgrgid -f 1 getgrnam -f 1 getgroups -f 1 getlogin -f 1 getmsg -f 1 getpgid -f 1 getpgrp -f 1 getpid -f 1 getpmsg -f 1 getppid -f 1 getpwnam -f 1 getpwuid -f 1 getrlimit -f 1 getsid -f 1 gettxt -f 1 getuid -f 1 grantpt -f 1 initgroups -f 1 ioctl -f 1 isastream -f 1 kill -f 1 lchown -f 1 link -f 1 lseek -f 1 lstat -f 1 makecontext -f 1 memcntl -f 1 mkdir -f 1 mknod -f 1 mlock -f 1 mmap -f 1 mount -f 1 mprotect -f 1 msgctl -f 1 msgget -f 1 msgrcv -f 1 msgsnd -f 1 msync -f 1 munlock -f 1 munmap -f 1 nuname -f 1 nice -f 1 open -f 1 opendir -f 1 pathconf -f 1 pause -f 1 pipe -f 1 poll -f 1 profil -f 1 ptrace -f 1 ptsname -f 1 putmsg -f 1 putpmsg -f 1 read -f 1 readdir -f 1 readlink -f 1 readv -f 1 rename -f 1 rewinddir -f 1 rmdir -f 1 sbrk -f 1 seekdir -f 1 semctl -f 1 semget -f 1 semop -f 1 setcontext -f 1 setgid -f 1 setgroups -f 1 setpgid -f 1 setpgrp -f 1 setrlimit -f 1 setsid -f 1 setuid -f 1 shmat -f 1 shmctl -f 1 shmdt -f 1 shmget -f 1 sigaction -f 1 sigaddset -f 1 sigaltstack -f 1 sigdelset -f 1 sigemptyset -f 1 sigfillset -f 1 sighold -f 1 sigignore -f 1 sigismember -f 1 siglongjmp -f 1 sigpause -f 1 sigpending -f 1 sigprocmask -f 1 sigrelse -f 1 sigsend -f 1 sigsendset -f 1 sigset -f 1 sigsetjmp -f 1 sigsuspend -f 1 stat -f 1 statvfs -f 1 stime -f 1 swapcontext -f 1 symlink -f 1 sync -f 1 sysconf -f 1 telldir -f 1 time -f 1 times -f 1 ttyname -f 1 ulimit -f 1 umask -f 1 umount -f 1 uname -f 1 unlink -f 1 unlockpt -f 1 utime -f 1 wait -f 1 waitid -f 1 waitpid -f 1 write -f 1 writev - -f 0 atexit -f 0 calloc -f 0 exit -f 0 _exit -f 0 free -f 0 localeconv -f 0 malloc -f 0 realloc -f 0 remove -f 0 setlocale -f 0 signal -f 0 strcoll -f 0 strerror -f 0 strftime -f 0 strxfrm -f 0 system -f 0 _fxstat -f 0 _lxstat -f 0 _xmknod -f 0 _xstat -f 0 _fpstart - -d 0 _altzone 1 long = 0; -d 0 __ctype[257+257+7] 2 unsigned char = {0}; -d 0 _numeric[2] 2 unsigned char = {0}; - -d 1 daylight 1 int = 0; -d 1 timezone 1 long = 0; -d 1 tzname 3 char * [2] = {(char*)0,(char*)0}; - -d 1 environ 2 char ** = 0; - -d 0 __huge_val[2] 2 unsigned long = {0x7ff00000,0x0}; -d 0 __flt_rounds 1 long = 0; -d 0 _fp_hw 1 long = 3; diff --git a/usr/src/lib/libsys/sparc/Makefile b/usr/src/lib/libsys/sparc/Makefile deleted file mode 100644 index 249cb75708..0000000000 --- a/usr/src/lib/libsys/sparc/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# Define objects first to trigger $(PIC) rules in Makefile.lib - -COMOBJ = libsys.o -MACHOBJ = libsyss.o -OBJECTS = $(COMOBJ) $(MACHOBJ) - -include $(SRC)/lib/Makefile.filter.com -include ../Makefile.com - -install: all $(ROOTLIBDIR) .WAIT $(ROOTLIBS) $(ROOTLINKS) - -include $(SRC)/lib/Makefile.filter.targ -include ../Makefile.targ diff --git a/usr/src/lib/libsys/sparc/libsys.list b/usr/src/lib/libsys/sparc/libsys.list deleted file mode 100644 index 9f9dde7e55..0000000000 --- a/usr/src/lib/libsys/sparc/libsys.list +++ /dev/null @@ -1,207 +0,0 @@ -f 1 access -f 1 acct -f 1 alarm -f 1 catclose -f 1 catgets -f 1 catopen -f 1 chdir -f 1 chmod -f 1 chown -f 1 chroot -f 1 close -f 1 closedir -f 1 creat -f 1 dup -f 1 execl -f 1 execle -f 1 execlp -f 1 execv -f 1 execve -f 1 execvp -f 1 fattach -f 1 fchdir -f 1 fchmod -f 1 fchown -f 1 fcntl -f 1 fdetach -f 1 fork -f 1 fpathconf -f 1 fstat -f 1 fstatvfs -f 1 fsync -f 1 ftok -f 1 getcontext -f 1 getcwd -f 1 getegid -f 1 geteuid -f 1 getgid -f 1 getgrgid -f 1 getgrnam -f 1 getgroups -f 1 getlogin -f 1 getmsg -f 1 getpgid -f 1 getpgrp -f 1 getpid -f 1 getpmsg -f 1 getppid -f 1 getpwnam -f 1 getpwuid -f 1 getrlimit -f 1 getsid -f 1 gettxt -f 1 getuid -f 1 grantpt -f 1 initgroups -f 1 ioctl -f 1 isastream -f 1 kill -f 1 lchown -f 1 link -f 1 lseek -f 1 lstat -f 1 makecontext -f 1 memcntl -f 1 mkdir -f 1 mknod -f 1 mlock -f 1 mmap -f 1 mount -f 1 mprotect -f 1 msgctl -f 1 msgget -f 1 msgrcv -f 1 msgsnd -f 1 msync -f 1 munlock -f 1 munmap -f 1 nice -f 1 open -f 1 opendir -f 1 pathconf -f 1 pause -f 1 pipe -f 1 poll -f 1 profil -f 1 ptrace -f 1 ptsname -f 1 putmsg -f 1 putpmsg -f 1 read -f 1 readdir -f 1 readlink -f 1 readv -f 1 rename -f 1 rewinddir -f 1 rmdir -f 1 seekdir -f 1 semctl -f 1 semget -f 1 semop -f 1 setcontext -f 1 setgid -f 1 setgroups -f 1 setpgid -f 1 setpgrp -f 1 setrlimit -f 1 setsid -f 1 setuid -f 1 shmat -f 1 shmctl -f 1 shmdt -f 1 shmget -f 1 sigaction -f 1 sigaddset -f 1 sigaltstack -f 1 sigdelset -f 1 sigemptyset -f 1 sigfillset -f 1 sighold -f 1 sigignore -f 1 sigismember -f 1 siglongjmp -f 1 sigpause -f 1 sigpending -f 1 sigprocmask -f 1 sigrelse -f 1 sigsend -f 1 sigsendset -f 1 sigset -f 1 sigsetjmp -f 1 sigsuspend -f 1 stat -f 1 statvfs -f 1 stime -f 1 swapcontext -f 1 symlink -f 1 sync -f 1 sysconf -f 1 telldir -f 1 time -f 1 times -f 1 ttyname -f 1 ulimit -f 1 umask -f 1 umount -f 1 uname -f 1 unlink -f 1 unlockpt -f 1 utime -f 1 wait -f 1 waitid -f 1 waitpid -f 1 write -f 1 writev - -f 0 atexit -f 0 calloc -f 0 exit -f 0 _exit -f 0 free -f 0 localeconv -f 0 malloc -f 0 realloc -f 0 remove -f 0 setlocale -f 0 signal -f 0 strcoll -f 0 strerror -f 0 strftime -f 0 strxfrm -f 0 system -f 0 _Q_add -f 0 _Q_cmp -f 0 _Q_cmpe -f 0 _Q_div -f 0 _Q_dtoq -f 0 _Q_feq -f 0 _Q_fge -f 0 _Q_fgt -f 0 _Q_fle -f 0 _Q_flt -f 0 _Q_fne -f 0 _Q_itoq -f 0 _Q_mul -f 0 _Q_neg -f 0 _Q_qtod -f 0 _Q_qtoi -f 0 _Q_qtos -f 0 _Q_qtou -f 0 _Q_sqrt -f 0 _Q_stoq -f 0 _Q_sub -f 0 _Q_utoq -f 0 __dtou -f 0 __ftou - -d 0 _altzone 1 long = 0; -d 0 __ctype[257+257+7] 2 unsigned char = {0}; -d 0 _numeric[2] 2 unsigned char = {0}; - -d 1 daylight 1 int = 0; -d 1 timezone 1 long = 0; -d 1 tzname 3 char * [2] = {(char*)0,(char*)0}; - -d 1 environ 2 char ** = 0; - -d 0 __huge_val[2] 2 unsigned long = {0x7ff00000,0x0}; diff --git a/usr/src/lib/libsys/sparc/libsys.sh b/usr/src/lib/libsys/sparc/libsys.sh deleted file mode 100644 index 7a3079a756..0000000000 --- a/usr/src/lib/libsys/sparc/libsys.sh +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 1995 by Sun Microsystems, Inc. -# All rights reserved. -# -# Stub library for programmer's interface to libsys. Used to satisfy ld(1) -# processing, and serves as a precedence place-holder at execution-time. - -awk ' -BEGIN { - printf("\t.file\t\"libsyss.s\"\n\t.section\t\".text\"\n"); -} -/.*/ { - printf("\t.global\t%s\n%s:\n\tt 5\n\t.type\t%s,#function\n\t.size\t%s,.-%s\n", $0, $0, $0, $0, $0); -} -' libsyss.list > libsyss.s diff --git a/usr/src/lib/libsys/sparc/libsyss.list b/usr/src/lib/libsys/sparc/libsyss.list deleted file mode 100644 index 15189a3e50..0000000000 --- a/usr/src/lib/libsys/sparc/libsyss.list +++ /dev/null @@ -1,10 +0,0 @@ -.div -.mul -.rem -.stret1 -.stret2 -.stret4 -.stret8 -.udiv -.umul -.urem -- cgit v1.2.3 From 0ac8993002ee179cc3289243a0fc956ee0db04da Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 30 Jul 2020 01:12:12 -0500 Subject: 13013 Port OpenZFS zpool label clear improvements 13012 zpool_read_label semantics should match OpenZFS Portions contributed by: Jason King Reviewed by: Matt Ahrens Reviewed by: Tim Chase Reviewed by: Tony Hutter Reviewed by: Andy Fiddaman Reviewed by: Toomas Soome Approved by: Dan McDonald --- usr/src/cmd/fs.d/zfs/fstyp/fstyp.c | 11 ++- usr/src/lib/libzfs/common/libzfs_import.c | 49 +++++++++++- usr/src/lib/libzutil/common/zutil_import.c | 11 ++- usr/src/pkg/manifests/system-test-zfstest.mf | 6 ++ usr/src/test/zfs-tests/runfiles/omnios.run | 3 +- usr/src/test/zfs-tests/runfiles/openindiana.run | 3 +- usr/src/test/zfs-tests/runfiles/smartos.run | 3 +- .../cli_root/zpool_attach/attach-o_ashift.ksh | 12 +-- .../cli_root/zpool_labelclear/labelclear.cfg | 3 - .../zpool_labelclear/zpool_labelclear_active.ksh | 28 +++---- .../zpool_labelclear/zpool_labelclear_exported.ksh | 20 ++--- .../zpool_labelclear/zpool_labelclear_removed.ksh | 62 +++++++++++++++ .../zpool_labelclear/zpool_labelclear_valid.ksh | 92 ++++++++++++++++++++++ .../cli_root/zpool_replace/replace-o_ashift.ksh | 15 +--- .../cli_root/zpool_replace/replace_prop_ashift.ksh | 6 +- 15 files changed, 260 insertions(+), 64 deletions(-) create mode 100755 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_removed.ksh create mode 100755 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh (limited to 'usr/src/lib') diff --git a/usr/src/cmd/fs.d/zfs/fstyp/fstyp.c b/usr/src/cmd/fs.d/zfs/fstyp/fstyp.c index d49d998404..2e7d4d397d 100644 --- a/usr/src/cmd/fs.d/zfs/fstyp/fstyp.c +++ b/usr/src/cmd/fs.d/zfs/fstyp/fstyp.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -89,11 +90,17 @@ fstyp_mod_ident(fstyp_mod_handle_t handle) char *str; uint64_t u64; char buf[64]; + int num_labels = 0; - if (zpool_read_label(h->fd, &h->config, NULL) != 0) { - return (FSTYP_ERR_NO_MATCH); + if (zpool_read_label(h->fd, &h->config, &num_labels) != 0) { + /* This is the only reason zpool_read_label() can fail */ + VERIFY3S(errno, ==, ENOMEM); + return (FSTYP_ERR_NOMEM); } + if (num_labels == 0) + return (FSTYP_ERR_NO_MATCH); + if (nvlist_lookup_uint64(h->config, ZPOOL_CONFIG_POOL_STATE, &state) != 0 || state == POOL_STATE_DESTROYED) { nvlist_free(h->config); diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c index 706f08e6ec..dc15aca0c0 100644 --- a/usr/src/lib/libzfs/common/libzfs_import.c +++ b/usr/src/lib/libzfs/common/libzfs_import.c @@ -169,23 +169,66 @@ zpool_clear_label(int fd) int l; vdev_label_t *label; uint64_t size; + int labels_cleared = 0; if (fstat64(fd, &statbuf) == -1) return (0); + size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); if ((label = calloc(sizeof (vdev_label_t), 1)) == NULL) return (-1); for (l = 0; l < VDEV_LABELS; l++) { - if (pwrite64(fd, label, sizeof (vdev_label_t), + uint64_t state, guid; + nvlist_t *config; + + if (pread64(fd, label, sizeof (vdev_label_t), label_offset(size, l)) != sizeof (vdev_label_t)) { - free(label); - return (-1); + continue; + } + + if (nvlist_unpack(label->vl_vdev_phys.vp_nvlist, + sizeof (label->vl_vdev_phys.vp_nvlist), &config, 0) != 0) { + continue; + } + + /* Skip labels which do not have a valid guid. */ + if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_GUID, + &guid) != 0 || guid == 0) { + nvlist_free(config); + continue; + } + + /* Skip labels which are not in a known valid state. */ + if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, + &state) != 0 || state > POOL_STATE_L2CACHE) { + nvlist_free(config); + continue; + } + + nvlist_free(config); + + /* + * A valid label was found, overwrite this label's nvlist + * and uberblocks with zeros on disk. This is done to prevent + * system utilities, like blkid, from incorrectly detecting a + * partial label. The leading pad space is left untouched. + */ + memset(label, 0, sizeof (vdev_label_t)); + size_t label_size = sizeof (vdev_label_t) - (2 * VDEV_PAD_SIZE); + + if (pwrite64(fd, label, label_size, label_offset(size, l) + + (2 * VDEV_PAD_SIZE)) == label_size) { + labels_cleared++; } } free(label); + + if (labels_cleared == 0) + return (-1); + return (0); } diff --git a/usr/src/lib/libzutil/common/zutil_import.c b/usr/src/lib/libzutil/common/zutil_import.c index 961247c5c0..b4e6ccc0ca 100644 --- a/usr/src/lib/libzutil/common/zutil_import.c +++ b/usr/src/lib/libzutil/common/zutil_import.c @@ -25,6 +25,7 @@ * Copyright (c) 2012, 2018 by Delphix. All rights reserved. * Copyright 2015 RackTop Systems. * Copyright (c) 2016, Intel Corporation. + * Copyright 2020 Joyent, Inc. */ /* @@ -913,8 +914,11 @@ zpool_read_label(int fd, nvlist_t **config, int *num_labels) *config = NULL; + if (num_labels != NULL) + *num_labels = 0; + if (fstat64(fd, &statbuf) == -1) - return (-1); + return (0); size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); if ((label = malloc(sizeof (vdev_label_t))) == NULL) @@ -968,11 +972,6 @@ zpool_read_label(int fd, nvlist_t **config, int *num_labels) free(label); *config = expected_config; - if (count == 0) { - errno = ENOENT; - return (-1); - } - return (0); } diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf index eca36deda1..8174cd0af3 100644 --- a/usr/src/pkg/manifests/system-test-zfstest.mf +++ b/usr/src/pkg/manifests/system-test-zfstest.mf @@ -1884,6 +1884,12 @@ file \ file \ path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported \ mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_removed \ + mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid \ + mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_offline/cleanup \ mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_offline/setup \ diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run index 5693772b65..4c52926b16 100644 --- a/usr/src/test/zfs-tests/runfiles/omnios.run +++ b/usr/src/test/zfs-tests/runfiles/omnios.run @@ -339,7 +339,8 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_encrypted', 'zpool_import_encrypted_load'] [/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] -tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported', + 'zpool_labelclear_removed', 'zpool_labelclear_valid'] pre = post = diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run index b004b2e96a..27697582ef 100644 --- a/usr/src/test/zfs-tests/runfiles/openindiana.run +++ b/usr/src/test/zfs-tests/runfiles/openindiana.run @@ -339,7 +339,8 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_encrypted', 'zpool_import_encrypted_load'] [/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] -tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported', + 'zpool_labelclear_removed', 'zpool_labelclear_valid'] pre = post = diff --git a/usr/src/test/zfs-tests/runfiles/smartos.run b/usr/src/test/zfs-tests/runfiles/smartos.run index e8f2a35b12..30e8efc0d3 100644 --- a/usr/src/test/zfs-tests/runfiles/smartos.run +++ b/usr/src/test/zfs-tests/runfiles/smartos.run @@ -289,7 +289,8 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_encrypted', 'zpool_import_encrypted_load'] [/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] -tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported', + 'zpool_labelclear_removed', 'zpool_labelclear_valid'] pre = post = diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh index 58ab57db05..fd33fb9506 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh @@ -51,8 +51,8 @@ log_onexit cleanup disk1=$TEST_BASE_DIR/$FILEDISK0 disk2=$TEST_BASE_DIR/$FILEDISK1 -log_must mkfile $SIZE $disk1 -log_must mkfile $SIZE $disk2 +log_must truncate -s $SIZE $disk1 +log_must truncate -s $SIZE $disk2 typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16") for ashift in ${ashifts[@]} @@ -84,13 +84,7 @@ do # clean things for the next run log_must zpool destroy $TESTPOOL1 log_must zpool labelclear $disk1 - # depending on if we expect to have failed the 'zpool attach' - if [[ $cmdval -le $ashift ]] - then - log_must zpool labelclear $disk2 - else - log_mustnot zpool labelclear $disk2 - fi + log_must zpool labelclear $disk2 done done diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg index 6ae5395635..4d7edbb005 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg @@ -17,9 +17,6 @@ . $STF_SUITE/include/libtest.shlib -typeset LABELCLEAR="zpool labelclear" -typeset LABELREAD="zdb -lq" - typeset disks=(${DISKS[*]}) typeset disk1=${disks[0]} typeset disk2=${disks[1]} diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh index a29c09095f..977a1806eb 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh @@ -43,26 +43,26 @@ log_assert "zpool labelclear will fail on all vdevs of imported pool" log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2 # Check that labelclear [-f] will fail on ACTIVE pool vdevs -log_mustnot $LABELCLEAR $disk1 -log_must $LABELREAD $disk1 -log_mustnot $LABELCLEAR -f $disk1 -log_must $LABELREAD $disk1 -log_mustnot $LABELCLEAR $disk2 -log_must $LABELREAD $disk2 -log_mustnot $LABELCLEAR -f $disk2 -log_must $LABELREAD $disk2 +log_mustnot zpool labelclear $disk1 +log_must zdb -lq $disk1 +log_mustnot zpool labelclear -f $disk1 +log_must zdb -lq $disk1 +log_mustnot zpool labelclear $disk2 +log_must zdb -lq $disk2 +log_mustnot zpool labelclear -f $disk2 +log_must zdb -lq $disk2 # Add a cache/spare to the pool, check that labelclear [-f] will fail # on the vdev and will succeed once it's removed from pool config for vdevtype in "cache" "spare"; do log_must zpool add $TESTPOOL $vdevtype $disk3 - log_mustnot $LABELCLEAR $disk3 - log_must $LABELREAD $disk3 - log_mustnot $LABELCLEAR -f $disk3 - log_must $LABELREAD $disk3 + log_mustnot zpool labelclear $disk3 + log_must zdb -lq $disk3 + log_mustnot zpool labelclear -f $disk3 + log_must zdb -lq $disk3 log_must zpool remove $TESTPOOL $disk3 - log_must $LABELCLEAR $disk3 - log_mustnot $LABELREAD $disk3 + log_must zpool labelclear $disk3 + log_mustnot zdb -lq $disk3 done log_pass "zpool labelclear will fail on all vdevs of imported pool" diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh index 82df8216eb..0a9016c471 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh @@ -52,21 +52,21 @@ for vdevtype in "" "cache" "spare"; do log_must zpool export $TESTPOOL # Check that labelclear will fail without -f - log_mustnot $LABELCLEAR $disk1 - log_must $LABELREAD $disk1 - log_mustnot $LABELCLEAR $disk2 - log_must $LABELREAD $disk2 + log_mustnot zpool labelclear $disk1 + log_must zdb -lq $disk1 + log_mustnot zpool labelclear $disk2 + log_must zdb -lq $disk2 # Check that labelclear will succeed with -f - log_must $LABELCLEAR -f $disk1 - log_mustnot $LABELREAD $disk1 - log_must $LABELCLEAR -f $disk2 - log_mustnot $LABELREAD $disk2 + log_must zpool labelclear -f $disk1 + log_mustnot zdb -lq $disk1 + log_must zpool labelclear -f $disk2 + log_mustnot zdb -lq $disk2 # Check that labelclear on auxilary vdevs will succeed if [[ -n $vdevtype ]]; then - log_must $LABELCLEAR $disk3 - log_mustnot $LABELREAD $disk3 + log_must zpool labelclear $disk3 + log_mustnot zdb -lq $disk3 fi done diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_removed.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_removed.ksh new file mode 100755 index 0000000000..f93de6e224 --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_removed.ksh @@ -0,0 +1,62 @@ +#!/bin/ksh -p +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2016 Nexenta Systems, Inc. +# Copyright (c) 2019 by Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg + +# DESCRIPTION: +# Check that `zpool labelclear` can clear labels on removed devices. +# +# STRATEGY: +# 1. Create a pool with primary, log, spare and cache devices. +# 2. Remove a top-level vdev, log, spare, and cache device. +# 3. Run `zpool labelclear` on the removed device. +# 4. Verify the label has been removed. +# + +verify_runnable "global" + +function cleanup +{ + poolexists $TESTPOOL && destroy_pool $TESTPOOL + rm -f $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4 $DEVICE5 +} + +log_onexit cleanup +log_assert "zpool labelclear works for removed devices" + +DEVICE1="$TEST_BASE_DIR/device-1" +DEVICE2="$TEST_BASE_DIR/device-2" +DEVICE3="$TEST_BASE_DIR/device-3" +DEVICE4="$TEST_BASE_DIR/device-4" +DEVICE5="$TEST_BASE_DIR/device-5" + +log_must truncate -s $((SPA_MINDEVSIZE * 8)) $DEVICE1 +log_must truncate -s $SPA_MINDEVSIZE $DEVICE2 $DEVICE3 $DEVICE4 $DEVICE5 + +log_must zpool create -f $TESTPOOL $DEVICE1 $DEVICE2 \ + log $DEVICE3 cache $DEVICE4 spare $DEVICE5 +log_must zpool sync + +# Remove each type of vdev and verify the label can be cleared. +for dev in $DEVICE5 $DEVICE4 $DEVICE3 $DEVICE2; do + log_must zpool remove $TESTPOOL $dev + log_must zpool sync $TESTPOOL + log_must zpool labelclear $dev + log_mustnot zdb -lq $dev +done + +log_pass "zpool labelclear works for removed devices" diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh new file mode 100755 index 0000000000..9c0c4d07c8 --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh @@ -0,0 +1,92 @@ +#!/bin/ksh -p +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2016 Nexenta Systems, Inc. +# Copyright (c) 2019 by Lawrence Livermore National Security, LLC. +# Copyright 2020 Joyent, Inc. +# + +. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg + +# DESCRIPTION: +# Check that `zpool labelclear` only clears valid labels. Expected +# label offsets which do not contain intact labels are left untouched. +# +# STRATEGY: +# 1. Create a pool with primary, log, spare and cache devices. +# 2. Export the pool. +# 3. Write a known pattern over the first two device labels. +# 4. Verify with zdb that only the last two device labels are intact. +# 5. Verify the pool could be imported using those labels. +# 6. Run `zpool labelclear` to destroy those last two labels. +# 7. Verify the pool can no longer be found; let alone imported. +# 8. Verify the pattern is intact to confirm `zpool labelclear` did +# not write to first two label offsets. +# 9. Verify that no valid label remain. +# + +verify_runnable "global" + +function cleanup +{ + poolexists $TESTPOOL && destroy_pool $TESTPOOL + rm -f $PATTERN_FILE $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4 +} + +log_onexit cleanup +log_assert "zpool labelclear will only clear valid labels" + +PATTERN_FILE=$TEST_BASE_DIR/pattern + +DEVICE1="$TEST_BASE_DIR/device-1" +DEVICE2="$TEST_BASE_DIR/device-2" +DEVICE3="$TEST_BASE_DIR/device-3" +DEVICE4="$TEST_BASE_DIR/device-4" + +log_must dd if=/dev/urandom of=$PATTERN_FILE bs=1048576 count=4 + +log_must truncate -s $SPA_MINDEVSIZE $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4 + +log_must zpool create -O mountpoint=none -f $TESTPOOL $DEVICE1 \ + log $DEVICE2 cache $DEVICE3 spare $DEVICE4 +log_must zpool export $TESTPOOL + +# Overwrite the first 4M of each device and verify the expected labels. +for dev in $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4; do + dd if=$PATTERN_FILE of=$dev bs=1048576 conv=notrunc + log_must eval "zdb -l $dev | grep 'labels = 2 3'" +done + +# Verify the pool could be imported using those labels. +log_must eval "zpool import -d $TEST_BASE_DIR | grep $TESTPOOL" + +# Verify the last two labels on each vdev can be cleared. +for dev in $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4; do + log_must zpool labelclear -f $dev +done + +# Verify there is no longer a pool which can be imported. +log_mustnot eval "zpool import -d $TEST_BASE_DIR | grep $TESTPOOL" + +# Verify the original pattern over the first two labels is intact +for dev in $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4; do + log_must dd if=$dev bs=1048576 count=4 | cmp -- - $PATTERN_FILE + log_mustnot zdb -lq $dev +done + +# Verify an error is reported when there are no labels to clear. +for dev in $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4; do + log_mustnot zpool labelclear -f $dev +done + +log_pass "zpool labelclear will only clear valid labels" diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh index 77f85c6bea..ae415487c7 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh @@ -51,8 +51,8 @@ log_onexit cleanup disk1=$TEST_BASE_DIR/$FILEDISK0 disk2=$TEST_BASE_DIR/$FILEDISK1 -log_must mkfile $SIZE $disk1 -log_must mkfile $SIZE $disk2 +log_must truncate -s $SIZE $disk1 +log_must truncate -s $SIZE $disk2 typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16") for ashift in ${ashifts[@]} @@ -84,15 +84,8 @@ do fi # clean things for the next run log_must zpool destroy $TESTPOOL1 - # depending on if we expect to have failed the 'zpool replace' - if [[ $cmdval -le $ashift ]] - then - log_mustnot zpool labelclear $disk1 - log_must zpool labelclear $disk2 - else - log_must zpool labelclear $disk1 - log_mustnot zpool labelclear $disk2 - fi + log_must zpool labelclear $disk1 + log_must zpool labelclear $disk2 done done diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh index 714f1180f5..e740de133a 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh @@ -52,8 +52,8 @@ log_onexit cleanup disk1=$TEST_BASE_DIR/$FILEDISK0 disk2=$TEST_BASE_DIR/$FILEDISK1 -log_must mkfile $SIZE $disk1 -log_must mkfile $SIZE $disk2 +log_must truncate -s $SIZE $disk1 +log_must truncate -s $SIZE $disk2 typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16") for ashift in ${ashifts[@]} @@ -89,7 +89,7 @@ do fi # clean things for the next run log_must zpool destroy $TESTPOOL1 - log_mustnot zpool labelclear $disk1 + log_must zpool labelclear $disk1 log_must zpool labelclear $disk2 done done -- cgit v1.2.3