xref: /openbsd/sbin/mknod/mknod.8 (revision 404b540a)
1.\"	$OpenBSD: mknod.8,v 1.17 2009/03/21 18:07:41 sobrado Exp $
2.\"	$NetBSD: mknod.8,v 1.9 1995/08/10 23:47:32 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)mknod.8	8.2 (Berkeley) 12/11/93
32.\"
33.Dd $Mdocdate: March 21 2009 $
34.Dt MKNOD 8
35.Os
36.Sh NAME
37.Nm mknod
38.Nd make device special files
39.Sh SYNOPSIS
40.Nm mknod
41.Op Fl m Ar mode
42.Ar name
43.Op Cm b \*(Ba c
44.Ar major minor
45.Nm mknod
46.Op Fl m Ar mode
47.Ar name
48.Cm p
49.Sh DESCRIPTION
50The
51.Nm
52command creates device special files.
53Normally the shell script
54.Pa /dev/MAKEDEV
55is used to create special files for commonly known devices; it executes
56.Nm
57with the appropriate arguments and can make all the files required for the
58device.
59.Pp
60The options are as follows:
61.Bl -tag -width Ds
62.It Fl m Ar mode
63Set the file permission bits of newly created device special files to
64.Ar mode .
65The mode argument can be in any of the formats specified to the
66.Xr chmod 1
67utility.
68If a symbolic mode is specified, the operators
69.Ql +
70and
71.Ql -
72are interpreted relative to an initial mode of
73.Dq a=rw .
74.El
75.Pp
76To make nodes manually, the arguments are:
77.Bl -tag -width majorx
78.It Ar name
79Device or FIFO name.
80For example
81.Dq sd
82for a SCSI disk or a
83.Dq pty
84for pseudo-devices.
85FIFOs may be named arbitrarily by the user.
86.It Cm b \*(Ba c \*(Ba p
87Type of device or FIFO.
88If the device is a block type device such as a tape or disk drive which needs
89both cooked and raw special files,
90the type is
91.Cm b .
92All other devices are character type devices, such as terminal
93and pseudo devices, and are type
94.Cm c .
95A FIFO (also known as a named pipe) is type
96.Cm p .
97.It Ar major
98The major device number is an integer number which tells the kernel
99which device driver entry point to use.
100To learn what major device number to use for a particular device,
101check the file
102.Pa /dev/MAKEDEV
103to see if the device is known.
104.It Ar minor
105The minor device number tells the kernel which subunit
106the node corresponds to on the device; for example,
107a subunit may be a filesystem partition
108or a tty line.
109.Pp
110Major and minor device numbers can be given in any format acceptable to
111.Xr strtoul 3 ,
112so that a leading
113.Dq 0x
114indicates a hexadecimal number, and a leading
115.Dq 0
116will cause the number to be interpreted as octal.
117.El
118.Sh SEE ALSO
119.Xr chmod 1 ,
120.Xr ksh 1 ,
121.Xr mkfifo 1 ,
122.Xr mkfifo 2 ,
123.Xr mknod 2 ,
124.Xr MAKEDEV 8
125.Sh STANDARDS
126.Nm
127also exists as a built-in to
128.Xr ksh 1 .
129.Sh HISTORY
130A
131.Nm
132command appeared in
133.At v6 .
134