]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
mount.nfs: No need to return nfs_mount_data structs
authorChuck Lever <chuck.lever@oracle.com>
Mon, 16 Jul 2007 20:29:01 +0000 (16:29 -0400)
committerNeil Brown <neilb@suse.de>
Fri, 20 Jul 2007 06:10:55 +0000 (16:10 +1000)
Refactor mount processing slightly to remove an output parameter and an
unnecessary type cast.  The mount syscall is now made from inside
nfs_mount or nfs4mount, rather than in common code after those are called.

Code review suggests that EX_BG was never returned by mount.nfs because the
logic I just replaced was always returning EX_FAIL.  The new logic should
properly return EX_BG when appropriate.

However, it is unclear whether /bin/mount handles backgrounding the mount
request, or whether mount.nfs should.

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

index de94e66f75d5971e6641c308968e003cc6c2a13d..bd7e25ca218d0d0547135f51e7393cf2714ac2b3 100644 (file)
@@ -250,11 +250,6 @@ fail_unlock:
        return result;
 }
 
-int do_mount_syscall(char *spec, char *node, char *type, int flags, void *data)
-{
-       return mount(spec, node, type, flags, data);
-}
-
 void mount_usage()
 {
        printf("usage: %s remotetarget dir [-rvVwfnh] [-o nfsoptions]\n",
@@ -473,26 +468,13 @@ int main(int argc, char *argv[])
                exit(EX_FAIL);
 
        if (strcmp(fs_type, "nfs4") == 0)
-               mnt_err = nfs4mount(spec, mount_point, &flags, &extra_opts, &mount_opts, 0);
+               mnt_err = nfs4mount(spec, mount_point, &flags, &extra_opts, 0, fake);
        else
-               mnt_err = nfsmount(spec, mount_point, &flags,
-                                  &extra_opts, &mount_opts,
-                                  0, fake);
+               mnt_err = nfsmount(spec, mount_point, &flags, &extra_opts, 0, fake);
 
        if (mnt_err)
                exit(EX_FAIL);
 
-       if (!fake) {
-               mnt_err = do_mount_syscall(spec, mount_point, fs_type,
-                                          flags & ~(MS_USER|MS_USERS) ,
-                                          mount_opts);
-
-               if (mnt_err) {
-                       mount_error(spec, mount_point, errno);
-                       exit(EX_FAIL);
-               }
-       }
-
        if (!nomtab)
                mnt_err = add_mtab(spec, mount_point, fs_type, flags, extra_opts,
                                0, 0 /* these are always zero for NFS */ );
index 58e311e5028a5386cbeb701d9f0f45866232d6fb..921739b4e90a4593903cf8c93091b054b42496e9 100644 (file)
@@ -68,7 +68,6 @@ struct nfs4_mount_data {
 #define NFS4_MOUNT_UNSHARED    0x8000  /* 5 */
 #define NFS4_MOUNT_FLAGMASK    0xFFFF
 
-int nfs4mount(const char *, const char *, int *, char **,
-       char **, int);
+int nfs4mount(const char *, const char *, int *, char **, int, int);
 
 #endif
index cc6eaf254719678822a811d468a71927e227fb1b..a0a1cabe40edaf34d5ab21e6a357a23e05863247 100644 (file)
@@ -25,6 +25,7 @@
 #include <netdb.h>
 #include <time.h>
 #include <sys/stat.h>
+#include <sys/mount.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <rpc/auth.h>
@@ -41,6 +42,7 @@
 #include "conn.h"
 #include "xcommon.h"
 
+#include "mount_constants.h"
 #include "nfs4_mount.h"
 #include "nfs_mount.h"
 #include "error.h"
@@ -166,8 +168,7 @@ static int get_my_ipv4addr(char *ip_addr, int len)
 }
 
 int nfs4mount(const char *spec, const char *node, int *flags,
-             char **extra_opts, char **mount_opts,
-             int running_bg)
+             char **extra_opts, int running_bg, int fake)
 {
        static struct nfs4_mount_data data;
        static char hostdir[1024];
@@ -441,8 +442,14 @@ int nfs4mount(const char *spec, const char *node, int *flags,
                continue;
        }
 
-       *mount_opts = (char *) &data;
-       /* clean up */
+       if (!fake) {
+               if (mount(spec, node, "nfs4",
+                               *flags & ~(MS_USER|MS_USERS), &data)) {
+                       mount_error(spec, node, errno);
+                       goto fail;
+               }
+       }
+
        return 0;
 
 fail:
index e566083998459982e0df1aa6fcd39cc717ef61ff..169f12e5fbeb4fd0a8827881139d034d547cb674 100644 (file)
@@ -80,7 +80,6 @@ struct nfs_mount_data {
 #define AUTH_GSS_SPKMP         390011
 #endif
 
-int nfsmount(const char *, const char *, int *, char **, char **,
-            int, int);
+int nfsmount(const char *, const char *, int *, char **, int, int);
 
 #endif /* _NFS_MOUNT_H */
index a3cbbbe595680fc612d41e7556eeb1b15e17672f..b6a0d6041040f66b0cb7e0220ceddcec7d0654da 100644 (file)
@@ -487,8 +487,7 @@ out_bad:
 
 int
 nfsmount(const char *spec, const char *node, int *flags,
-        char **extra_opts, char **mount_opts,
-        int running_bg, int fake)
+        char **extra_opts, int running_bg, int fake)
 {
        static char *prev_bg_host;
        char hostdir[1024];
@@ -618,7 +617,6 @@ nfsmount(const char *spec, const char *node, int *flags,
 #endif
 
        data.version = nfs_mount_data_version;
-       *mount_opts = (char *) &data;
 
        if (*flags & MS_REMOUNT)
                goto out_ok;
@@ -862,6 +860,14 @@ noauth_flavors:
                }
        }
 
+       if (!fake) {
+               if (mount(spec, node, "nfs",
+                               *flags & ~(MS_USER|MS_USERS), &data)) {
+                       mount_error(spec, node, errno);
+                       goto fail;
+               }
+       }
+
        return 0;
 
        /* abort */