Revert rev. 1.86 by jmallett@ as it breaks "ro" mounts specified
in /etc/fstab. This has been happening due to the priority inversion; options specified on the command line should take precedence over options from fstab over default "noro" option, but since both the default "noro" and options specified on the command line (-w, -r, -o ...) were put into the same "options" variable, "noro" took precedence over fstab "ro" (this is easily visible with "mount -d"). PR: bin/100164
This commit is contained in:
parent
9f5cc52fb6
commit
3cbf527e8d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163671
@ -183,6 +183,26 @@ exec_mountprog(const char *name, const char *execname, char *const argv[])
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int specified_ro(const char *arg)
|
||||||
|
{
|
||||||
|
char *optbuf, *opt;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
optbuf = strdup(arg);
|
||||||
|
if (optbuf == NULL)
|
||||||
|
err(1, NULL);
|
||||||
|
|
||||||
|
for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
|
||||||
|
if (strcmp(opt, "ro") == 0) {
|
||||||
|
ret = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(optbuf);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -191,14 +211,12 @@ main(int argc, char *argv[])
|
|||||||
struct statfs *mntbuf;
|
struct statfs *mntbuf;
|
||||||
FILE *mountdfp;
|
FILE *mountdfp;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int all, ch, i, init_flags, late, mntsize, rval, have_fstab;
|
int all, ch, i, init_flags, late, mntsize, rval, have_fstab, ro;
|
||||||
char *cp, *ep, *options;
|
char *cp, *ep, *options;
|
||||||
|
|
||||||
options = strdup("noro");
|
|
||||||
if (options == NULL)
|
|
||||||
errx(1, "malloc failed");
|
|
||||||
|
|
||||||
all = init_flags = late = 0;
|
all = init_flags = late = 0;
|
||||||
|
ro = 0;
|
||||||
|
options = NULL;
|
||||||
vfslist = NULL;
|
vfslist = NULL;
|
||||||
vfstype = "ufs";
|
vfstype = "ufs";
|
||||||
while ((ch = getopt(argc, argv, "adlF:fo:prwt:uv")) != -1)
|
while ((ch = getopt(argc, argv, "adlF:fo:prwt:uv")) != -1)
|
||||||
@ -219,7 +237,11 @@ main(int argc, char *argv[])
|
|||||||
late = 1;
|
late = 1;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
options = catopt(options, optarg);
|
if (*optarg) {
|
||||||
|
options = catopt(options, optarg);
|
||||||
|
if (specified_ro(optarg))
|
||||||
|
ro = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
fstab_style = 1;
|
fstab_style = 1;
|
||||||
@ -227,6 +249,7 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
options = catopt(options, "ro");
|
options = catopt(options, "ro");
|
||||||
|
ro = 1;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (vfslist != NULL)
|
if (vfslist != NULL)
|
||||||
@ -255,6 +278,9 @@ main(int argc, char *argv[])
|
|||||||
(strcmp(type, FSTAB_RO) && \
|
(strcmp(type, FSTAB_RO) && \
|
||||||
strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
|
strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
|
||||||
|
|
||||||
|
if ((init_flags & MNT_UPDATE) && (ro == 0))
|
||||||
|
options = catopt(options, "noro");
|
||||||
|
|
||||||
rval = 0;
|
rval = 0;
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 0:
|
case 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user