1.\" $NetBSD: mknod.2,v 1.27 2013/07/30 13:45:38 njoly Exp $ 2.\" 3.\" Copyright (c) 1980, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)mknod.2 8.1 (Berkeley) 6/4/93 31.\" 32.Dd July 29, 2013 33.Dt MKNOD 2 34.Os 35.Sh NAME 36.Nm mknod , 37.Nm mknodat 38.Nd make a special file node 39.Sh LIBRARY 40.Lb libc 41.Sh SYNOPSIS 42.In sys/stat.h 43.Ft int 44.Fn mknod "const char *path" "mode_t mode" "dev_t dev" 45.Ft int 46.Fn mknodat "int fd" "const char *path" "mode_t mode" "dev_t dev" 47.Sh DESCRIPTION 48The device special file 49.Fa path 50is created with the major and minor 51device numbers specified by 52.Fa dev . 53The access permissions of 54.Fa path 55are extracted from 56.Fa mode , 57modified by the 58.Xr umask 2 59of the parent process. 60.Pp 61.Fn mknodat 62works the same way as 63.Fn mknod 64except if 65.Fa path 66is relative. 67In that case, it is looked up from a directory whose file 68descriptor was passed as 69.Fa fd . 70Search permission is required on this directory. 71.\" (These alternatives await a decision about the semantics of O_SEARCH) 72.\" Search permission is required on this directory 73.\" except if 74.\" .Fa fd 75.\" was opened with the 76.\" .Dv O_SEARCH 77.\" flag. 78.\" - or - 79.\" This file descriptor must have been opened with the 80.\" .Dv O_SEARCH 81.\" flag. 82.Fa fd 83can be set to 84.Dv AT_FDCWD 85in order to specify the current directory. 86.Pp 87.Fn mknod 88requires super-user privileges. 89.Sh RETURN VALUES 90.Rv -std mknod mknodat 91.Sh ERRORS 92.Fn mknod 93and 94.Fn mknodat 95will fail and the file will be not created if: 96.Bl -tag -width Er 97.It Bq Er EACCES 98Search permission is denied for a component of the path prefix. 99.It Bq Er EDQUOT 100The directory in which the entry for the new node 101is being placed cannot be extended because the 102user's quota of disk blocks on the file system 103containing the directory has been exhausted; or 104the user's quota of inodes on the file system on 105which the node is being created has been exhausted. 106.It Bq Er EEXIST 107The named file exists. 108.It Bq Er EFAULT 109.Fa path 110points outside the process's allocated address space. 111.It Bq Er EINVAL 112The supplied 113.Fa mode 114or 115.Fa dev 116is invalid. 117.It Bq Er EIO 118An I/O error occurred while making the directory entry or allocating the inode. 119.It Bq Er ELOOP 120Too many symbolic links were encountered in translating the pathname. 121.It Bq Er ENAMETOOLONG 122A component of a pathname exceeded 123.Brq Dv NAME_MAX 124characters, or an entire path name exceeded 125.Brq Dv PATH_MAX 126characters. 127.It Bq Er ENOENT 128A component of the path prefix does not exist. 129.It Bq Er ENOSPC 130The directory in which the entry for the new node is being placed 131cannot be extended because there is no space left on the file 132system containing the directory; or 133there are no free inodes on the file system on which the 134node is being created. 135.It Bq Er ENOTDIR 136A component of the path prefix is not a directory. 137.It Bq Er EPERM 138The process's effective user ID is not super-user. 139.It Bq Er EROFS 140The named file resides on a read-only file system. 141.El 142.Pp 143In addition, 144.Fn mknodat 145will fail if: 146.Bl -tag -width Er 147.It Bq Er EBADF 148.Fa path 149does not specify an absolute path and 150.Fa fd 151is neither 152.Dv AT_FDCWD 153nor a valid file descriptor open for reading or searching. 154.It Bq Er ENOTDIR 155.Fa path 156is not an absolute path and 157.Fa fd 158is a file descriptor associated with a non-directory file. 159.El 160.Sh SEE ALSO 161.Xr chmod 2 , 162.Xr mkfifo 2 , 163.Xr stat 2 , 164.Xr umask 2 165.Sh STANDARDS 166The 167.Fn mknod 168function conforms to 169.St -p1003.1-90 . 170.Fn mknodat 171conforms to 172.St -p1003.1-2008 . 173.Sh HISTORY 174A 175.Fn mknod 176function call appeared in 177.At v6 . 178