[9] | 1 | .\" Copyright (c) 1980 Regents of the University of California.
|
---|
| 2 | .\" All rights reserved. The Berkeley software License Agreement
|
---|
| 3 | .\" specifies the terms and conditions for redistribution.
|
---|
| 4 | .\"
|
---|
| 5 | .\" @(#)mknod.2 6.4 (Berkeley) 5/23/86
|
---|
| 6 | .\"
|
---|
| 7 | .TH MKNOD 2 "May 23, 1986"
|
---|
| 8 | .UC 4
|
---|
| 9 | .SH NAME
|
---|
| 10 | mknod, mkfifo \- make a special file
|
---|
| 11 | .SH SYNOPSIS
|
---|
| 12 | .nf
|
---|
| 13 | .ft B
|
---|
| 14 | #include <sys/types.h>
|
---|
| 15 | #include <unistd.h>
|
---|
| 16 | #include <sys/stat.h>
|
---|
| 17 |
|
---|
| 18 | int mknod(const char *\fIpath\fP, mode_t \fImode\fP, dev_t \fIdev\fP)
|
---|
| 19 | int mkfifo(const char *\fIpath\fP, mode_t \fImode\fP)
|
---|
| 20 | .fi
|
---|
| 21 | .ft R
|
---|
| 22 | .SH DESCRIPTION
|
---|
| 23 | .B Mknod
|
---|
| 24 | creates a new file
|
---|
| 25 | whose name is
|
---|
| 26 | .I path.
|
---|
| 27 | The mode of the new file
|
---|
| 28 | (including special file bits)
|
---|
| 29 | is initialized from
|
---|
| 30 | .IR mode ,
|
---|
| 31 | as defined in
|
---|
| 32 | .IR <sys/stat.h> .
|
---|
| 33 | (The protection part of the mode
|
---|
| 34 | is modified by the process's mode mask (see
|
---|
| 35 | .BR umask (2))).
|
---|
| 36 | The first block pointer of the i-node
|
---|
| 37 | is initialized from
|
---|
| 38 | .I dev
|
---|
| 39 | and is used to specify which device the special file
|
---|
| 40 | refers to.
|
---|
| 41 | .PP
|
---|
| 42 | If mode indicates a block or character special file,
|
---|
| 43 | .I dev
|
---|
| 44 | is the device number of a character or block I/O device.
|
---|
| 45 | The low eight bits of the device number hold the minor device number
|
---|
| 46 | that selects a device among the devices governed by the same driver.
|
---|
| 47 | The driver is selected by the major device number, the next eight bits
|
---|
| 48 | of the device number.
|
---|
| 49 | .PP
|
---|
| 50 | If
|
---|
| 51 | .I mode
|
---|
| 52 | does not indicate a block special or character special device,
|
---|
| 53 | .I dev
|
---|
| 54 | is ignored.
|
---|
| 55 | (For example, when creating a ``fifo'' special file.)
|
---|
| 56 | .PP
|
---|
| 57 | .B Mknod
|
---|
| 58 | may be invoked only by the super-user,
|
---|
| 59 | unless it is being used to create a fifo.
|
---|
| 60 | .PP
|
---|
| 61 | The call
|
---|
| 62 | .BI "mkfifo(" path ", " mode ")"
|
---|
| 63 | is equivalent to
|
---|
| 64 | .PP
|
---|
| 65 | .RS
|
---|
| 66 | .BI "mknod(" path ", (" mode " & 0777) | S_IFIFO, 0)"
|
---|
| 67 | .RE
|
---|
| 68 | .SH "RETURN VALUE
|
---|
| 69 | Upon successful completion a value of 0 is returned.
|
---|
| 70 | Otherwise, a value of \-1 is returned and \fBerrno\fP
|
---|
| 71 | is set to indicate the error.
|
---|
| 72 | .SH ERRORS
|
---|
| 73 | .B Mknod
|
---|
| 74 | will fail and the file mode will be unchanged if:
|
---|
| 75 | .TP 15
|
---|
| 76 | [ENOTDIR]
|
---|
| 77 | A component of the path prefix is not a directory.
|
---|
| 78 | .TP 15
|
---|
| 79 | [ENAMETOOLONG]
|
---|
| 80 | The path name exceeds PATH_MAX characters.
|
---|
| 81 | .TP 15
|
---|
| 82 | [ENOENT]
|
---|
| 83 | A component of the path prefix does not exist.
|
---|
| 84 | .TP 15
|
---|
| 85 | [EACCES]
|
---|
| 86 | Search permission is denied for a component of the path prefix.
|
---|
| 87 | .TP 15
|
---|
| 88 | [ELOOP]
|
---|
| 89 | Too many symbolic links were encountered in translating the pathname.
|
---|
| 90 | (Minix-vmd)
|
---|
| 91 | .TP 15
|
---|
| 92 | [EPERM]
|
---|
| 93 | The process's effective user ID is not super-user.
|
---|
| 94 | .TP 15
|
---|
| 95 | [EIO]
|
---|
| 96 | An I/O error occurred while making the directory entry or allocating the inode.
|
---|
| 97 | .TP 15
|
---|
| 98 | [ENOSPC]
|
---|
| 99 | The directory in which the entry for the new node is being placed
|
---|
| 100 | cannot be extended because there is no space left on the file
|
---|
| 101 | system containing the directory.
|
---|
| 102 | .TP 15
|
---|
| 103 | [ENOSPC]
|
---|
| 104 | There are no free inodes on the file system on which the
|
---|
| 105 | node is being created.
|
---|
| 106 | .ig
|
---|
| 107 | .TP 15
|
---|
| 108 | [EDQUOT]
|
---|
| 109 | The directory in which the entry for the new node
|
---|
| 110 | is being placed cannot be extended because the
|
---|
| 111 | user's quota of disk blocks on the file system
|
---|
| 112 | containing the directory has been exhausted.
|
---|
| 113 | .TP 15
|
---|
| 114 | [EDQUOT]
|
---|
| 115 | The user's quota of inodes on the file system on
|
---|
| 116 | which the node is being created has been exhausted.
|
---|
| 117 | ..
|
---|
| 118 | .TP 15
|
---|
| 119 | [EROFS]
|
---|
| 120 | The named file resides on a read-only file system.
|
---|
| 121 | .TP 15
|
---|
| 122 | [EEXIST]
|
---|
| 123 | The named file exists.
|
---|
| 124 | .TP 15
|
---|
| 125 | [EFAULT]
|
---|
| 126 | .I Path
|
---|
| 127 | points outside the process's allocated address space.
|
---|
| 128 | .SH "SEE ALSO"
|
---|
| 129 | .BR chmod (2),
|
---|
| 130 | .BR stat (2),
|
---|
| 131 | .BR umask (2).
|
---|