diff options
author | Dima Dorfman <dd@FreeBSD.org> | 2001-08-16 02:40:29 +0000 |
---|---|---|
committer | Dima Dorfman <dd@FreeBSD.org> | 2001-08-16 02:40:29 +0000 |
commit | f7acb7e404f2e3ba797cdcc633ce48f6bb835322 (patch) | |
tree | 03e22a24c882200c64ef7e1175643eee1749432d /sbin/mdmfs/mdmfs.c | |
parent | 5ae083292b7fe54b1e38dba4891618549782739c (diff) | |
download | src-f7acb7e404f2e3ba797cdcc633ce48f6bb835322.tar.gz src-f7acb7e404f2e3ba797cdcc633ce48f6bb835322.zip |
Implement a better compatibility mode with mount_mfs. It is the
default if the executable is named (called as) "mount_*", or can be
enabled with the -C option. This allows users to leave their old
fstab entires unchanged (modulo symlink'ing mdmfs to mount(md|mfs))
and have things behave the way they should (by emulating mount_mfs
silliness), while still allowing mdmfs to be used as a generic
make-an-md-and-mount-it type thing.
Right now, the only effects of this option is to set the mount-point
mode to 01777 as if "-p 1777" was given, and to complain about getting
command-line options that mount_mfs didn't take (e.g., -X, -L, et al).
The latter is mostly to try to catch operator errors.
Also implement -U, which turns on soft-updates. It's redundant (since
softdep is the default), but implement it anyway for compatibility.
Notes
Notes:
svn path=/head/; revision=81742
Diffstat (limited to 'sbin/mdmfs/mdmfs.c')
-rw-r--r-- | sbin/mdmfs/mdmfs.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c index 02c336a254cc..62a3316bbb0e 100644 --- a/sbin/mdmfs/mdmfs.c +++ b/sbin/mdmfs/mdmfs.c @@ -65,6 +65,7 @@ struct mtpt_info { bool mi_have_mode; }; +static bool compat; /* Full compatibility with mount_mfs? */ static bool debug; /* Emit debugging information? */ static bool loudsubs; /* Suppress output from helper programs? */ static bool norun; /* Actually run the helper programs? */ @@ -115,8 +116,12 @@ main(int argc, char **argv) newfs_arg = strdup(""); mount_arg = strdup(""); + /* If we were started as mount_*, imply -C. */ + if (strncmp(getprogname(), "mount_", 6) == 0) + compat = true; + while ((ch = getopt(argc, argv, - "a:b:c:Dd:e:F:f:hi:LMm:Nn:O:o:p:Ss:t:w:X")) != -1) + "a:b:Cc:Dd:e:F:f:hi:LMm:Nn:O:o:p:Ss:t:Uw:X")) != -1) switch (ch) { case 'a': argappend(&newfs_arg, "-a %s", optarg); @@ -124,10 +129,17 @@ main(int argc, char **argv) case 'b': argappend(&newfs_arg, "-b %s", optarg); break; + case 'C': + if (compat) + usage(); + compat = true; + break; case 'c': argappend(&newfs_arg, "-c %s", optarg); break; case 'D': + if (compat) + usage(); detach = false; break; case 'd': @@ -153,6 +165,8 @@ main(int argc, char **argv) argappend(&newfs_arg, "-i %s", optarg); break; case 'L': + if (compat) + usage(); loudsubs = true; break; case 'M': @@ -165,6 +179,8 @@ main(int argc, char **argv) argappend(&newfs_arg, "-m %s", optarg); break; case 'N': + if (compat) + usage(); norun = true; break; case 'n': @@ -177,6 +193,8 @@ main(int argc, char **argv) argappend(&mount_arg, "-o %s", optarg); break; case 'p': + if (compat) + usage(); if (*optarg >= '0' && *optarg <= '7') mi.mi_mode = strtol(optarg, NULL, 8); if ((mi.mi_mode & ~07777) != 0) @@ -184,15 +202,24 @@ main(int argc, char **argv) mi.mi_have_mode = true; break; case 'S': + if (compat) + usage(); softdep = false; break; case 's': argappend(&mdconfig_arg, "-s %s", optarg); break; + case 'U': + softdep = true; + break; case 'w': + if (compat) + usage(); extract_ugid(optarg, &mi); break; case 'X': + if (compat) + usage(); debug = true; break; default: @@ -203,6 +230,12 @@ main(int argc, char **argv) if (argc < 2) usage(); + /* Make compatibility assumptions. */ + if (compat) { + mi.mi_mode = 01777; + mi.mi_have_mode = true; + } + /* Derive 'unit' (global). */ unitstr = argv[0]; if (strncmp(unitstr, "/dev/", 5) == 0) @@ -634,12 +667,23 @@ run(int *ofd, const char *cmdline, ...) static void usage(void) { + const char *name; - fprintf(stderr, -"usage: %s [-DLMNSX] [-a maxcontig] [-b block-size] [-c cylinders]\n" + if (compat) + name = getprogname(); + else + name = "mdmfs"; + if (!compat) + fprintf(stderr, +"Usage: %s [-DLMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n" "\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n" "\t[-m percent-free] [-n rotational-positions] [-O optimization]\n" "\t[-o mount-options] [-p permissions] [-s size] [-w user:group]\n" -"\tmd-device mount-point\n", getprogname()); +"\tmd-device mount-point\n", name); + fprintf(stderr, +"Usage: %s -C [-NU] [-a maxcontig] [-b block-size] [-c cylinders]\n" +"\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n" +"\t[-m percent-free] [-n rotational-positions] [-O optimization]\n" +"\t[-o mount-options] [-s size] md-device mount-point\n", name); exit(1); } |