summaryrefslogtreecommitdiffstats
path: root/sbin/mdmfs/mdmfs.c
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2003-08-05 15:04:39 +0000
committeryar <yar@FreeBSD.org>2003-08-05 15:04:39 +0000
commit186be00c7486a491b16114fda3e051d4a4fb0e75 (patch)
treeca0c68957bce4ecf984b91a3f6a61b0d57e19fb2 /sbin/mdmfs/mdmfs.c
parenta00853028bf6ab555c105dde4b09bc90bd2649c1 (diff)
downloadFreeBSD-src-186be00c7486a491b16114fda3e051d4a4fb0e75.zip
FreeBSD-src-186be00c7486a491b16114fda3e051d4a4fb0e75.tar.gz
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).
Diffstat (limited to 'sbin/mdmfs/mdmfs.c')
-rw-r--r--sbin/mdmfs/mdmfs.c7
1 files changed, 4 insertions, 3 deletions
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)
OpenPOWER on IntegriCloud