No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / am-utils / dist / scripts / am-eject.in
blob8754a3bd4751de76a3baf643d7bb99e17e5ba83d
1 #!/bin/sh
2 # auto-unmount floppy/cd directory before ejecting device
3 # script taken from Debian Linux's amd
5 # Package: am-utils-6.x
6 # (Additional) author: Erez Zadok <ezk@cs.columbia.edu>
8 # set path
9 prefix=@prefix@
10 exec_prefix=@exec_prefix@
11 PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH}
12 export PATH
14 if [ $# -ne 1 ]; then
15 echo "Usage: $0 cd|cdrom|fd|floppy"
16 exit 2
19 # determine toplevel mount point of amd
20 fs=`amq | grep ' toplvl ' | cut -d' ' -f1`
21 if [ "$fs" = "" ]; then
22 echo "Cannot determine amd toplevel directory"
23 exit 2
26 # append name of medium
27 case "$1" in
28 cd|fd) fs=$fs/$1;;
29 *) echo "Usage: $0 cd|cdrom|fd|floppy"; exit 2;;
30 esac
32 # is the medium mounted?
33 if amq | grep -q "^$fs" >/dev/null 2>&1; then
34 # if yes, try to unmount it
35 sync
36 amq -u $fs
37 sleep 2
38 if amq | grep -q "^$fs" >/dev/null 2>&1; then
39 # failed, bail out
40 echo -n "Cannot unmount $fs; in use by:"
41 fuser -uv -m $fs
42 echo ""
43 exit 1
45 else
46 echo "$fs not mounted"
49 case $1 in
50 cd|cdrom) eject cdrom || eject ;; # eject CD-ROM
51 fd|floppy) eject floppy || eject
52 echo "Ok to remove disk" ;;
53 esac