summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/mknod/mknod.818
-rw-r--r--sbin/mknod/mknod.c54
2 files changed, 40 insertions, 32 deletions
diff --git a/sbin/mknod/mknod.8 b/sbin/mknod/mknod.8
index 9de2804..22efbd1 100644
--- a/sbin/mknod/mknod.8
+++ b/sbin/mknod/mknod.8
@@ -28,7 +28,7 @@
.\" @(#)mknod.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd October 31, 2009
+.Dd January 31, 2010
.Dt MKNOD 8
.Os
.Sh NAME
@@ -37,6 +37,8 @@
.Sh SYNOPSIS
.Nm
.Ar name
+.Nm
+.Ar name
.Op Cm b | c
.Ar major minor
.Op Ar owner : Ns Ar group
@@ -52,14 +54,14 @@ systems.
The
.Nm
utility creates device special files.
-To make nodes manually, the four required arguments are:
+To make nodes manually, the arguments are:
.Pp
.Bl -tag -width indent
.It Ar name
Device name, for example
-.Dq sd
-for a SCSI disk on an HP300 or a
-.Dq pty
+.Pa /dev/da0
+for a SCSI disk or
+.Pa /dev/pts/0
for pseudo-terminals.
.It Cm b | c
Type of device.
@@ -110,13 +112,13 @@ The
.Nm
utility can be used to recreate deleted device nodes under a
.Xr devfs 5
-mount point by invoking it using dummy arguments.
+mount point by invoking it with only a filename as an argument.
Example:
.Pp
-.Dl "mknod cd0 c 0 0"
+.Dl "mknod /dev/cd0"
.Pp
where
-.Dq Li cd0
+.Pa /dev/cd0
is the name of the deleted device node.
.Sh COMPATIBILITY
The
diff --git a/sbin/mknod/mknod.c b/sbin/mknod/mknod.c
index 4c6c399..6905cae 100644
--- a/sbin/mknod/mknod.c
+++ b/sbin/mknod/mknod.c
@@ -61,7 +61,8 @@ usage(void)
{
(void)fprintf(stderr,
- "usage: mknod name [b | c] major minor [owner:group]\n");
+ "usage: mknod name\n"
+ " mknod name [b | c] major minor [owner:group]\n");
exit(1);
}
@@ -115,31 +116,36 @@ main(int argc, char **argv)
char *cp, *endp;
long mymajor, myminor;
- if (argc != 5 && argc != 6)
+ if (argc != 2 && argc != 5 && argc != 6)
usage();
- mode = 0666;
- if (argv[2][0] == 'c')
- mode |= S_IFCHR;
- else if (argv[2][0] == 'b')
- mode |= S_IFBLK;
- else
- errx(1, "node must be type 'b' or 'c'");
-
- errno = 0;
- mymajor = (long)strtoul(argv[3], &endp, 0);
- if (endp == argv[3] || *endp != '\0')
- errx(1, "%s: non-numeric major number", argv[3]);
- range_error = errno;
- errno = 0;
- myminor = (long)strtoul(argv[4], &endp, 0);
- if (endp == argv[4] || *endp != '\0')
- errx(1, "%s: non-numeric minor number", argv[4]);
- range_error |= errno;
- dev = makedev(mymajor, myminor);
- if (range_error || major(dev) != (u_int) mymajor ||
- (long)(u_int)minor(dev) != myminor)
- errx(1, "major or minor number too large");
+ if (argc >= 5) {
+ mode = 0666;
+ if (argv[2][0] == 'c')
+ mode |= S_IFCHR;
+ else if (argv[2][0] == 'b')
+ mode |= S_IFBLK;
+ else
+ errx(1, "node must be type 'b' or 'c'");
+
+ errno = 0;
+ mymajor = (long)strtoul(argv[3], &endp, 0);
+ if (endp == argv[3] || *endp != '\0')
+ errx(1, "%s: non-numeric major number", argv[3]);
+ range_error = errno;
+ errno = 0;
+ myminor = (long)strtoul(argv[4], &endp, 0);
+ if (endp == argv[4] || *endp != '\0')
+ errx(1, "%s: non-numeric minor number", argv[4]);
+ range_error |= errno;
+ dev = makedev(mymajor, myminor);
+ if (range_error || major(dev) != (u_int) mymajor ||
+ (long)(u_int)minor(dev) != myminor)
+ errx(1, "major or minor number too large");
+ } else {
+ mode = 0666 | S_IFCHR;
+ dev = 0;
+ }
uid = gid = -1;
if (6 == argc) {
OpenPOWER on IntegriCloud