misc/103089: [sbin/mount_nfs] introduce new option

Dominic Fandrey lon_kamikaze at gmx.de
Sun Sep 10 03:40:25 PDT 2006

>Number:         103089
>Category:       misc
>Synopsis:       [sbin/mount_nfs] introduce new option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 10 10:40:22 GMT 2006
>Originator:     Dominic Fandrey
>Release:        Releng_6
FreeBSD mobileKamikaze.norad 6.1-STABLE FreeBSD 6.1-STABLE #0: Sat Sep  9 17:31:18 CEST 2006     root at homeKamikaze.norad:/usr/obj/usr/src/sys/TPR40-6  i386
In environments where a successful mount is rather unlikely (such as on a laptop) the use of the -b option is quite frustrating, because a failed attempt takes quite some time.

As an example I've got 4 nfs mounts in my fstab (with the -b option) and it delays booting by ~2 minutes, when I'm not in my home network, because a connection attempt takes a remarkable amount of time. This is why I added the -B option. Instead of waiting for the connection to the server to fail, it instantly forks (unless not already forked, which might be the case if someone added -B several times).

I suppose with only slight changes the patch could be applied to mount_nfs4 as well.

diff -uPr sbin/mount_nfs.orig/mount_nfs.8 sbin/mount_nfs/mount_nfs.8
--- sbin/mount_nfs.orig/mount_nfs.8	Sun Sep 10 12:05:33 2006
+++ sbin/mount_nfs/mount_nfs.8	Sun Sep 10 12:16:00 2006
@@ -163,6 +163,11 @@
 Useful for
 .Xr fstab 5 ,
 where the file system mount is not critical to multiuser operation.
+.It Fl B
+Fork off a child immediately, even before the first attempt to contact the
+server. Useful for
+.Xr fstab 5 ,
+where notification about failiure is not desired.
 .It Fl c
 For UDP mount points, do not do a
 .Xr connect 2 .
diff -uPr sbin/mount_nfs.orig/mount_nfs.c sbin/mount_nfs/mount_nfs.c
--- sbin/mount_nfs.orig/mount_nfs.c	Sun Sep 10 12:05:33 2006
+++ sbin/mount_nfs/mount_nfs.c	Sun Sep 10 12:05:02 2006
@@ -278,6 +278,14 @@
 		case 'b':
 			opflags |= BGRND;
+		case 'B':
+			opflags |= BGRND;
+			if ((opflags & (BGRND | ISBGRND)) == BGRND) {
+				opflags |= ISBGRND;
+				if (daemon(0, 0) != 0)
+					err(1, "daemon");
+			}
+			break;
 		case 'c':
 			nfsargsp->flags |= NFSMNT_NOCONN;


More information about the freebsd-bugs mailing list