Rather than using specified_ro to parse the options list an extra time, and
keeping a flag to check whether we actually wanted to mount the filesystem readonly, setup the options list so that we start off by assuming rw is what's desired and let later flags change that.
This commit is contained in:
parent
672e707a61
commit
5256cc2152
@ -184,26 +184,6 @@ exec_mountprog(const char *name, const char *execname,
|
||||
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
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -212,12 +192,14 @@ main(int argc, char *argv[])
|
||||
struct statfs *mntbuf;
|
||||
FILE *mountdfp;
|
||||
pid_t pid;
|
||||
int all, ch, i, init_flags, mntsize, rval, have_fstab, ro;
|
||||
int all, ch, i, init_flags, mntsize, rval, have_fstab;
|
||||
char *cp, *ep, *options;
|
||||
|
||||
options = strdup("noro");
|
||||
if (options == NULL)
|
||||
errx(1, "malloc failed");
|
||||
|
||||
all = init_flags = 0;
|
||||
ro = 0;
|
||||
options = NULL;
|
||||
vfslist = NULL;
|
||||
vfstype = "ufs";
|
||||
while ((ch = getopt(argc, argv, "adF:fo:prwt:uv")) != -1)
|
||||
@ -235,11 +217,7 @@ main(int argc, char *argv[])
|
||||
init_flags |= MNT_FORCE;
|
||||
break;
|
||||
case 'o':
|
||||
if (*optarg) {
|
||||
options = catopt(options, optarg);
|
||||
if (specified_ro(optarg))
|
||||
ro = 1;
|
||||
}
|
||||
options = catopt(options, optarg);
|
||||
break;
|
||||
case 'p':
|
||||
fstab_style = 1;
|
||||
@ -247,7 +225,6 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'r':
|
||||
options = catopt(options, "ro");
|
||||
ro = 1;
|
||||
break;
|
||||
case 't':
|
||||
if (vfslist != NULL)
|
||||
@ -276,9 +253,6 @@ main(int argc, char *argv[])
|
||||
(strcmp(type, FSTAB_RO) && \
|
||||
strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
|
||||
|
||||
if ((init_flags & MNT_UPDATE) && (ro == 0))
|
||||
options = catopt(options, "noro");
|
||||
|
||||
rval = 0;
|
||||
switch (argc) {
|
||||
case 0:
|
||||
|
Loading…
Reference in New Issue
Block a user