xref: /minix/lib/libc/sys/mknod.2 (revision 84d9c625)
1.\"	$NetBSD: mknod.2,v 1.28 2013/10/15 11:43:21 njoly Exp $
2.\"
3.\" Copyright (c) 1980, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)mknod.2	8.1 (Berkeley) 6/4/93
31.\"
32.Dd July 29, 2013
33.Dt MKNOD 2
34.Os
35.Sh NAME
36.Nm mknod ,
37.Nm mknodat
38.Nd make a special file node
39.Sh LIBRARY
40.Lb libc
41.Sh SYNOPSIS
42.In sys/stat.h
43.Ft int
44.Fn mknod "const char *path" "mode_t mode" "dev_t dev"
45.In sys/stat.h
46.In fcntl.h
47.Ft int
48.Fn mknodat "int fd" "const char *path" "mode_t mode" "dev_t dev"
49.Sh DESCRIPTION
50The device special file
51.Fa path
52is created with the major and minor
53device numbers specified by
54.Fa dev .
55The access permissions of
56.Fa path
57are extracted from
58.Fa mode ,
59modified by the
60.Xr umask 2
61of the parent process.
62.Pp
63.Fn mknodat
64works the same way as
65.Fn mknod
66except if
67.Fa path
68is relative.
69In that case, it is looked up from a directory whose file
70descriptor was passed as
71.Fa fd .
72Search permission is required on this directory.
73.\"    (These alternatives await a decision about the semantics of O_SEARCH)
74.\" Search permission is required on this directory
75.\" except if
76.\" .Fa fd
77.\" was opened with the
78.\" .Dv O_SEARCH
79.\" flag.
80.\"    - or -
81.\" This file descriptor must have been opened with the
82.\" .Dv O_SEARCH
83.\" flag.
84.Fa fd
85can be set to
86.Dv AT_FDCWD
87in order to specify the current directory.
88.Pp
89.Fn mknod
90requires super-user privileges.
91.Sh RETURN VALUES
92.Rv -std mknod mknodat
93.Sh ERRORS
94.Fn mknod
95and
96.Fn mknodat
97will fail and the file will be not created if:
98.Bl -tag -width Er
99.It Bq Er EACCES
100Search permission is denied for a component of the path prefix.
101.It Bq Er EDQUOT
102The directory in which the entry for the new node
103is being placed cannot be extended because the
104user's quota of disk blocks on the file system
105containing the directory has been exhausted; or
106the user's quota of inodes on the file system on
107which the node is being created has been exhausted.
108.It Bq Er EEXIST
109The named file exists.
110.It Bq Er EFAULT
111.Fa path
112points outside the process's allocated address space.
113.It Bq Er EINVAL
114The supplied
115.Fa mode
116or
117.Fa dev
118is invalid.
119.It Bq Er EIO
120An I/O error occurred while making the directory entry or allocating the inode.
121.It Bq Er ELOOP
122Too many symbolic links were encountered in translating the pathname.
123.It Bq Er ENAMETOOLONG
124A component of a pathname exceeded
125.Brq Dv NAME_MAX
126characters, or an entire path name exceeded
127.Brq Dv PATH_MAX
128characters.
129.It Bq Er ENOENT
130A component of the path prefix does not exist.
131.It Bq Er ENOSPC
132The directory in which the entry for the new node is being placed
133cannot be extended because there is no space left on the file
134system containing the directory; or
135there are no free inodes on the file system on which the
136node is being created.
137.It Bq Er ENOTDIR
138A component of the path prefix is not a directory.
139.It Bq Er EPERM
140The process's effective user ID is not super-user.
141.It Bq Er EROFS
142The named file resides on a read-only file system.
143.El
144.Pp
145In addition,
146.Fn mknodat
147will fail if:
148.Bl -tag -width Er
149.It Bq Er EBADF
150.Fa path
151does not specify an absolute path and
152.Fa fd
153is neither
154.Dv AT_FDCWD
155nor a valid file descriptor open for reading or searching.
156.It Bq Er ENOTDIR
157.Fa path
158is not an absolute path and
159.Fa fd
160is a file descriptor associated with a non-directory file.
161.El
162.Sh SEE ALSO
163.Xr chmod 2 ,
164.Xr mkfifo 2 ,
165.Xr stat 2 ,
166.Xr umask 2
167.Sh STANDARDS
168The
169.Fn mknod
170function conforms to
171.St -p1003.1-90 .
172.Fn mknodat
173conforms to
174.St -p1003.1-2008 .
175.Sh HISTORY
176A
177.Fn mknod
178function call appeared in
179.At v6 .
180