Bug 103089 - [patch] mount_nfs(8): introduce new option
Summary: [patch] mount_nfs(8): introduce new option
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
Depends on:
Reported: 2006-09-10 11:40 UTC by Dominic Fandrey
Modified: 2008-03-04 04:14 UTC (History)
0 users

See Also:

file.diff (1.01 KB, patch)
2006-09-10 11:40 UTC, Dominic Fandrey
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dominic Fandrey 2006-09-10 11:40:22 UTC
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.
Comment 1 Dominic Fandrey 2006-09-10 11:47:20 UTC
In my foolish haste I submitted the wrong patch. This one actually works.

diff -Pur sbin/mount_nfs.orig/mount_nfs.8 sbin/mount_nfs/mount_nfs.8
--- sbin/mount_nfs.orig/mount_nfs.8	Thu Feb 10 10:19:30 2005
+++ sbin/mount_nfs/mount_nfs.8	Sun Sep 10 12:37:51 2006
@@ -36,7 +36,7 @@
 .Nd mount NFS file systems
-.Op Fl 23bcdiLlNPsTU
+.Op Fl 23bBcdiLlNPsTU
 .Op Fl a Ar maxreadahead
 .Op Fl D Ar deadthresh
 .Op Fl g Ar maxgroups
@@ -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 -Pur sbin/mount_nfs.orig/mount_nfs.c sbin/mount_nfs/mount_nfs.c
--- sbin/mount_nfs.orig/mount_nfs.c	Fri Jun 10 11:51:41 2005
+++ sbin/mount_nfs/mount_nfs.c	Sun Sep 10 12:38:50 2006
@@ -260,7 +260,7 @@
 	nfsargs = nfsdefargs;
 	nfsargsp = &nfsargs;
 	while ((c = getopt(argc, argv,
-	    "23a:bcdD:g:I:iLlNo:PR:r:sTt:w:x:U")) != -1)
+	    "23a:bBcdD:g:I:iLlNo:PR:r:sTt:w:x:U")) != -1)
 		switch (c) {
 		case '2':
 			mountmode = V2;
@@ -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;
@@ -918,7 +926,7 @@
 	(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
-"usage: mount_nfs [-23bcdiLlNPsTU] [-a maxreadahead] [-D deadthresh]",
+"usage: mount_nfs [-23bBcdiLlNPsTU] [-a maxreadahead] [-D deadthresh]",
 "                 [-g maxgroups] [-I readdirsize] [-o options] [-R retrycnt]",
 "                 [-r readsize] [-t timeout] [-w writesize] [-x retrans]",
 "                 rhost:path node");
Comment 2 kamikaze 2008-03-03 17:55:47 UTC
There seems to be no interest in this. I'm not using that myself any more, I 
suggest you just close it.
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2008-03-03 20:03:23 UTC
State Changed
From-To: open->suspended

Submitter is no longer interested in pursuing this, but leave it in 
'suspended' in case someone else wants to pick it up.
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2008-03-04 04:14:32 UTC
State Changed
From-To: suspended->closed

Submitter really recommends that this just be closed instead.