[patch] nmount ro, rw and negated option handling

Jaakko Heinonen jh at FreeBSD.org
Sat Feb 19 14:32:35 UTC 2011


On 2011-01-25, Jaakko Heinonen wrote:
> Another related bug is in vfs_domount_update(): if VFS_MOUNT() succeeds
> but vfs_export() fails, old mount flags and options are restored. I
> think this shouldn't happen when VFS_MOUNT() has been already
> successfully completed and this is the final reason why FFS fs_ronly and
> the MNT_RDONLY flag get out of sync. Does the patch below look sane?
> 
> %%%
> Index: sys/kern/vfs_mount.c
> ===================================================================
> --- sys/kern/vfs_mount.c	(revision 217792)
> +++ sys/kern/vfs_mount.c	(working copy)

I have committed an updated version as r218852.

Unless there are objections, I plan to commit something like this next:


Recognize "ro", "rdonly", "norw", "rw" and "noro" as equal options in
vfs_equalopts(). This allows vfs_sanitizeopts() to filter redundant
occurrences of these options. It was possible that for example both "ro"
and "rw" options became active concurrently.

PR:		kern/133614

%%%
Index: sys/kern/vfs_mount.c
===================================================================
--- sys/kern/vfs_mount.c	(revision 218446)
+++ sys/kern/vfs_mount.c	(working copy)
@@ -175,6 +175,27 @@ vfs_deleteopt(struct vfsoptlist *opts, c
 	}
 }
 
+static int
+vfs_isopt_ro(const char *opt)
+{
+
+	if (strcmp(opt, "ro") == 0 || strcmp(opt, "rdonly") == 0 ||
+	    strcmp(opt, "norw") == 0)
+		return (1);
+	else
+		return (0);
+}
+
+static int
+vfs_isopt_rw(const char *opt)
+{
+
+	if (strcmp(opt, "rw") == 0 || strcmp(opt, "noro") == 0)
+		return (1);
+	else
+		return (0);
+}
+
 /*
  * Check if options are equal (with or without the "no" prefix).
  */
@@ -203,6 +224,11 @@ vfs_equalopts(const char *opt1, const ch
 		if (strncmp(opt2, "no", 2) == 0 && strcmp(opt1, opt2 + 2) == 0)
 			return (1);
 	}
+	/* "ro" / "rdonly" / "norw" / "rw" / "noro" */
+	if ((vfs_isopt_ro(opt1) || vfs_isopt_rw(opt1)) &&
+	    (vfs_isopt_ro(opt2) || vfs_isopt_rw(opt2)))
+		return (1);
+
 	return (0);
 }
 
%%%

-- 
Jaakko


More information about the freebsd-hackers mailing list