xref: /openbsd-src/lib/libc/sys/mknod.2 (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1.\"	$OpenBSD: mknod.2,v 1.12 2007/05/31 19:19:33 jmc Exp $
2.\"	$NetBSD: mknod.2,v 1.6 1995/02/27 12:34:33 cgd 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.2	8.1 (Berkeley) 6/4/93
32.\"
33.Dd $Mdocdate: May 31 2007 $
34.Dt MKNOD 2
35.Os
36.Sh NAME
37.Nm mknod
38.Nd make a special file node
39.Sh SYNOPSIS
40.Fd #include <sys/stat.h>
41.Ft int
42.Fn mknod "const char *path" "mode_t mode" "dev_t dev"
43.Sh DESCRIPTION
44The device special file
45.Fa path
46is created with the major and minor
47device numbers extracted from
48.Fa mode .
49The access permissions of
50.Fa path
51are descendant from the
52.Xr umask 2
53of the parent process.
54.Pp
55If
56.Fa mode
57indicates a block or character special file,
58.Fa dev
59is a configuration dependent specification of a character or block
60I/O device and the superblock of the device.
61If
62.Fa mode
63does not indicate a block special or character special device,
64.Fa dev
65is ignored.
66.Pp
67.Fn mknod
68requires superuser privileges.
69.Sh RETURN VALUES
70Upon successful completion a value of 0 is returned.
71Otherwise, a value of \-1 is returned and
72.Va errno
73is set to indicate the error.
74.Sh ERRORS
75.Fn mknod
76will fail and the file will be not created if:
77.Bl -tag -width Er
78.It Bq Er ENOTDIR
79A component of the path prefix is not a directory.
80.It Bq Er ENAMETOOLONG
81A component of a pathname exceeded
82.Dv {NAME_MAX}
83characters, or an entire path name exceeded
84.Dv {PATH_MAX}
85characters.
86.It Bq Er ENOENT
87A component of the path prefix does not exist.
88.It Bq Er EACCES
89Search permission is denied for a component of the path prefix.
90.It Bq Er ELOOP
91Too many symbolic links were encountered in translating the pathname.
92.It Bq Er EPERM
93The process's effective user ID is not superuser.
94.It Bq Er EIO
95An I/O error occurred while making the directory entry or allocating the inode.
96.It Bq Er ENOSPC
97The directory in which the entry for the new node is being placed
98cannot be extended because there is no space left on the file
99system containing the directory.
100.It Bq Er ENOSPC
101There are no free inodes on the file system on which the
102node is being created.
103.It Bq Er EDQUOT
104The directory in which the entry for the new node
105is being placed cannot be extended because the
106user's quota of disk blocks on the file system
107containing the directory has been exhausted.
108.It Bq Er EDQUOT
109The user's quota of inodes on the file system on
110which the node is being created has been exhausted.
111.It Bq Er EROFS
112The named file resides on a read-only file system.
113.It Bq Er EEXIST
114The named file exists.
115.It Bq Er EFAULT
116.Fa path
117points outside the process's allocated address space.
118.It Bq Er EINVAL
119The process is running within an alternate root directory, as
120created by
121.Xr chroot 2 .
122.El
123.Sh SEE ALSO
124.Xr chmod 2 ,
125.Xr chroot 2 ,
126.Xr stat 2 ,
127.Xr umask 2
128.Sh HISTORY
129A
130.Fn mknod
131function call appeared in
132.At v6 .
133