summaryrefslogtreecommitdiffstats
path: root/sbin/devfs
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2004-11-06 11:03:59 +0000
committerdd <dd@FreeBSD.org>2004-11-06 11:03:59 +0000
commitd4e51893426e1528f2041fe68e48922cbe989786 (patch)
treeb2891388f91cdd31a0c7094f1008139c7d0bd75c /sbin/devfs
parentbecc212fd34eb2fe45097dd6e04187cfd3666a0b (diff)
downloadFreeBSD-src-d4e51893426e1528f2041fe68e48922cbe989786.zip
FreeBSD-src-d4e51893426e1528f2041fe68e48922cbe989786.tar.gz
Parse file mode with setmode(3) for consistency with other programs
that do this kind of thing.
Diffstat (limited to 'sbin/devfs')
-rw-r--r--sbin/devfs/devfs.83
-rw-r--r--sbin/devfs/rule.c18
2 files changed, 9 insertions, 12 deletions
diff --git a/sbin/devfs/devfs.8 b/sbin/devfs/devfs.8
index 1d7d442..0953429 100644
--- a/sbin/devfs/devfs.8
+++ b/sbin/devfs/devfs.8
@@ -202,7 +202,8 @@ This does not necessarily result in any changes to the node
.It Cm mode Ar filemode
Set the file mode to
.Ar filemode ,
-which is interpreted in octal.
+which is interpreted as in
+.Xr chmod 1 .
.It Cm user Ar uid
Set the UID to
.Ar uid ,
diff --git a/sbin/devfs/rule.c b/sbin/devfs/rule.c
index b179c9e..d6b6ea3 100644
--- a/sbin/devfs/rule.c
+++ b/sbin/devfs/rule.c
@@ -314,8 +314,7 @@ rulespec_intok(struct devfs_rule *dr, int ac __unused, char **av,
struct passwd *pw;
struct group *gr;
devfs_rnum rnum;
- char *cp;
- long l;
+ void *set;
memset(dr, '\0', sizeof(*dr));
@@ -367,10 +366,8 @@ rulespec_intok(struct devfs_rule *dr, int ac __unused, char **av,
} else
break;
}
- for (;;) {
- if (av[0] == NULL)
- break;
- else if (strcmp(av[0], "hide") == 0) {
+ while (av[0] != NULL) {
+ if (strcmp(av[0], "hide") == 0) {
dr->dr_iacts |= DRA_BACTS;
dr->dr_bacts |= DRB_HIDE;
++av;
@@ -402,11 +399,10 @@ rulespec_intok(struct devfs_rule *dr, int ac __unused, char **av,
if (av[1] == NULL)
errx(1, "expecting argument for mode");
dr->dr_iacts |= DRA_MODE;
- l = strtol(av[1], &cp, 8);
- if (l > (1 << (sizeof(dr->dr_mode) * 8)) - 1 ||
- *cp != '\0')
- errx(1, "invalid mode: %s", av[1]);
- dr->dr_mode = l;
+ set = setmode(av[1]);
+ if (set == NULL)
+ errx(1, "invald mode: %s", av[1]);
+ dr->dr_mode = getmode(set, 0);
av += 2;
} else if (strcmp(av[0], "include") == 0) {
if (av[1] == NULL)
OpenPOWER on IntegriCloud