#
# 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
# 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) 1984, 1986, 1987, 1988, 1989 AT&T
# All Rights Reserved
#
#
if [ -n "$1" ]; then
echo "umountall: $1" 1>&2
fi
echo "Usage:\n\tumountall [-k] [-s] [-F FSType] [-l|-r] [-Z] [-n]" 1>&2
echo "\tumountall [-k] [-s] [-h host] [-Z] [-n]" 1>&2
exit 2
}
# PATHed from the command line). As such it should not depend on /usr
# being mounted (if /usr is a separate filesystem).
#
# echo
# exit
# getopts
# test, [ ]
# exec
# read
#
# /sbin commands we use:
#
# The following /usr based commands may be used by this script (depending on
# command line options). We will set our PATH to find them, but where they
# are not present (eg, if /usr is not mounted) we will catch references to
# them via shell functions conditionally defined after option processing
# (don't use any of these commands before then).
#
# Command Command line option and use
#
# slower shell constructs to reverse a file.
# Clear these in case they were already set in our inherited environment.
HOST=
# Is the passed fstype a "remote" one?
for t in $RemoteFSTypes
do
[ "$t" = "$1" ] && return 0
done
return 1
}
# Get list of remote FS types (just once)
RemoteFSTypes=`while read t junk; do echo $t; done < /etc/dfs/fstypes`
#
# Process command line args
#
do
case $c in
r) RFLAG="r";;
l) LFLAG="l";;
s) SFLAG="s";;
k) KFLAG="k";;
h) if [ -n "$HFLAG" ]; then
usage "more than one host specified"
fi
HFLAG="h"
;;
F) if [ -n "$FFLAG" ]; then
usage "more than one FStype specified"
fi
FFLAG="f"
?????????*)
usage "FSType ${FSType} exceeds 8 characters"
esac;
;;
Z) ZFLAG="z";;
n) NFLAG="n"
# Alias any commands that would perform real actions to
# something that tells what action would have been performed
UMOUNTFLAG="-V"
echo "fuser $*" 1>&2
}
: # No need to show where we'd sleep
}
;;
\?) usage ""
;;
esac
done
# Sanity checking:
# 1) arguments beyond those supported
# 2) can't specify both remote and local
# 3) can't specify a host with -r or -l
# 4) can't specify a fstype with -h
# 5) can't specify this host with -h (checks only uname -n)
# 6) can't be fstype nfs and local
# 7) only fstype nfs is remote
usage "additional arguments not supported"
fi
usage "options -r and -l are incompatible"
fi
usage "option -${RFLAG}${LFLAG} incompatible with -h option"
fi
usage "Specifying FStype incompatible with -h option"
fi
usage "Specifying local host illegal for -h option"
fi
# remote FSType not allowed
usage "option -l and FSType ${FSType} are incompatible"
fi
# remote FSType required
usage "option -r and FSType ${FSType} are incompatible"
fi
#
# Take advantage of parallel unmounting at this point if we have no
# criteria to match and we are in the global zone
#
if [ -z "${SFLAG}${LFLAG}${RFLAG}${HFLAG}${KFLAG}${FFLAG}${ZFLAG}" -a \
"$ZONENAME" = "global" ]; then
umount -a ${UMOUNTFLAG}
exit # with return code of the umount -a
fi
#
# Catch uses of /usr commands when /usr is not mounted
echo "umountall: fuser -k skipped (no /usr)" 1>&2
# continue - not fatal
}
: # no point in sleeping if fuser is doing nothing
}
else
echo "umountall: sleep after fuser -k skipped (no /usr)" 1>&2
# continue - not fatal
}
fi
fi
fi
#
# fstype=nfs line in mnttab (eg, "host:/export) extract the host
# component. The dev string looks like: "host:/path"
IFS=":"
set -- $*
echo $1
}
#
# Similar for smbfs, but tricky due to the optional parts
# of the "device" syntax. The dev strings look like:
IFS="/@"
set -- $*
case $# in
3) echo "$2";;
2) echo "$1";;
esac
}
#
# doumounts echos its return code to stdout, so commands used within
# this function should take care to produce no other output to stdout.
(
rc=0
fslist=""
do
/ | \
/dev | \
/devices | \
/lib | \
/proc | \
/sbin | \
/tmp | \
/tmp/.libgrubmgmt* | \
/usr | \
/var | \
'' )
#
# file systems possibly mounted in the kernel or
# in the methods of some of the file system
# services
#
continue
;;
* )
thishost='-'
fi
fi
continue
fi
fi
continue
fi
# umount local filesystems
fi
# Note: isremote is true for both nfs & autofs, so
# this will filter out autofs mounts with nfs file
# system mounted on the top of it.
#
# WARNING: use of any syscall on a NFS file system has
# the danger to go over-the-wire and could cause nfs
# clients to hang on shutdown, if the nfs server is
# down beforehand.
# For the reason described above, a simple test like
# "df -F nfs $mountp" can't be used to filter out
# nfs-over-autofs mounts. (isremote works OK)
#
# umount remote filesystems
fi
#
# should not see any zone options
# but our own
#
break
fi
done
continue
fi
# we are called from the global zone
else
zone=*)
option="zone="
break
;;
esac
done
# skip mounts from non-global zones if ZFLAG is not set
continue
fi
# skip mounts from the global zone if ZFLAG is set
continue
fi
fi
if [ -n "${KFLAG}" ]; then
sleep 2
fi
umount ${UMOUNTFLAG} ${mountp} 1>&2
trc=$?
fi
else
# We want to umount in parallel
fi
esac
done
umount -a ${UMOUNTFLAG} $fslist 1>&2
trc=$?
fi
fi
echo $rc
)
}
#
# may umount in opposite order to the original mounts.
#
exec < $MNTTAB
while read line; do
if [ -n "$REVERSED" ]; then
else
fi
done
else
fi
exit $error