From 3fbb50397cbf4176cf0267178539072f1133e771 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Thu, 3 Nov 2011 17:08:37 +0100 Subject: [PATCH] stopgap local fstab . /etc/fstab.local to list user-defined filesystems . /usr/etc/rc reads it and runs type-specific fsck if necessary . also type-specific mount --- commands/fsck.mfs/fsck.c | 3 ++- etc/Makefile | 2 +- etc/fstab.local | 3 +++ etc/usr/rc | 24 ++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 etc/fstab.local diff --git a/commands/fsck.mfs/fsck.c b/commands/fsck.mfs/fsck.c index 84510d81d..45a737b6c 100644 --- a/commands/fsck.mfs/fsck.c +++ b/commands/fsck.mfs/fsck.c @@ -1557,6 +1557,7 @@ char **argv; prog = *argv++; while ((arg = *argv++) != 0) if (arg[0] == '-' && arg[1] != 0 && arg[2] == 0) switch (arg[1]) { + case 'p': case 'a': automatic ^= 1; break; case 'c': clist = getlist(&argv, "inode"); @@ -1581,7 +1582,7 @@ char **argv; devgiven = 1; } if (!devgiven) { - printf("Usage: fsck [-acilrsz] file\n"); + printf("Usage: fsck [-pacilrsz] file\n"); exit(1); } return(0); diff --git a/etc/Makefile b/etc/Makefile index 5cdf674d1..a81ea6343 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -5,7 +5,7 @@ FILES1=fstab group hostname.file inet.conf motd.install mtab passwd profile \ protocols rc services termcap ttytab utmp rc.cd binary_sizes \ binary_sizes.big binary_sizes.xxl syslog.conf rc.daemons.dist \ rs.inet rs.single make.conf system.conf ttys resolv.conf rc.conf \ - rc.subr man.conf + rc.subr man.conf fstab.local FILES2=shadow FILES3=daily dhcptags.conf rc diff --git a/etc/fstab.local b/etc/fstab.local new file mode 100644 index 000000000..ec5db9ad2 --- /dev/null +++ b/etc/fstab.local @@ -0,0 +1,3 @@ +# Device Mountpoint FStype +# Example: +# /dev/ram /mnt mfs diff --git a/etc/usr/rc b/etc/usr/rc index 6009acfe8..66c5b4773 100644 --- a/etc/usr/rc +++ b/etc/usr/rc @@ -2,6 +2,7 @@ RANDOM_FILE=/usr/adm/random.dat LOCAL_FILE=/usr/etc/rc.local +LOCAL_FSTAB=/etc/fstab.local case "$#:$1" in 1:start|1:stop|1:down) @@ -188,6 +189,29 @@ start) # Run the daily cleanup on systems that are not on at night. test -f /usr/etc/daily && sh /usr/etc/daily boot & + # Mount non-standard filesystems + [ -f $LOCAL_FSTAB ] && cat $LOCAL_FSTAB | grep -v '^#' | while read fsline + do set $fsline + if [ $# -lt 3 ]; then echo "$LOCAL_FSTAB: short line"; continue; fi + + # This line's parameters + dev="$1"; mp="$2"; fstype="$3" + + # Sanity checks + if mount | fgrep "$dev"; then echo "$dev mounted."; continue; fi + if [ ! -b $dev ]; then echo "$dev missing"; continue; fi + if [ ! -d $mp ]; then echo "$mp missing"; continue; fi + + # Do fsck if necessary + if shutdown -C + then echo "Checking $fstype $dev" + if ! fsck.$fstype -p $dev; then echo "$dev fail"; continue; fi + fi + + # Do actual mount command + echo "$fstype $dev on $mp:" + mount -t $fstype $dev $mp + done ;; stop|down) # Save random data, if /usr is mounted rw. -- 2.44.0