Simplyfing mknod. Good eye, Truls Becken.
This commit is contained in:
parent
1fbe4e95ed
commit
3c5f2b2407
6
mknod.c
6
mknod.c
|
@ -17,12 +17,8 @@ int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
mode_t type, mode = 0644;
|
mode_t type, mode = 0644;
|
||||||
mode_t types['u'+1];
|
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
|
|
||||||
types['u'] = types['c'] = S_IFCHR;
|
|
||||||
types['b'] = S_IFBLK;
|
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'm':
|
case 'm':
|
||||||
mode = estrtol(EARGF(usage()), 8);
|
mode = estrtol(EARGF(usage()), 8);
|
||||||
|
@ -36,7 +32,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if(strlen(argv[1]) != 1 || !strchr("ucb", argv[1][0]))
|
if(strlen(argv[1]) != 1 || !strchr("ucb", argv[1][0]))
|
||||||
eprintf("mknod: '%s': invalid type\n", argv[1]);
|
eprintf("mknod: '%s': invalid type\n", argv[1]);
|
||||||
type = types[(unsigned)argv[1][0]];
|
type = (argv[1][0] == 'b') ? S_IFBLK : S_IFCHR;
|
||||||
|
|
||||||
dev = makedev(estrtol(argv[2], 0), estrtol(argv[3], 0));
|
dev = makedev(estrtol(argv[2], 0), estrtol(argv[3], 0));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user