xref: /netbsd-src/lib/libc/sys/mknod.2 (revision b757af438b42b93f8c6571f026d8b8ef3eaf5fc9)
1.\"	$NetBSD: mknod.2,v 1.22 2011/07/08 19:25:51 wiz 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 3, 2011
33.Dt MKNOD 2
34.Os
35.Sh NAME
36.Nm mknod
37.Nd make a special file node
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In sys/stat.h
42.Ft int
43.Fn mknod "const char *path" "mode_t mode" "dev_t dev"
44.Sh DESCRIPTION
45The device special file
46.Fa path
47is created with the major and minor
48device numbers specified by
49.Fa dev .
50The access permissions of
51.Fa path
52are extracted from
53.Fa mode ,
54modified by the
55.Xr umask 2
56of the parent process.
57.Pp
58.Fn mknod
59requires super-user privileges.
60.Sh RETURN VALUES
61Upon successful completion a value of 0 is returned.
62Otherwise, a value of \-1 is returned and
63.Va errno
64is set to indicate the error.
65.Sh ERRORS
66.Fn mknod
67will fail and the file will be not created if:
68.Bl -tag -width Er
69.It Bq Er EACCES
70Search permission is denied for a component of the path prefix.
71.It Bq Er EDQUOT
72The directory in which the entry for the new node
73is being placed cannot be extended because the
74user's quota of disk blocks on the file system
75containing the directory has been exhausted; or
76the user's quota of inodes on the file system on
77which the node is being created has been exhausted.
78.It Bq Er EEXIST
79The named file exists.
80.It Bq Er EFAULT
81.Fa path
82points outside the process's allocated address space.
83.It Bq Er EINVAL
84The supplied
85.Fa mode
86or
87.Fa dev
88is invalid.
89.It Bq Er EIO
90An I/O error occurred while making the directory entry or allocating the inode.
91.It Bq Er ELOOP
92Too many symbolic links were encountered in translating the pathname.
93.It Bq Er ENAMETOOLONG
94A component of a pathname exceeded
95.Brq Dv NAME_MAX
96characters, or an entire path name exceeded
97.Brq Dv PATH_MAX
98characters.
99.It Bq Er ENOENT
100A component of the path prefix does not exist.
101.It Bq Er ENOSPC
102The directory in which the entry for the new node is being placed
103cannot be extended because there is no space left on the file
104system containing the directory; or
105there are no free inodes on the file system on which the
106node is being created.
107.It Bq Er ENOTDIR
108A component of the path prefix is not a directory.
109.It Bq Er EPERM
110The process's effective user ID is not super-user.
111.It Bq Er EROFS
112The named file resides on a read-only file system.
113.El
114.Sh SEE ALSO
115.Xr chmod 2 ,
116.Xr mkfifo 2 ,
117.Xr stat 2 ,
118.Xr umask 2
119.Sh HISTORY
120A
121.Fn mknod
122function call appeared in
123.At v6 .
124