mknod: Add support for making FIFOs
This commit is contained in:
parent
ba2f04f391
commit
4542db4e40
31
mknod.1
31
mknod.1
|
@ -8,25 +8,32 @@
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl m Ar mode
|
.Op Fl m Ar mode
|
||||||
.Ar name
|
.Ar name
|
||||||
.Ar type
|
.Cm b Ns | Ns Cm c Ns | Ns Cm u
|
||||||
.Ar major
|
.Ar major
|
||||||
.Ar minor
|
.Ar minor
|
||||||
|
.Nm
|
||||||
|
.Op Fl m Ar mode
|
||||||
|
.Ar name
|
||||||
|
.Cm p
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
creates a special device file named
|
creates a special file named
|
||||||
.Ar name
|
.Ar name .
|
||||||
with major number
|
.Pp
|
||||||
|
The following special file types are supported:
|
||||||
|
.Bl -tag -width Ds
|
||||||
|
.It Cm b
|
||||||
|
A block device.
|
||||||
|
.It Cm c | u
|
||||||
|
A character device.
|
||||||
|
.It Cm p
|
||||||
|
A named pipe.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
Block and character devices are created with major number
|
||||||
.Ar major ,
|
.Ar major ,
|
||||||
and minor number
|
and minor number
|
||||||
.Ar minor .
|
.Ar minor .
|
||||||
.Ar type
|
|
||||||
specifies what kind of special file will be created and must be one of:
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Ar u | c
|
|
||||||
A character device.
|
|
||||||
.It Ar b
|
|
||||||
A block device.
|
|
||||||
.El
|
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl m
|
.It Fl m
|
||||||
|
|
19
mknod.c
19
mknod.c
|
@ -16,7 +16,9 @@
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-m mode] name type major minor\n", argv0);
|
eprintf("usage: %s [-m mode] name b|c|u major minor\n"
|
||||||
|
" %s [-m mode] name p\n",
|
||||||
|
argv0, argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -33,7 +35,7 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc < 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (strlen(argv[1]) != 1)
|
if (strlen(argv[1]) != 1)
|
||||||
|
@ -46,12 +48,23 @@ main(int argc, char *argv[])
|
||||||
case 'c':
|
case 'c':
|
||||||
mode |= S_IFCHR;
|
mode |= S_IFCHR;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
mode |= S_IFIFO;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
invalid:
|
invalid:
|
||||||
eprintf("invalid type '%s'\n", argv[1]);
|
eprintf("invalid type '%s'\n", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = makedev(estrtonum(argv[2], 0, LLONG_MAX), estrtonum(argv[3], 0, LLONG_MAX));
|
if (S_ISFIFO(mode)) {
|
||||||
|
if (argc != 2)
|
||||||
|
usage();
|
||||||
|
dev = 0;
|
||||||
|
} else {
|
||||||
|
if (argc != 4)
|
||||||
|
usage();
|
||||||
|
dev = makedev(estrtonum(argv[2], 0, LLONG_MAX), estrtonum(argv[3], 0, LLONG_MAX));
|
||||||
|
}
|
||||||
|
|
||||||
if (mknod(argv[0], mode, dev) == -1)
|
if (mknod(argv[0], mode, dev) == -1)
|
||||||
eprintf("mknod %s:", argv[0]);
|
eprintf("mknod %s:", argv[0]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user