]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
text-based mount.nfs: refactor mandatory mount option processing
authorChuck Lever <chuck.lever@oracle.com>
Mon, 8 Oct 2007 15:53:46 +0000 (11:53 -0400)
committerNeil Brown <neilb@suse.de>
Tue, 9 Oct 2007 01:18:04 +0000 (11:18 +1000)
We're about to combine nfsmount_s() and nfs4mount_s().  Refactor the
version-specific mount option processing into a separate function.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
utils/mount/stropts.c

index 3d83f9e5743bb9dd2c974ecf1242d7477677bd9f..627031215a9c286ab76c0ff245722ea5f8105bd8 100644 (file)
@@ -214,6 +214,29 @@ static int fix_mounthost_option(struct mount_options *options)
        return 0;
 }
 
+/*
+ * Set up mandatory mount options.
+ *
+ * Returns 1 if successful; otherwise zero.
+ */
+static int set_mandatory_options(const char *type,
+                                struct sockaddr_in *saddr,
+                                struct mount_options *options)
+{
+       if (!append_addr_option(saddr, options))
+               return 0;
+
+       if (strncmp(type, "nfs4", 4) == 0) {
+               if (!append_clientaddr_option(saddr, options))
+                       return 0;
+       } else {
+               if (!fix_mounthost_option(options))
+                       return 0;
+       }
+
+       return 1;
+}
+
 /*
  * nfsmount_s - Mount an NFSv2 or v3 file system using C string options
  *