MFC 1.89, 1.90

Fix "mount -u -o ro" and "mount -u -o rw".

PR:		104687
This commit is contained in:
rodrigc 2007-01-28 01:24:57 +00:00
parent ed4b2c771e
commit 8cea67fc48

View File

@ -120,6 +120,26 @@ remountable_fs_names[] = {
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(argc, argv)
int argc;
@ -130,10 +150,11 @@ main(argc, argv)
struct statfs *mntbuf;
FILE *mountdfp;
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;
all = init_flags = late = 0;
ro = 0;
options = NULL;
vfslist = NULL;
vfstype = "ufs";
@ -155,8 +176,11 @@ main(argc, argv)
late = 1;
break;
case 'o':
if (*optarg)
if (*optarg) {
options = catopt(options, optarg);
if (specified_ro(optarg))
ro = 1;
}
break;
case 'p':
fstab_style = 1;
@ -164,6 +188,7 @@ main(argc, argv)
break;
case 'r':
options = catopt(options, "ro");
ro = 1;
break;
case 't':
if (vfslist != NULL)
@ -192,6 +217,9 @@ main(argc, 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: