MKNOD(2,L) AIX Technical Reference MKNOD(2,L)
-------------------------------------------------------------------------------
mknod, mknodx, mkfifo
PURPOSE
Creates a directory, a special file, a FIFO special file, or an ordinary file.
SYNTAX
#include <sys/stat.h>
int mknod (path, mode, dev)
char *path;
int mode;
dev_t dev;
int mknodx(path, mode, site, dev)
char *path;
int mode;
siteno_t site;
dev_t dev;
DESCRIPTION
The mknod system call creates a new regular file, special file, FIFO special
file, or directory. The path parameter names the new file.
Also see "mkdir" for additional information on creating a directory.
The mode parameter specifies the mode of the file, which defines the file type
and access permissions.
The dev parameter is configuration dependent and is used only if the mode
parameter specifies a block or character special file. dev is the ID of the
device, and it corresponds to the st_rdev member of the structure returned by
the stat system call. See "statx, fstatx, stat, fstat, fullstat, ffullstat,
lstat" and "stat.h" for more information about the device ID.
The mode parameter is constructed logically ORing the values specified in
"chmod, fchmod" with one the following values, which define the file type:
S_IFDIR Directory
S_IFCHR Character special file
S_IFMPX Multiplexed character special file
S_IFBLK Block special file
S_IFREG Regular data file
S_IFIFO FIFO special file.
Processed November 7, 1990 MKNOD(2,L) 1
MKNOD(2,L) AIX Technical Reference MKNOD(2,L)
The file types S_HIDDEN, S_SOCKET, and S_LINK cannot be created using mknod or
mknodx. Use chhidden to create S_HIDDEN, bind to create S_SOCKET, and symlink
to create S_LINK.
A complete list of the possible mode values and other useful macros appears in
"stat.h."
The new file has:
o the owner ID set to the process effective user ID.
o the group ID set to:
- the group ID of its parent directory, if the parent directory has the
set-file-group-ID attribute; otherwise,
- the process effective group ID.
o permission and attribute bits set according to the value of the mode
parameter, modified as follows:
- All bits set in the process file mode creation mask are cleared. (For
information about the file mode creation mask, see "umask.")
- If the new file is a directory, its set-file-group-ID and sticky
attributes are inherited from the parent directory.
If the type of the new file is S_IFMPX (multiplexed character special file),
then when the file is used, additional path name components can appear after
the path name as if it were a directory. The additional part of the path name
is available to the file's device driver for interpretation. This provides a
multiplexed interface to the device driver. The hft device driver uses this
feature. (See "hft" for details about this device driver.)
Upon successful completion, the mknod system call causes the st_ctime and
st_mtime fields of the directory in which the new regular file, special file,
FIFO special file, or directory was created to be updated to the current time.
Upon successful completion, the mknod system call causes the st_atime,
st_ctime, and st_mtime fields of the new regular file, special file, FIFO
special file, or directory to be set to the current time. See "stat.h" for
information on the st_atime, st_ctime, and st_mtime fields.
The mknod system call can be invoked only by the superuser for file types other
than FIFO special file.
If the Transparent Computing Facility is installed, the mknodx system call may
be used to create character or block special files for devices on any site in
the cluster. The site parameter specifies the site which has the physical
device. A site parameter value of 0 indicates a generic device special file;
this always refers to a device on the site from which it is accessed, rather
than a specific device on a specific site. Calling the mknod system call is
equivalent to calling the mknodx system call with the site parameter as the
Processed November 7, 1990 MKNOD(2,L) 2
MKNOD(2,L) AIX Technical Reference MKNOD(2,L)
local site number. Therefore, device special files created within a TCF
cluster using mknod refer to devices on the local node, not devices on the node
where the file resides. The site parameter is ignored if creating other types
of files.
COMPATIBILITY INTERFACES
The following interface is provided to allow for POSIX (draft 13, section
5.4.2) conformity.
#include <sys/types.h>
#include <sys/stat.h>
int mkfifo (path, mode)
char *path;
mode_t mode;
mkfifo (path, mode)
is equivalent to
mknod (path, (mode & 0777) | S_IFIFO, 0)
RETURN VALUE
Upon successful completion, a value of 0 is returned. If the mknod system call
fails, a value of -1 is returned and errno is set to indicate the error.
ERROR CONDITIONS
The mknod system call fails and the new file is not created if one or more of
the following are true:
EPERM The process's effective user ID is not superuser and the filetype is
not S_IFIFO.
ENOTDIR A component of the path prefix is not a directory.
ENOENT A component of the path prefix does not exist or the path parameter
points to an empty string.
EROFS The directory in which the file is to be created is located on a
read-only file system.
EEXIST The named file exists.
EFAULT The path parameter points to a location outside of the process's
allocated address space.
ESTALE The process's root or current directory is located in an NFS virtual
file system that has been unmounted.
Processed November 7, 1990 MKNOD(2,L) 3
MKNOD(2,L) AIX Technical Reference MKNOD(2,L)
ENAMETOOLONG
A component of the path parameter exceeded NAME_MAX characters or the
entire path parameter exceeded PATH_MAX characters.
EACCES The mode parameter specified a directory and the path parameter
explicitly named a hidden directory component.
EACCES Search permission is denied for a component of the path.
EACCES The directory in which the file is to be created does not permit
writing.
ENOENT A symbolic link was named, but the file to which it refers does not
exist.
ELOOP A loop of symbolic links was detected.
ENOSPC The file system is out of inodes or the directory in which the
regular file, special file, FIFO special file, or directory was to
have been created does not have room for the new entry and cannot be
extended.
EDQUOT The directory in which the entry for the new link is being placed
cannot be extended because the user's quota of disk blocks on the
file system containing the directory has been exhausted.
If the Transparent Computing Facility is installed on your system, mknod can
also fail if one or more of the following are true:
ESITEDN1 path cannot be accessed because a site went down.
ESITEDN2 The operation was terminated because a site failed.
ENOSTORE path is a name relative to the working directory, but no site which
stores this directory is currently up.
ENOSTORE A component of path is replicated but not stored on any site which is
currently up.
EROFS Write access is requested for a file on a replicated file system in
which the primary copy is unavailable.
EPERM A site value out of the range 0 through 31 was specified with a block
or character special mode value (mknodx only).
EINTR A signal was caught during the system call.
RELATED INFORMATION
In this book: "bind," "chhidden," "chmod, fchmod," "exec: execl, execv,
execle, execve, execlp, execvp," "mkdir," "umask," "symlink," "fs," and
"stat.h."
Processed November 7, 1990 MKNOD(2,L) 4
MKNOD(2,L) AIX Technical Reference MKNOD(2,L)
The chmod, mkdir, and mknod commands in AIX Operating System Commands
Reference.
Processed November 7, 1990 MKNOD(2,L) 5