Skip to contentSkip to conversation

Move NFS mount code from util-linux to nfs-utils - take2

PATCH In review Amit Gud 5 participants 8 messages Jun 12, 2006 – Jun 16, 2006

Subsystems (2)
lore
Share & tools
lore

Amit Gud

author
#0 lore raw

PATCH 1/1 Move NFS mount code from util-linux to nfs-utils - take2

AG

Signature · 2 lines
May the source be with you.
http://www.cis.ksu.edu/~gud

Moves the NFS mount code out of util-linux to nfs-utils. The primary reason being ease of maintainability, and keeping util-linux away from all the filesystem-specifc worries.

Adds a new directory 'mount' under utils. Creates a binary mount.nfs. Three symbolic links are created to this binary - mount.nfs4, umount.nfs and umount.nfs4. It is simpler and avoids code duplication (or overhead of fork->exec) by keeping umount code in a single binary along with the mount code. Mount code uses umount to handle certain fail cases. It also makes sense to keep single binary for all the versions of the NFS, as opposed to having seperate binaries mount.nfs and mount.nfs4, since the code falls back to lower version if mounting with v4 fails. Adds two man pages - mount.nfs(8) and umount.nfs(8).

Patches are split into two parts:
[1/2] nfsmount-migration-to-nfsutils-v2.patch [2/2] nfsmount-migration-to-nfsutils-support-v2.patch

After applying the patches before configuring and compiling, do:

$ rpcgen -c utils/mount/nfsmount.x > utils/mount/nfsmount_xdr.c
$ rpcgen -h utils/mount/nfsmount.x > utils/mount/nfsmount.h
$ sh autogen.sh

---

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#1 lore raw

in mount.c :

+void mount_usage()
+{
+ printf("usage: %s remotetarget dir [-rvVwfnh] [-t version] [-o
nfsoptions]\n", progname);
+ printf("options:\n\t-r\t\tMount file system readonly\n");
+ printf("\t-v\t\tVerbose\n");
+ printf("\t-V\t\tPrint version\n");
+ printf("\t-w\t\tMount file system read-write\n");

1. isn't it generally a good practice to have usage message over stderr ?
so the user doesn't miss it. even if he chances to redirect the output
...
just a suggestion.

+ break;
+ case 't':
+ nfs_mount_vers = (strncmp(optarg, "nfs4", 4)) ?
0 : 4;
+ break;

2. i dont think a -t option makes sense for mount.nfs mount.nfs itself says it is a nfs file system
you can pick up the version from -o nfsvers=4 to cater to nfs
version
-t is by legacy meant for specifying the filesystem type.

i also don't see why bind and other options need to be there for
mount.nfs

+
+int add_mtab(char *fsname, char *mount_point, char *fstype, int flags, char *opts, int freq, int passno)
+{

3. felt that there can be just be one function called mtab_update that can be kept in
the common utility source files you had so that both umount and
mount code can use it.

in nfs4mount.c
+#if defined(VAR_LOCK_DIR)
+#define DEFAULT_DIR VAR_LOCK_DIR
+#else
+#define DEFAULT_DIR "/var/lock/subsys"
+#endif
+
+extern int verbose;
+
+char *IDMAPLCK = DEFAULT_DIR "/rpcidmapd";
+#define idmapd_check() do { \
+ if (access(IDMAPLCK, F_OK)) { \
+ printf(_("Warning: rpc.idmapd appears not to be
running.\n" \
+ " All uids will be mapped to the nobody
uid.\n")); \
+ } \
+} while(0);
+
+char *GSSDLCK = DEFAULT_DIR "/rpcgssd";
+#define gssd_check() do { \
+ if (access(GSSDLCK, F_OK)) { \
+ printf(_("Warning: rpc.gssd appears not to be
running.\n")); \
+ } \
+} while(0);

4. very nice thing to do ... warn the user if idmapd and gssd are not running.
But then idmapd on suse doesn't seem to be writing into
/var/lock/subsys ...
Is /var/lock/subsys/ the standard way for daemons to show their
existence. ?
or is creation of /var/run/<daemon_name> a standard ? then idmapd scripts might need some change .. or else .. code needs some modification here to be able to work fine in all
distros ...

in nfsumount.c :

+ spec = argv[1];
+
+ argv += 1;
+ argc -= 1;
+
+ while ((c = getopt_long (argc, argv, "fvnrlh",
+ umount_longopts, NULL)) != -1) {

it'll be nice if you include -a option and have all nfs or nfs4 mounts
umounted on calling
umount.nfs -a
this is should be easy enough with an appropriate mtab utility
function.

thanks
chax.

P. S. Chakravarthi
Senior Software Engineer
[email protected]
Phone: 25731856 Extn: 3198

Novell Inc.
Software for the Open Enterprise

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#2 lore raw
Quoted 11 lines · Chakravarthi P
(quoted diff) +3 -0
+			break;
+		case 't':
+			nfs_mount_vers = (strncmp(optarg, "nfs4", 4)) ?

0 : 4;

(quoted diff) +1 -0
+			break;

2. i dont think a -t option makes sense for mount.nfs mount.nfs itself says it is a nfs file system
you can pick up the version from -o nfsvers=4 to cater to nfs
version
-t is by legacy meant for specifying the filesystem type.

-t nfs4 is required for compatibility with existing scripts and /etc/fstab entries.

Frank

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#3 lore raw
Quoted 7 lines · Frank Filz
Quoted 6 lines · Chakravarthi P
(quoted diff) +3 -0
+                     break;
+             case 't':
+                     nfs_mount_vers = (strncmp(optarg, "nfs4", 4)) ?

0 : 4;
+ break;

Quoted 8 lines
Quoted 5 lines

2. i dont think a -t option makes sense for mount.nfs mount.nfs itself says it is a nfs file system
you can pick up the version from -o nfsvers=4 to cater to nfs
version
-t is by legacy meant for specifying the filesystem type.

-t nfs4 is required for compatibility with existing scripts and /etc/fstab entries.

As far as I understand this, the mount command chooses which subcommand to execute based on the "-t" option. So the subcommands (such as mount.nfs) shouldn't have a "-t" option.

Instead, use two subcommands for NFS: mount.nfs and mount.nfs4.

Signature · 7 lines
"We who cut mere stones must always be envisioning cathedrals"
   -- Quarry worker's creed


_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
author
#4 lore raw
In reply to Chakravarthi P
Quoted 11 lines · Chakravarthi P

in mount.c :

(quoted diff) +3 -0
+void mount_usage()
+{
+	printf("usage: %s remotetarget dir [-rvVwfnh] [-t version] [-o

nfsoptions]\n", progname);

(quoted diff) +4 -0
+	printf("options:\n\t-r\t\tMount file system readonly\n");
+	printf("\t-v\t\tVerbose\n");
+	printf("\t-V\t\tPrint version\n");
+	printf("\t-w\t\tMount file system read-write\n");
Quoted 6 lines

1. isn't it generally a good practice to have usage message over stderr ?
so the user doesn't miss it. even if he chances to redirect the output
...
just a suggestion.

yes, good idea.

Quoted 6 lines
(quoted diff) +3 -0
+			break;
+		case 't':
+			nfs_mount_vers = (strncmp(optarg, "nfs4", 4)) ?

0 : 4;

(quoted diff) +1 -0
+			break;
Quoted 9 lines

2. i dont think a -t option makes sense for mount.nfs mount.nfs itself says it is a nfs file system
you can pick up the version from -o nfsvers=4 to cater to nfs
version
-t is by legacy meant for specifying the filesystem type.

i also don't see why bind and other options need to be there for
mount.nfs

The mount.nfs, though a subcommand for mount, is meant to be used even as a standalone binary with the limited functionality. -t option is there because theres just one binary for the different NFS versions, and -t is just used as a way to give the filesystem type, just like for mount there are nfs and nfs4 options for -t.

Quoted 9 lines
(quoted diff) +2 -0
+
+int add_mtab(char *fsname, char *mount_point, char *fstype, int flags,

char *opts, int freq, int passno)
+{

3. felt that there can be just be one function called mtab_update that can be kept in
the common utility source files you had so that both umount and
mount code can use it.

Yes, I will reorganize this.

Quoted 28 lines

in nfs4mount.c

(quoted diff) +12 -0
+#if defined(VAR_LOCK_DIR)
+#define DEFAULT_DIR VAR_LOCK_DIR
+#else
+#define DEFAULT_DIR "/var/lock/subsys"
+#endif
+
+extern int verbose;
+
+char *IDMAPLCK = DEFAULT_DIR "/rpcidmapd";
+#define idmapd_check() do { \
+	if (access(IDMAPLCK, F_OK)) { \
+		printf(_("Warning: rpc.idmapd appears not to be

running.\n" \

(quoted diff) +1 -0
+			"         All uids will be mapped to the nobody

uid.\n")); \

(quoted diff) +7 -0
+	} \
+} while(0);
+
+char *GSSDLCK = DEFAULT_DIR "/rpcgssd";
+#define gssd_check() do { \
+		if (access(GSSDLCK, F_OK)) { \
+			printf(_("Warning: rpc.gssd appears not to be

running.\n")); \

(quoted diff) +2 -0
+		} \
+} while(0); 
Quoted 10 lines

4. very nice thing to do ... warn the user if idmapd and gssd are not running.
But then idmapd on suse doesn't seem to be writing into
/var/lock/subsys ...
Is /var/lock/subsys/ the standard way for daemons to show their
existence. ?
or is creation of /var/run/<daemon_name> a standard ? then idmapd scripts might need some change .. or else .. code needs some modification here to be able to work fine in all
distros ...

I suppose /var/lock/subsys/ is the standard directory. I inherited the DEFAULT_DIR, that was being used in the util-linux mount.

Quoted 11 lines

in nfsumount.c :

(quoted diff) +7 -0
+	spec = argv[1];
+
+	argv += 1;
+	argc -= 1;
+
+	while ((c = getopt_long (argc, argv, "fvnrlh",
+				umount_longopts, NULL)) != -1) {
 
 it'll be nice if you include -a option and have all nfs or nfs4 mounts
Quoted 5 lines

umounted on calling
umount.nfs -a
this is should be easy enough with an appropriate mtab utility
function.

Yes, nice idea.

Best,
AG

Signature · 8 lines
May the source be with you.
http://www.cis.ksu.edu/~gud



_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
#5 lore raw
In reply to Amit Gud
Quoted 19 lines · On Monday June 12, [email protected] wrote:

AG

Signature · 15 lines
May the source be with you.
http://www.cis.ksu.edu/~gud

Moves the NFS mount code out of util-linux to nfs-utils. The primary reason being ease of maintainability, and keeping util-linux away from all the filesystem-specifc worries.

Adds a new directory 'mount' under utils. Creates a binary mount.nfs. Three symbolic links are created to this binary - mount.nfs4, umount.nfs and umount.nfs4. It is simpler and avoids code duplication (or overhead of fork->exec) by keeping umount code in a single binary along with the mount code. Mount code uses umount to handle certain fail cases. It also makes sense to keep single binary for all the versions of the NFS, as opposed to having seperate binaries mount.nfs and mount.nfs4, since the code falls back to lower version if mounting with v4 fails. Adds two man pages - mount.nfs(8) and umount.nfs(8).

Patches are split into two parts:
[1/2] nfsmount-migration-to-nfsutils-v2.patch
[2/2] nfsmount-migration-to-nfsutils-support-v2.patch

After applying the patches before configuring and compiling, do:
$ rpcgen -c utils/mount/nfsmount.x > utils/mount/nfsmount_xdr.c
$ rpcgen -h utils/mount/nfsmount.x > utils/mount/nfsmount.h
$ sh autogen.sh

The 'rpcgen' should be done by the Makefile. I have added a patch which does this.
However there are now two slightly different nfsmount.x files in the tree

./support/export/mount.x
./utils/mount/nfsmount.x

If they could be unified (leave the one in support/export, but merge in any changes you want from nfsmount.x) and then use the libexport.a library to get the nfsmount_clnt.o etc, that would be really good.

You can see the current code at
git://linux-nfs.org/nfs-utils

Further patches against that would be great.

Also, it seems really odd that you need
./configure --without-mount
it you want it to compile the mount client.
Surely it should be --with-mount!!!
What is the reasoning there?

NeilBrown

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#6 lore raw
Quoted 25 lines · Neil Brown
Quoted 18 lines · On Monday June 12, [email protected] wrote:

AG

Signature · 15 lines
May the source be with you.
http://www.cis.ksu.edu/~gud

Moves the NFS mount code out of util-linux to nfs-utils. The primary reason being ease of maintainability, and keeping util-linux away from all the filesystem-specifc worries.

Adds a new directory 'mount' under utils. Creates a binary mount.nfs. Three symbolic links are created to this binary - mount.nfs4, umount.nfs and umount.nfs4. It is simpler and avoids code duplication (or overhead of fork->exec) by keeping umount code in a single binary along with the mount code. Mount code uses umount to handle certain fail cases. It also makes sense to keep single binary for all the versions of the NFS, as opposed to having seperate binaries mount.nfs and mount.nfs4, since the code falls back to lower version if mounting with v4 fails. Adds two man pages - mount.nfs(8) and umount.nfs(8).

Patches are split into two parts:
[1/2] nfsmount-migration-to-nfsutils-v2.patch
[2/2] nfsmount-migration-to-nfsutils-support-v2.patch

After applying the patches before configuring and compiling, do:
$ rpcgen -c utils/mount/nfsmount.x > utils/mount/nfsmount_xdr.c
$ rpcgen -h utils/mount/nfsmount.x > utils/mount/nfsmount.h
$ sh autogen.sh

The 'rpcgen' should be done by the Makefile. I have added a patch which does this.
However there are now two slightly different nfsmount.x files in the tree

Quoted 6 lines

./support/export/mount.x
./utils/mount/nfsmount.x

If they could be unified (leave the one in support/export, but merge in any changes you want from nfsmount.x) and then use the libexport.a library to get the nfsmount_clnt.o etc, that would be really good.

sounds good.

Quoted 10 lines

You can see the current code at
git://linux-nfs.org/nfs-utils

Further patches against that would be great.

Also, it seems really odd that you need
./configure --without-mount
it you want it to compile the mount client.
Surely it should be --with-mount!!!
What is the reasoning there?

I went with the GNU Autoconf Manual ;),
http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_mono/autoconf.html#SEC130,
which says --with-foo, when external program foo is to be used, and --without-foo otherwise. But I know, it sounds rather odd. I think, I'II change it to --with-mount.

AG

Signature · 8 lines
May the source be with you.
http://www.cis.ksu.edu/~gud



_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
#7 lore raw
Quoted 7 lines · On Thursday June 15, [email protected] wrote:
Quoted 6 lines

Also, it seems really odd that you need
./configure --without-mount
it you want it to compile the mount client.
Surely it should be --with-mount!!!
What is the reasoning there?

Quoted 6 lines

I went with the GNU Autoconf Manual ;),
http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_mono/autoconf.html#SEC130,
which says --with-foo, when external program foo is to be used, and --without-foo otherwise. But I know, it sounds rather odd. I think, I'II change it to --with-mount.

Ahh... I see what you were thinking, and it does seem to make sense in a way...

I think the '--with-foo' is when you want the package you are using to make use of some other program.
In this case nfs-utils doesn't have the option of using mount. It is the sysadmin who may use mount, or may use nfs-utils/mount.

I think you should make it an enable/disable feature. Default to --enable-mount, but allow --disable-mount.

NeilBrown

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs