'\" te .\" Copyright 1989 AT&T. Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved. Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. .\" 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 .\" http://www.opengroup.org/bookstore/. .\" 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. .\" This notice shall appear on any product containing this material. .\" 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. .\" 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. .\" 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] .TH mknod 2 "19 Feb 2004" "SunOS 5.11" "System Calls" .SH NAME mknod \- make a directory, a special file, or a regular file .SH SYNOPSIS .LP .nf #include \fBint\fR \fBmknod\fR(\fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR, \fBdev_t\fR \fIdev\fR); .fi .SH DESCRIPTION .sp .LP The \fBmknod()\fR function creates a new file named by the path name pointed to by \fIpath\fR. The file type and permissions of the new file are initialized from \fImode\fR. .sp .LP The file type is specified in \fImode\fR by the \fBS_IFMT\fR bits, which must be set to one of the following values: .sp .ne 2 .mk .na \fB\fBS_IFIFO\fR\fR .ad .RS 11n .rt fifo special .RE .sp .ne 2 .mk .na \fB\fBS_IFCHR\fR\fR .ad .RS 11n .rt character special .RE .sp .ne 2 .mk .na \fB\fBS_IFDIR\fR\fR .ad .RS 11n .rt directory .RE .sp .ne 2 .mk .na \fB\fBS_IFBLK\fR\fR .ad .RS 11n .rt block special .RE .sp .ne 2 .mk .na \fB\fBS_IFREG\fR\fR .ad .RS 11n .rt ordinary file .RE .sp .LP The file access permissions are specified in \fImode\fR by the 0007777 bits, and may be constructed by a bitwise \fBOR\fR operation of the following values: .sp .sp .TS tab(); lw(1.08i) lw(.89i) lw(3.53i) lw(1.08i) lw(.89i) lw(3.53i) . \fBS_ISUID\fR04000Set user ID on execution. \fBS_ISGID\fR020#0T{ 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 T} \fBS_ISVTX\fR01000T{ On directories, restricted deletion flag; on regular files on a UFS file system, do not cache flag. T} \fBS_IRWXU\fR00700Read, write, execute by owner. \fBS_IRUSR\fR00400Read by owner. \fBS_IWUSR\fR00200Write by owner. \fBS_IXUSR\fR00100T{ Execute (search if a directory) by owner. T} \fBS_IRWXG\fR00070Read, write, execute by group. \fBS_IRGRP\fR00040Read by group. \fBS_IWGRP\fR00020Write by group. \fBS_IXGRP\fR00010Execute by group. \fBS_IRWXO\fR00007Read, write, execute (search) by others. \fBS_IROTH\fR00004Read by others. \fBS_IWOTH\fR00002Write by others \fBS_IXOTH\fR00001Execute by others. .TE .sp .LP The owner \fBID\fR of the file is set to the effective user \fBID\fR of the process. The group \fBID\fR of the file is set to the effective group \fBID\fR of the process. However, if the \fBS_ISGID\fR bit is set in the parent directory, then the group \fBID\fR of the file is inherited from the parent. If the group \fBID\fR of the new file does not match the effective group \fBID\fR or one of the supplementary group IDs, the \fBS_ISGID\fR bit is cleared. .sp .LP The access permission bits of \fImode\fR are modified by the process's file mode creation mask: all bits set in the process's file mode creation mask are cleared (see \fBumask\fR(2)). If \fImode\fR indicates a block or character special file, \fIdev\fR is a configuration-dependent specification of a character or block I/O device. If \fImode\fR does not indicate a block special or character special device, \fIdev\fR is ignored. See \fBmakedev\fR(3C). .sp .LP If \fIpath\fR is a symbolic link, it is not followed. .SH RETURN VALUES .sp .LP Upon successful completion, \fBmknod()\fR returns \fB0\fR. Otherwise, it returns \fB\(mi1\fR, the new file is not created, and \fBerrno\fR is set to indicate the error. .SH ERRORS .sp .LP The \fBmknod()\fR function will fail if: .sp .ne 2 .mk .na \fB\fBEACCES\fR\fR .ad .RS 16n .rt A component of the path prefix denies search permission, or write permission is denied on the parent directory. .RE .sp .ne 2 .mk .na \fB\fBEDQUOT\fR\fR .ad .RS 16n .rt The directory where the new file entry is being placed cannot be extended because the user's quota of disk blocks on that file system has been exhausted, or the user's quota of inodes on the file system where the file is being created has been exhausted. .RE .sp .ne 2 .mk .na \fB\fBEEXIST\fR\fR .ad .RS 16n .rt The named file exists. .RE .sp .ne 2 .mk .na \fB\fBEFAULT\fR\fR .ad .RS 16n .rt The \fIpath\fR argument points to an illegal address. .RE .sp .ne 2 .mk .na \fB\fBEINTR\fR\fR .ad .RS 16n .rt A signal was caught during the execution of the \fBmknod()\fR function. .RE .sp .ne 2 .mk .na \fB\fBEINVAL\fR\fR .ad .RS 16n .rt An invalid argument exists. .RE .sp .ne 2 .mk .na \fB\fBEIO\fR\fR .ad .RS 16n .rt An I/O error occurred while accessing the file system. .RE .sp .ne 2 .mk .na \fB\fBELOOP\fR\fR .ad .RS 16n .rt Too many symbolic links were encountered in translating \fIpath\fR. .RE .sp .ne 2 .mk .na \fB\fBENAMETOOLONG\fR\fR .ad .RS 16n .rt The length of the \fIpath\fR argument exceeds {\fB\fR\fBPATH_MAX\fR}, or the length of a \fIpath\fR component exceeds {\fB\fR\fBNAME_MAX\fR} while \fB\fR\fB_POSIX_NO_TRUNC\fR is in effect. .RE .sp .ne 2 .mk .na \fB\fBENOENT\fR\fR .ad .RS 16n .rt A component of the path prefix specified by \fIpath\fR does not name an existing directory or \fIpath\fR is an empty string. .RE .sp .ne 2 .mk .na \fB\fBENOLINK\fR\fR .ad .RS 16n .rt The \fIpath\fR argument points to a remote machine and the link to that machine is no longer active. .RE .sp .ne 2 .mk .na \fB\fBENOSPC\fR\fR .ad .RS 16n .rt The directory that would contain the new file cannot be extended or the file system is out of file allocation resources. .RE .sp .ne 2 .mk .na \fB\fBENOTDIR\fR\fR .ad .RS 16n .rt A component of the path prefix is not a directory. .RE .sp .ne 2 .mk .na \fB\fBEPERM\fR\fR .ad .RS 16n .rt Not all privileges are asserted in the effective set of the calling process. .RE .sp .ne 2 .mk .na \fB\fBEROFS\fR\fR .ad .RS 16n .rt The directory in which the file is to be created is located on a read-only file system. .RE .sp .LP The \fBmknod()\fR function may fail if: .sp .ne 2 .mk .na \fB\fBENAMETOOLONG\fR\fR .ad .RS 16n .rt Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {\fBPATH_MAX\fR}. .RE .SH USAGE .sp .LP Applications should use the \fBmkdir\fR(2) function to create a directory because appropriate permissions are not required and because \fBmknod()\fR might not establish directory entries for the directory itself (\fB\&.\fR) and the parent directory (\fB\&.\|.\fR). The \fBmknod()\fR function can be invoked only by a privileged user for file types other than FIFO special. The \fBmkfifo\fR(3C) function should be used to create FIFOs. .sp .LP Doors are created using \fBdoor_create\fR(3C) and can be attached to the file system using \fBfattach\fR(3C). Symbolic links can be created using \fBsymlink\fR(2). An endpoint for communication can be created using \fBsocket\fR(3SOCKET). .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityStandard _ MT-LevelAsync-Signal-Safe .TE .SH SEE ALSO .sp .LP \fBchmod\fR(2), \fBcreat\fR(2), \fBexec\fR(2), \fBmkdir\fR(2), \fBopen\fR(2), \fBstat\fR(2), \fBsymlink\fR(2), \fBumask\fR(2), \fBdoor_create\fR(3C), \fBfattach\fR(3C), \fBmakedev\fR(3C), \fBmkfifo\fR(3C), \fBsocket\fR(3SOCKET), \fBstat.h\fR(3HEAD), \fBattributes\fR(5), \fBprivileges\fR(5), \fBstandards\fR(5)