dg_mknod(2) SDK R4.11 dg_mknod(2)
NAME
dgmknod - create a file system node
SYNOPSIS
#include <sys/types.h>
#include <sys/dgmknod.h>
#include <sys/dgstat.h>
int dgmknod (path, bufferptr, version)
char * path;
struct dgmknod * bufferptr;
unsigned short version;
where:
path Address of pathname to create
bufferptr Address of a dgmknod buffer which describes the node
to be created
version Version of the struct dgmknod packet that bufferptr
refers to; should be set to DG_MKNOD_VERSION_NUMBER
DESCRIPTION
Dgmknod(2) 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 bufferptr:
· The file's type and mode will be set according to the
extendedmode 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 the calling
process must have appropriate privilege to set the sticky bit
(S_ISVTX), as explained below. For systems supporting the
DG/UX Capability Option, appropriate privilege is defined as
having one or more specific capabilities enabled in the
effective capability set of the calling process. See
capdefaults(5) for the default capability for this system
call.
On systems without the DG/UX Capability Option, appropriate privilege
means that the process has an effective UID of root. See the
appropriateprivilege(5) man page for more information.
· 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 devicenumber.
· 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 symboliclinktarget field will be
used as the target of the link file. Note that there is no
requirement that symboliclinktarget actually exist.
· 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
bufferptr, using the following algorithm: Each integer
between desireddataelementblocks and
dataelementblockslimit, 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 desiredindexelementblocks and work towards
indexelementblockslimit.
· 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.
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 bufferptr
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 calling process must have appropriate privilege in order to
create files of type block-special or character-special.
The calling process must have appropriate privilege 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 dgmknod operation was successful.
-1 An error occurred. errno is set to indicate the error.
DIAGNOSTICS
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 bufferptr
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 available to
allocate file space or an inode.
EFAULT bufferptr points to an invalid address, or the
pathname does not completely reside in the process's
address space or the pathname does not terminate in
the process's address space.
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 of the target of the symbolic link being
created exceeds the length limit for pathnames, or a
component of the pathname of the target of the
symbolic link being created 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, or the pathname contains
a character not in the allowed character set.
EACCES The calling process does not have permission to
resolve the pathname.
SEE ALSO
chmod(2), chown(2), creat(2), dgfstat(2), dgmstat(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),
appropriateprivilege(5), dg_mknod(5), dgstat(5), stat(5).
capdefaults(5).
Licensed material--property of copyright holder(s)