dgmknod(2) DG/UX 4.30 dgmknod(2)
NAME
dg_mknod - Create a file system node.
SYNOPSIS
#include <sys/types.h>
#include <sys/dg_mknod.h>
#include <sys/dg_stat.h>
int dg_mknod (path, buffer_ptr, version)
char * path;
struct dg_mknod * buffer_ptr;
unsigned short version;
PARAMETERS
path Address of pathname to create.
buffer_ptr Address of a dg_mknod buffer which describes
the node to be created.
version Version of the struct dg_mknod packet that
<buffer_ptr> refers to; should be set to
DG_MKNOD_VERSION_NUMBER.
DESCRIPTION
Dg_mknod() creates a new ordinary file, directory, control-
point directory, block-special file, character-special file,
FIFO file, or symbolic link file. The new file will be
named <path>, and its attributes will be set according to
the struct dg_mknod packet represented by <buffer_ptr>:
* The file's type and mode will be set according to the
<extended_mode> field. Note that the file's mode is
modified by the process's file mode creation mask; all
bits set in the mask are cleared (see umask(2)). Note
also that only the superuser may set the sticky bit
(S_ISVTX), as explained below.
* If the file is of type block-special (S_IFBLK) or
character-special (S_IFCHR), then the file's
represented device (st_rdev) will be set to
<device_number>.
* If the file is of type FIFO (S_IFIFO), then the
indicated FIFO (named pipe) file will be created.
* If the file is of type symbolic link (S_IFLNK), then
the pathname denoted by the <symbolic_link_target>
field will be used as the target of the link file.
Note that there is no requirement that
<symbolic_link_target> actually exist.
Licensed material--property of copyright holder(s) Page 1
dgmknod(2) DG/UX 4.30 dgmknod(2)
* If the file is of type ordinary file (S_IFREG),
directory (S_IFDIR) or CPD (DG_IFCPD), then the file's
data and index element sizes will be set according to
the information in <buffer_ptr>, using the following
algorithm: Each integer between
<desired_data_element_blocks> and
<data_element_blocks_limit>, starting at the former,
will be examined in order. The first number that is
discovered to be a valid data element size is the
number that will be used as the data element size. If
no number in the specified range is a valid element
size, an error will be returned (see below) and no node
will be created. The file's index element size will be
set in exactly the same manner, except that the range
will start at <desired_index_element_blocks> and work
towards <index_element_blocks_limit>.
* If the file is of type socket (S_IFSOCK), or if the
file type is invalid, an error will be returned (see
below) and no node will be created.
The file's other attributes are initialized as follows:
* The file's inode number (st_ino) is set to refer to the
per-file database allocated.
* The file's size (st_size) is set to zero.
* The number of links to the file (st_nlink) is set to
one, unless the file is of type directory (S_IFDIR) or
CPD (DG_IFCPD), in which case it is set to two.
* The file's user-ID (st_uid) is set to the effective
user-ID of the calling process.
* The file's group-ID (st_gid) is set to the effective
group-ID of the calling process.
* The file's time fields (st_atime, st_ctime and
st_mtime) are all set to the current time.
<Path> is created in the containing directory and is made to
identify the newly created file. The attributes of the
parent directory change as follows:
* The file size (st_size) is updated if the new directory
entry caused the directory to change size.
* The time last modified (st_mtime) and time of last
attribute change (st_ctime) are set to the current
time.
Licensed material--property of copyright holder(s) Page 2
dgmknod(2) DG/UX 4.30 dgmknod(2)
If the call to dg_mknod() fails, no file is created, and the
attributes of the directory intended to contain the file
remain unchanged.
The size and composition of the structure referred to by
<buffer_ptr> are determined by the <version> parameter. All
calls to this function should use DG_MKNOD_VERSION_NUMBER
for this parameter. <Version> allows for future revisions
of struct dg_mknod to be handled in a compatible way.
ACCESS CONTROL
The process must have write access to the containing
directory of <path>, and it must have permission to resolve
<path>.
The process's effective user-ID must be superuser in order
to create files of type block-special or character-special.
The process's effective user-ID must be superuser in order
to set the sticky-bit (S_ISVTX). However, failure to meet
this requirement will not produce an error when setting the
sticky bit is requested; the file will merely be created
without that bit being set.
RETURN VALUE
0 The dg_mknod operation was successful.
-1 An error occurred. Errno is set to indicate
the error.
EXCEPTIONS
Errno may be set to one of the following error codes:
EEXIST The named file <path> already exists.
EINVAL <version> is not a supported version of
struct dg_mknod.
EINVAL An invalid file type was specified in the
<buffer_ptr->extended_mode>.
EROFS The directory in which <path> is to be
created is located on a file system device
that is mounted read-only.
ENOSPC There is not enough contiguous space
Licensed material--property of copyright holder(s) Page 3
dgmknod(2) DG/UX 4.30 dgmknod(2)
available to allocate file space or an inode.
EFAULT <buffer_ptr> points to an invalid address.
ENOENT A non-terminal component of the pathname does
not exist.
ENOTDIR A non-terminal component of the pathname was
not a directory or symbolic link.
ENAMETOOLONG The pathname exceeds the length limit for
pathnames.
ENAMETOOLONG A component of the pathname exceeds the
length limit for filenames.
ENOMEM There are not enough system resources to
resolve the pathname or to expand a symbolic
link.
ELOOP The number of symbolic links encountered
during pathname resolution exceeded
MAXSYMLINKS. A symbolic link cycle is
suspected.
EPERM Permission to create a character-special file
or a block-special file is denied.
EPERM The pathname contains a character not in the
allowed character set.
EFAULT The pathname does not completely reside in
the process's address space or the pathname
does not terminate in the process's address
space.
ENAMETOOLONG The pathname of the target of the symbolic
link being created exceeds the length limit
for pathnames.
Licensed material--property of copyright holder(s) Page 4
dgmknod(2) DG/UX 4.30 dgmknod(2)
ENAMETOOLONG A component of the pathname of the target of
the symbolic link being created exceeds the
length limit for filenames.
EACCES The calling process does not have permission
to resolve the pathname.
SEE ALSO
The related manual sections: chmod(2), chown(2), creat(2),
dg_fstat(2), dg_mstat(2), fchmod(2), fchown(2), fstat(2),
link(2), lstat(2), mknod(2), pipe(2), read(2), stat(2),
time(2), unlink(2), utime(2), utimes(2), write(2),
dg_mknod(5), dg_stat(5), stat(5).
Licensed material--property of copyright holder(s) Page 5