Files
oldlinux-files/Minix/2.0.0/wwwman/man2/mknod.2.html
2024-02-19 00:21:39 -05:00

124 lines
4.1 KiB
HTML

<HTML>
<HEAD>
<TITLE>mknod(2)</TITLE>
</HEAD>
<BODY>
<H1>mknod(2)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
mknod, mkfifo - make a special file
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>#include</STRONG> <STRONG>&lt;sys/types.h&gt;</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;unistd.h&gt;</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;sys/stat.h&gt;</STRONG>
<STRONG>int</STRONG> <STRONG>mknod(const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>path</EM><STRONG>,</STRONG> <STRONG>mode_t</STRONG> <EM>mode</EM><STRONG>,</STRONG> <STRONG>dev_t</STRONG> <EM>dev</EM><STRONG>)</STRONG>
<STRONG>int</STRONG> <STRONG>mkfifo(const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>path</EM><STRONG>,</STRONG> <STRONG>mode_t</STRONG> <EM>mode</EM><STRONG>)</STRONG>
</PRE>
<H2>DESCRIPTION</H2><PRE>
<STRONG>Mknod</STRONG> creates a new file whose name is <EM>path</EM>. The mode of the new file
(including special file bits) is initialized from <EM>mode</EM>, as defined in
&lt;<EM>sys</EM>/<EM>stat</EM>.<EM>h</EM>&gt;. (The protection part of the mode is modified by the
process's mode mask (see <STRONG><A HREF="../man2/umask.2.html">umask(2)</A></STRONG>)). The first block pointer of the i-
node is initialized from <EM>dev</EM> and is used to specify which device the
special file refers to.
If mode indicates a block or character special file, <EM>dev</EM> is the device
number of a character or block I/O device. The low eight bits of the
device number hold the minor device number that selects a device among
the devices governed by the same driver. The driver is selected by the
major device number, the next eight bits of the device number.
If <EM>mode</EM> does not indicate a block special or character special device,
<EM>dev</EM> is ignored. (For example, when creating a ``fifo'' special file.)
<STRONG>Mknod</STRONG> may be invoked only by the super-user, unless it is being used to
create a fifo.
The call <STRONG>mkfifo(</STRONG><EM>path</EM><STRONG>,</STRONG> <EM>mode</EM><STRONG>)</STRONG> is equivalent to
<STRONG>mknod(</STRONG><EM>path</EM><STRONG>,</STRONG> <STRONG>(</STRONG><EM>mode</EM> <STRONG>&amp;</STRONG> <STRONG>0777)</STRONG> <STRONG>|</STRONG> <STRONG>S_IFIFO,</STRONG> <STRONG>0)</STRONG>
</PRE>
<H2>RETURN VALUE</H2><PRE>
Upon successful completion a value of 0 is returned. Otherwise, a value
of -1 is returned and <STRONG>errno</STRONG> is set to indicate the error.
</PRE>
<H2>ERRORS</H2><PRE>
<STRONG>Mknod</STRONG> will fail and the file mode will be unchanged if:
[ENOTDIR] A component of the path prefix is not a directory.
[ENAMETOOLONG] The path name exceeds PATH_MAX characters.
[ENOENT] A component of the path prefix does not exist.
[EACCES] Search permission is denied for a component of the path
prefix.
[ELOOP] Too many symbolic links were encountered in translating
the pathname. (Minix-vmd)
[EPERM] The process's effective user ID is not super-user.
[EIO] An I/O error occurred while making the directory entry or
allocating the inode.
[ENOSPC] The directory in which the entry for the new node is being
placed cannot be extended because there is no space left
on the file system containing the directory.
[ENOSPC] There are no free inodes on the file system on which the
node is being created.
[EROFS] The named file resides on a read-only file system.
[EEXIST] The named file exists.
[EFAULT] <EM>Path</EM> points outside the process's allocated address space.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man2/chmod.2.html">chmod(2)</A></STRONG>, <STRONG><A HREF="../man2/stat.2.html">stat(2)</A></STRONG>, <STRONG><A HREF="../man2/umask.2.html">umask(2)</A></STRONG>.
</PRE>
</BODY>
</HTML>