From owner-svn-src-head@FreeBSD.ORG Sun Jan 31 11:48:26 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 144421065672; Sun, 31 Jan 2010 11:48:26 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 02DDA8FC28; Sun, 31 Jan 2010 11:48:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0VBmPQL014563; Sun, 31 Jan 2010 11:48:25 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0VBmPeE014560; Sun, 31 Jan 2010 11:48:25 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201001311148.o0VBmPeE014560@svn.freebsd.org> From: Ed Schouten Date: Sun, 31 Jan 2010 11:48:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203277 - head/sbin/mknod X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Jan 2010 11:48:26 -0000 Author: ed Date: Sun Jan 31 11:48:25 2010 New Revision: 203277 URL: http://svn.freebsd.org/changeset/base/203277 Log: Allow mknod(8) to be only invoked with a pathname as an argument. In 99% of the cases people just want to recreate device nodes they removed from /dev. There is no reason to pass the additional "c 0 0" anymore. Also slightly improve the manpage. Remove references to non-existent device names and platforms. Modified: head/sbin/mknod/mknod.8 head/sbin/mknod/mknod.c Modified: head/sbin/mknod/mknod.8 ============================================================================== --- head/sbin/mknod/mknod.8 Sun Jan 31 11:36:04 2010 (r203276) +++ head/sbin/mknod/mknod.8 Sun Jan 31 11:48:25 2010 (r203277) @@ -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 Modified: head/sbin/mknod/mknod.c ============================================================================== --- head/sbin/mknod/mknod.c Sun Jan 31 11:36:04 2010 (r203276) +++ head/sbin/mknod/mknod.c Sun Jan 31 11:48:25 2010 (r203277) @@ -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) {