2 .\" Copright (c) 2014, Joyent, Inc.
3 .\" Copyright 1989 AT&T. Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved. Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
7 .\" This notice shall appear on any product containing this material.
8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
11 .TH MKNOD 2 "Feb 19, 2004"
13 mknod, mknodat \- make a directory, a special file, or a regular file
19 \fBint\fR \fBmknod\fR(\fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR, \fBdev_t\fR \fIdev\fR);
23 \fBint\fR \fBmknodat(\fBint\fR \fIfd\fR, \fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR, \fBdev_t\fR \fIdev\fR);
28 The \fBmknod()\fR and \fBmknodat()\fR function creates a new file named by the
29 path name pointed to by \fIpath\fR. The file type and permissions of the new
30 file are initialized from \fImode\fR.
33 The file type is specified in \fImode\fR by the \fBS_IFMT\fR bits, which must
34 be set to one of the following values:
82 The file access permissions are specified in \fImode\fR by the 0007777 bits,
83 and may be constructed by a bitwise \fBOR\fR operation of the following values:
90 \fBS_ISUID\fR 04000 Set user ID on execution.
91 \fBS_ISGID\fR 020#0 T{
92 Set group ID on execution if # is \fB7\fR, \fB5\fR, \fB3\fR, or \fB1\fR. Enable mandatory file/record locking if # is \fB6\fR, \fB4\fR, \fB2\fR, or \fB0\fR
94 \fBS_ISVTX\fR 01000 T{
95 On directories, restricted deletion flag; on regular files on a UFS file system, do not cache flag.
97 \fBS_IRWXU\fR 00700 Read, write, execute by owner.
98 \fBS_IRUSR\fR 00400 Read by owner.
99 \fBS_IWUSR\fR 00200 Write by owner.
100 \fBS_IXUSR\fR 00100 T{
101 Execute (search if a directory) by owner.
103 \fBS_IRWXG\fR 00070 Read, write, execute by group.
104 \fBS_IRGRP\fR 00040 Read by group.
105 \fBS_IWGRP\fR 00020 Write by group.
106 \fBS_IXGRP\fR 00010 Execute by group.
107 \fBS_IRWXO\fR 00007 Read, write, execute (search) by others.
108 \fBS_IROTH\fR 00004 Read by others.
109 \fBS_IWOTH\fR 00002 Write by others
110 \fBS_IXOTH\fR 00001 Execute by others.
115 The owner \fBID\fR of the file is set to the effective user \fBID\fR of the
116 process. The group \fBID\fR of the file is set to the effective group \fBID\fR
117 of the process. However, if the \fBS_ISGID\fR bit is set in the parent
118 directory, then the group \fBID\fR of the file is inherited from the parent.
119 If the group \fBID\fR of the new file does not match the effective group
120 \fBID\fR or one of the supplementary group IDs, the \fBS_ISGID\fR bit is
124 The access permission bits of \fImode\fR are modified by the process's file
125 mode creation mask: all bits set in the process's file mode creation mask are
126 cleared (see \fBumask\fR(2)). If \fImode\fR indicates a block or character
127 special file, \fIdev\fR is a configuration-dependent specification of a
128 character or block I/O device. If \fImode\fR does not indicate a block special
129 or character special device, \fIdev\fR is ignored. See \fBmakedev\fR(3C).
132 If \fIpath\fR is a symbolic link, it is not followed.
135 The \fBmknodat()\fR function is similar to \fBmknod()\fR; however, when
136 \fIpath\fR is a relative path, it is resolved starting at the directory
137 represented by the file descriptor \fIfd\fR. To start at the current working
138 directory, \fIfd\fR may be set to the special value \fBAT_FDCWD\fR.
141 Upon successful completion, \fBmknod()\fR and \fBmknodat()\fR return \fB0\fR.
142 Otherwise, they return \fB\(mi1\fR, the new file is not created, and \fBerrno\fR
143 is set to indicate the error.
146 The \fBmknod()\fR and \fBmknodat()\fR functions will fail if:
153 A component of the path prefix denies search permission, or write permission is
154 denied on the parent directory.
163 The directory where the new file entry is being placed cannot be extended
164 because the user's quota of disk blocks on that file system has been exhausted,
165 or the user's quota of inodes on the file system where the file is being
166 created has been exhausted.
175 The named file exists.
184 The \fIpath\fR argument points to an illegal address.
193 A signal was caught during the execution of the \fBmknod()\fR function.
202 An invalid argument exists.
211 An I/O error occurred while accessing the file system.
220 Too many symbolic links were encountered in translating \fIpath\fR.
226 \fB\fBENAMETOOLONG\fR\fR
229 The length of the \fIpath\fR argument exceeds {\fB\fR\fBPATH_MAX\fR}, or the
230 length of a \fIpath\fR component exceeds {\fB\fR\fBNAME_MAX\fR} while
231 \fB\fR\fB_POSIX_NO_TRUNC\fR is in effect.
240 A component of the path prefix specified by \fIpath\fR does not name an
241 existing directory or \fIpath\fR is an empty string.
250 The \fIpath\fR argument points to a remote machine and the link to that machine
260 The directory that would contain the new file cannot be extended or the file
261 system is out of file allocation resources.
270 A component of the path prefix is not a directory. In addition, when calling
271 \fBmknodat()\fR, if \fIpath\fR is a relative path and \fIfd\fR is a valid file
272 descriptor which does not refer to a directory.
281 Not all privileges are asserted in the effective set of the calling process.
290 The directory in which the file is to be created is located on a read-only file
296 The \fBmknodat()\fR function will fail if:
303 The \fIpath\fR argument is a relative path and \fIfd\fR is not a valid open file
304 descriptor or the special value \fBAT_FDCWD\fR.
309 The \fBmknod()\fR function may fail if:
313 \fB\fBENAMETOOLONG\fR\fR
316 Pathname resolution of a symbolic link produced an intermediate result whose
317 length exceeds {\fBPATH_MAX\fR}.
322 Applications should use the \fBmkdir\fR(2) function to create a directory
323 because appropriate permissions are not required and because \fBmknod()\fR
324 might not establish directory entries for the directory itself (\fB\&.\fR) and
325 the parent directory (\fB\&.\|.\fR). The \fBmknod()\fR function can be invoked
326 only by a privileged user for file types other than FIFO special. The
327 \fBmkfifo\fR(3C) function should be used to create FIFOs.
330 Doors are created using \fBdoor_create\fR(3C) and can be attached to the file
331 system using \fBfattach\fR(3C). Symbolic links can be created using
332 \fBsymlink\fR(2). An endpoint for communication can be created using
333 \fBsocket\fR(3SOCKET).
336 See \fBattributes\fR(5) for descriptions of the following attributes:
344 ATTRIBUTE TYPE ATTRIBUTE VALUE
346 Interface Stability Standard
348 MT-Level Async-Signal-Safe
353 \fBchmod\fR(2), \fBcreat\fR(2), \fBexec\fR(2), \fBmkdir\fR(2), \fBopen\fR(2),
354 \fBstat\fR(2), \fBsymlink\fR(2), \fBumask\fR(2), \fBdoor_create\fR(3C),
355 \fBfattach\fR(3C), \fBmakedev\fR(3C), \fBmkfifo\fR(3C), \fBsocket\fR(3SOCKET),
356 \fBstat.h\fR(3HEAD), \fBattributes\fR(5), \fBprivileges\fR(5),