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).
This commit is contained in:
parent
7e3d4432af
commit
ce03e3a7bd
@ -200,6 +200,17 @@ Set the file (directory) permissions of the mount point
|
|||||||
.Ar mount-point
|
.Ar mount-point
|
||||||
to
|
to
|
||||||
.Ar permissions .
|
.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
|
.It Fl S
|
||||||
Do not enable soft-updates on the file system.
|
Do not enable soft-updates on the file system.
|
||||||
.It Fl s Ar size
|
.It Fl s Ar size
|
||||||
|
@ -92,6 +92,7 @@ main(int argc, char **argv)
|
|||||||
bool detach, softdep, autounit;
|
bool detach, softdep, autounit;
|
||||||
char *mtpoint, *unitstr;
|
char *mtpoint, *unitstr;
|
||||||
char ch, *p;
|
char ch, *p;
|
||||||
|
void *set;
|
||||||
|
|
||||||
/* Misc. initialization. */
|
/* Misc. initialization. */
|
||||||
(void)memset(&mi, '\0', sizeof(mi));
|
(void)memset(&mi, '\0', sizeof(mi));
|
||||||
@ -191,11 +192,11 @@ main(int argc, char **argv)
|
|||||||
case 'p':
|
case 'p':
|
||||||
if (compat)
|
if (compat)
|
||||||
usage();
|
usage();
|
||||||
if (*optarg >= '0' && *optarg <= '7')
|
if ((set = setmode(optarg)) == NULL)
|
||||||
mi.mi_mode = strtol(optarg, NULL, 8);
|
|
||||||
if ((mi.mi_mode & ~07777) != 0)
|
|
||||||
usage();
|
usage();
|
||||||
|
mi.mi_mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
mi.mi_have_mode = true;
|
mi.mi_have_mode = true;
|
||||||
|
free(set);
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (compat)
|
if (compat)
|
||||||
|
Loading…
Reference in New Issue
Block a user