'\" te .\" Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. .\" Copyright 1989 AT&T. .\" 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. .TH mknod 2 "6 Jul 2010" "SunOS 5.11" "System Calls" .SH NAME mknod, mknodat \- 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 .LP .nf int mknodat(int \fIfd\fR, const char *\fIpath\fR, mode_t \fImode\fR, dev_t \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. .sp .LP Upon successful completion, \fBmknod()\fR marks for update the last data access, last data modification, and last file status change timestamps of the file. Also, the last data modification and last file status change timestamps of the directory that contains the new entry is marked for update. .sp .LP Only a process with appropriate privileges may invoke \fBmknod()\fR for file types other than FIFO-special. .sp .LP The \fBmknodat()\fR function is equivalent to the \fBmknod()\fR function except in the case where \fIpath\fR specifies a relative path. In this case the newly created directory, special file, or regular file is located relative to the directory associated with the file descriptor \fIfd\fR instead of the current working directory. If the file descriptor was opened without \fBO_SEARCH\fR, the function checks whether directory searches are permitted using the current permissions of the directory underlying the file descriptor. If the file descriptor was opened with \fBO_SEARCH\fR, the function does not perform the check. .sp .LP If \fBmknodat()\fR is passed the special value \fBAT_FDCWD\fR in the \fIfd\fR parameter, the current working directory is used and the behavior is identical to a call to \fBmknod()\fR. .SH RETURN VALUES .sp .LP Upon successful completion, \fBmknod()\fR and \fBmknodat()\fR return \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 and \fBmknodat()\fR functions 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 \fBmknodat()\fR function will fail if: .sp .ne 2 .mk .na \fB\fBEACCES\fR\fR .ad .RS 10n .rt \fIfd\fR was not opened with \fBO_SEARCH\fR and the permissions of the directory underlying \fIfd\fR do not permit directory searches. .RE .sp .ne 2 .mk .na \fB\fBEBADF\fR\fR .ad .RS 10n .rt The \fIpath\fR argument does not specify an absolute path and the \fIfd\fR argument is neither \fBAT_FDCWD\fR nor a valid file descriptor open for reading or searching. .RE .sp .LP The \fBmknod()\fR and \fBmknodat()\fR functions may fail if: .sp .ne 2 .mk .na \fB\fBELOOP\fR\fR .ad .RS 16n .rt More than {\fBSYMLOOP_MAX\fR} symbolic links were encountered during resolution of the \fIpath\fR argument. .RE .sp .ne 2 .mk .na \fB\fBENAMETOOLONG\fR\fR .ad .RS 16n .rt The length of a pathname exceeds {\fBPATH_MAX\fR}, or pathname resolution of a symbolic link produced an intermediate result with a length that exceeds {\fBPATH_MAX\fR}. .RE .sp .LP The \fBmknodat()\fR function may fail if: .sp .ne 2 .mk .na \fB\fBENOTDIR\fR\fR .ad .RS 11n .rt The \fIpath\fR argument is not an absolute path and \fIfd\fR is neither \fBAT_FDCWD\fR nor a file descriptor associated with a directory. .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 StabilityCommitted _ MT-LevelAsync-Signal-Safe _ StandardSee \fBstandards\fR(5). .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)