xref: /original-bsd/lib/libc/sys/mknod.2 (revision 51dd4909)
1.\" Copyright (c) 1980, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)mknod.2	6.5 (Berkeley) 03/10/91
7.\"
8.Dd
9.Dt MKNOD 2
10.Os BSD 4
11.Sh NAME
12.Nm mknod
13.Nd make a special file node
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn mknod "const char *path" "mode_t mode" "dev_t dev"
18.Sh DESCRIPTION
19The device special file
20.Fa path
21is created with the major and minor
22device numbers extracted from
23.Fa mode.
24The access permissions of
25.Fa path
26are descendant from the
27.Xr umask 2
28of the parent process.
29.Pp
30If
31.Fa mode
32indicates a block or character special file,
33.Fa dev
34is a configuration dependent specification of a character or block
35I/O device and the superblock of the device.  If
36.Fa mode
37does not indicate a block special or character special device,
38.Fa dev
39is ignored.
40.Pp
41.Fn Mknod
42requires super-user privileges.
43.Sh RETURN VALUES
44Upon successful completion a value of 0 is returned.
45Otherwise, a value of -1 is returned and
46.Va errno
47is set to indicate the error.
48.Sh ERRORS
49.Fn Mknod
50will fail and the file will be not created if:
51.Bl -tag -width Er
52.It Bq Er ENOTDIR
53A component of the path prefix is not a directory.
54.It Bq Er EINVAL
55The pathname contains a character with the high-order bit set.
56.It Bq Er ENAMETOOLONG
57A component of a pathname exceeded 255 characters,
58or an entire path name exceeded 1023 characters.
59.It Bq Er ENOENT
60A component of the path prefix does not exist.
61.It Bq Er EACCES
62Search permission is denied for a component of the path prefix.
63.It Bq Er ELOOP
64Too many symbolic links were encountered in translating the pathname.
65.It Bq Er EPERM
66The process's effective user ID is not super-user.
67.It Bq Er EPERM
68The pathname contains a character with the high-order bit set.
69.It Bq Er EIO
70An I/O error occurred while making the directory entry or allocating the inode.
71.It Bq Er ENOSPC
72The directory in which the entry for the new node is being placed
73cannot be extended because there is no space left on the file
74system containing the directory.
75.It Bq Er ENOSPC
76There are no free inodes on the file system on which the
77node is being created.
78.It Bq Er EDQUOT
79The directory in which the entry for the new node
80is being placed cannot be extended because the
81user's quota of disk blocks on the file system
82containing the directory has been exhausted.
83.It Bq Er EDQUOT
84The user's quota of inodes on the file system on
85which the node is being created has been exhausted.
86.It Bq Er EROFS
87The named file resides on a read-only file system.
88.It Bq Er EEXIST
89The named file exists.
90.It Bq Er EFAULT
91.Fa Path
92points outside the process's allocated address space.
93.El
94.Sh SEE ALSO
95.Xr chmod 2 ,
96.Xr stat 2 ,
97.Xr umask 2
98.Sh HISTORY
99A
100.Nm
101function call appeared in Version 6 AT&T UNIX.
102