Skip to contentSkip to conversation

mount.nfs: No need to return nfs_mount_data structs

PATCH In review Chuck Lever 1 participant 1 message Jul 16, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 11/17 mount.nfs: No need to return nfs_mount_data structs

Refactor mount processing slightly to remove an output parameter and an unnecessary type cast.

It doesn't look like background mounting was working, but this might help.

---

 utils/mount/mount.c      |   22 ++--------------------
 utils/mount/nfs4_mount.h |    3 +--
 utils/mount/nfs4mount.c  |   15 +++++++++++----
 utils/mount/nfs_mount.h  |    3 +--
 utils/mount/nfsmount.c   |   12 +++++++++---
 5 files changed, 24 insertions(+), 31 deletions(-)
utils/mount/mount.c +2 -20
index 865746a..bc2e53a 100644
@@ -249,11 +249,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",
@@ -472,26 +467,13 @@ int main(int argc, char *argv[])
 		exit(EX_FAIL);
 
 	if (!strcmp(fs_type, "nfs4"))
-		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 */ );
utils/mount/nfs4_mount.h +1 -2
index 58e311e..921739b 100644
@@ -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
utils/mount/nfs4mount.c +11 -4
index ea2ac3a..c8fa0de 100644
@@ -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 "nfsmount_err.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:
utils/mount/nfs_mount.h +1 -2
index e566083..169f12e 100644
@@ -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 */
utils/mount/nfsmount.c +9 -3
index df23e30..4ce8a4e 100644
@@ -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 */

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs