Compatibility options for mount(8)

Kirk McKusick mckusick at mckusick.com
Tue Jul 2 03:42:28 UTC 2013


> Date: Tue, 2 Jul 2013 01:11:52 +0200
> Subject: Compatibility options for mount(8)
> From: Robert Millan <rmh at freebsd.org>
> To: freebsd-fs at freebsd.org
> 
> Hi,
> 
> On Debian GNU/kFreeBSD, we've been using these bits of glue to make
> FreeBSD mount a bit more compatible with the Linux version of mount.

Your proposed changes look reasonable to me. Some comments below.
Also you need to update the manual page for mount to document these
two changes lest someone be surprised or confused.

> We found that this occasionally helps when porting software that needs
> to use those features and relies on Linux semantics:
> 
>   - Ignore "-n" flag, since it requests not to update /etc/mtab, which
> we never do anyway.
> 
>   - Map "-o remount" to its FreeBSD equivalent, "-o update".

It is shorter to remap it to "-u" which is shorthand for "-o update".

> I'd like to check in the attached patch. Please have a look!
> 
> Thanks
> 
> --
> Robert Millan
> 
> Index: sbin/mount/mount.c
> ===================================================================
> --- sbin/mount/mount.c	(revision 252490)
> +++ sbin/mount/mount.c	(working copy)
> @@ -253,7 +253,7 @@
>  	options = NULL;
>  	vfslist = NULL;
>  	vfstype = "ufs";
> -	while ((ch = getopt(argc, argv, "adF:fLlo:prt:uvw")) != -1)
> +	while ((ch = getopt(argc, argv, "adF:fLlo:prt:uvwn")) != -1)

Our coding style is to sort the options into alphabetical order.
So the "n" option should be between "l" and "o".

>  		switch (ch) {
>  		case 'a':
>  			all = 1;
> @@ -274,6 +274,9 @@
>  		case 'l':
>  			late = 1;
>  			break;
> +		case 'n':
> +			/* For compatibility with the Linux version of mount. */
> +			break;
>  		case 'o':
>  			if (*optarg) {
>  				options = catopt(options, optarg);
> @@ -771,6 +774,11 @@
>  			} else if (strncmp(p, groupquotaeq,
>  			    sizeof(groupquotaeq) - 1) == 0) {
>  				continue;
> +			} else if (strcmp(p, "remount") == 0) {
> +				/* For compatibility with the Linux version of mount. */
> +				append_arg(a, strdup("-o"));
> +				append_arg(a, strdup("update"));
> +				continue;

As noted above, I would recoomend using "-u".

>  			} else if (*p == '-') {
>  				append_arg(a, p);
>  				p = strchr(p, '=');

	Kirk McKusick


More information about the freebsd-fs mailing list