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
Discussed on:	freebsd-hackers
MFC after:	1 month
This commit is contained in:
Jaakko Heinonen 2011-03-23 17:56:38 +00:00
parent e9a3f7852d
commit 3fd8fe5b54

View File

@ -175,6 +175,27 @@ vfs_deleteopt(struct vfsoptlist *opts, const char *name)
}
}
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 char *opt2)
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);
}