From 3b28652c82f9aedcf02bfd8cf9c95b3f60023ca8 Mon Sep 17 00:00:00 2001 From: rodrigc Date: Wed, 29 Nov 2006 00:41:44 +0000 Subject: Deduce the "fstype" parameter to pass to nmount() by looking at the "_nfs" part of argv[0]. This should facilitate unifying mount_nfs and mount_nfs4 into one binary. MFC after: 1 month Reviewed by: mohans --- sbin/mount_nfs/mount_nfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sbin/mount_nfs') diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index aa85868..6907b27 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -253,7 +253,7 @@ main(int argc, char *argv[]) struct iovec *iov; int mntflags, altflags, num; int iovlen; - char *name, *p, *spec; + char *name, *p, *spec, *fstype; char mntpath[MAXPATHLEN]; mntflags = 0; @@ -263,6 +263,12 @@ main(int argc, char *argv[]) iov = NULL; iovlen = 0; + fstype = strrchr(argv[0], '_'); + if (fstype == NULL) + errx(EX_USAGE, "argv[0] must end in _fstype"); + + ++fstype; + while ((c = getopt(argc, argv, "23a:bcdD:g:I:iLlNo:PR:r:sTt:w:x:U")) != -1) switch (c) { @@ -461,7 +467,7 @@ main(int argc, char *argv[]) (void)checkpath(name, mntpath); build_iovec(&iov, &iovlen, "nfs_args", nfsargsp, sizeof(*nfsargsp)); - build_iovec(&iov, &iovlen, "fstype", "nfs", (size_t)-1); + build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1); build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1); if (nmount(iov, iovlen, mntflags)) -- cgit v1.1