From 186be00c7486a491b16114fda3e051d4a4fb0e75 Mon Sep 17 00:00:00 2001 From: yar Date: Tue, 5 Aug 2003 15:04:39 +0000 Subject: Don't reinvent the wheel: Use setmode(3) to interpret a file mode specification from the command line. This approach is more flexible and less error-prone than using a mere strtoul(3). --- sbin/mdmfs/mdmfs.8 | 11 +++++++++++ sbin/mdmfs/mdmfs.c | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'sbin/mdmfs') diff --git a/sbin/mdmfs/mdmfs.8 b/sbin/mdmfs/mdmfs.8 index 9db5194..daf66c2 100644 --- a/sbin/mdmfs/mdmfs.8 +++ b/sbin/mdmfs/mdmfs.8 @@ -200,6 +200,17 @@ Set the file (directory) permissions of the mount point .Ar mount-point to .Ar permissions . +The +.Ar permissions +argument can be in any of the mode formats recognized by +.Xr chmod 1 . +If symbolic permissions are specified, +the operation characters +.Dq + +and +.Dq - +are interpreted relative to the initial permissions of +.Dq a=rwx . .It Fl S Do not enable soft-updates on the file system. .It Fl s Ar size diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c index 035f1fe..db143cc 100644 --- a/sbin/mdmfs/mdmfs.c +++ b/sbin/mdmfs/mdmfs.c @@ -92,6 +92,7 @@ main(int argc, char **argv) bool detach, softdep, autounit; char *mtpoint, *unitstr; char ch, *p; + void *set; /* Misc. initialization. */ (void)memset(&mi, '\0', sizeof(mi)); @@ -191,11 +192,11 @@ main(int argc, char **argv) case 'p': if (compat) usage(); - if (*optarg >= '0' && *optarg <= '7') - mi.mi_mode = strtol(optarg, NULL, 8); - if ((mi.mi_mode & ~07777) != 0) + if ((set = setmode(optarg)) == NULL) usage(); + mi.mi_mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO); mi.mi_have_mode = true; + free(set); break; case 'S': if (compat) -- cgit v1.1