Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mknod(2) — HP-UX 7.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

mkdir(2)

mkdir(1)

mknod(1M)

chmod(2)

exec(2)

setacl(2)

umask(2)

cdf(4)

fs(4)

mknod(4)

acl(5)

MKNOD(2)

NAME

mknod − make a directory, or a special or regular file

SYNOPSIS

#include <sys/types.h>
#include <sys/stat.h>
int mknod (path, mode, dev)
char ∗path;
mode_t mode;
dev_t dev;
int mkrnod(path, mode, dev, cnodeid)
char *path;
int mode;
dev_t dev;
cnode_t cnodeid;

DESCRIPTION

Mknod creates a new file named by the path name pointed to by path. The mode of the new file is specified by the mode argument.  Mkrnod is the same as mknod but is used to make device files that can be accessed from a different cnode identified by the additional parameter cnodeid. A cnodeid value of 0 creates a "generic" device file that can be accessed by any cnode. 

Symbolic constants defining the file type and file access permission bits are found in the <sys/stat.h> header file and are used to construct the mode argument.  The value of the mode argument should be the bitwise inclusive OR of the values of the desired file type, miscellaneous mode bits, and access permissions.  If the S_IFMT portion of mode has a value of 0, mknod creates a regular file.  The mode value 0044000 (S_CDF | S_IFDIR) is used with mkrnod to indicate a hidden directory (see cdf(4)).

S_IFMT File type mask
S_IFNWK Network special file
S_IFIFO FIFO special file
S_IFCHR Character special file
S_IFDIR Directory node
S_IFBLK Block special file
S_IFREG Regular file
S_ISUID Set user ID on execution
S_ISGID Set group ID on execution
S_ENFMT Record locking enforced
S_ISVTX Save text image after execution
S_IRWXU Permission mask for owner
S_IRUSR Read by owner
S_IWUSR Write by owner
S_IXUSR Execute (search) by owner
S_IRWXG Permission mask for group
S_IRGRP Read by group
S_IWGRP Write by group
S_IXGRP Execute (search) by group
S_IRWXO Permission mask for others
S_IROTH Read by others
S_IWOTH Write by others
S_IXOTH Execute (search) by others

The owner ID of the file is set to the effective-user-ID of the process.  If the set-group-ID bit of the parent directory is set, the directory’s group ID is set to the group ID of the parent directory.  Otherwise, the directory’s group ID is set to the effective-group-ID of the process. 

The file access permission bits of mode are modified by the process’s file mode creation mask: for each bit set in the process’s file mode creation mask, the corresponding bit in the file’s mode is cleared (see umask(2)).

On systems implementing access control lists (ACLs), the directory is created with three base ACL entries, corresponding to the file access permission bits (see acl(5)).

Dev is meaningful only if mode indicates a block or character special file, and is ignored otherwise.  It is an implementation- and configuration-dependent specification of a character or block I/O device.  Dev is created by using the makedev macro defined in <sys/sysmacros.h>.  The makedev macro takes as arguments the major and minor device numbers, whose value and interpretation are implementation dependent.  The result of makedev is an object of type dev_t. 

Mknod can be invoked only by the super-user for file types other than FIFO special. 

WARNINGS

Proper discretion should be used when using mkrnod to create generic device files.  A generic device file accessed from different cnodes applies to different physical devices.  Thus the file’s ownership and permissions may not be appropriate in the context of all the cnodes. 

RETURN VALUE

Upon successful completion a value of 0 is returned.  Otherwise, a value of −1 is returned and errno is set to indicate the error. 

ERRORS

Mknod fails and the new file is not created if one or more of the following is true:

[EACCES] Path is in a directory that denies write permission, mode is for a FIFO special file, and the caller is not a super-user. 

[EACCES] A component of the path prefix denies search permission. 

[EEXIST] The named file exists. 

[EFAULT] Path points outside the process’s allocated address space.  The reliable detection of this error is implementation dependent. 

[ELOOP] Too many symbolic links are encountered in translating the path name. 

[ENAMETOOLONG]
The length of the specified path name exceeds PATH_MAX bytes, or the length of a component of the path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC is in effect. 

[ENOENT] Path is null. 

[ENOENT] A component of the path prefix does not exist. 

[ENOSPC] Not enough space on the file system. 

[ENOTDIR] A component of the path prefix is not a directory. 

[EPERM] The effective-user-ID of the process does not match that of the super-user, and the file type is not FIFO special. 

[EROFS] The directory in which the file is to be created is located on a read-only file system. 

AUTHOR

Mknod was developed by AT&T and HP. 

SEE ALSO

mkdir(2), mkdir(1), mknod(1M), chmod(2), exec(2), setacl(2), umask(2), cdf(4), fs(4), mknod(4), acl(5). 

STANDARDS CONFORMANCE

mknod: SVID2, XPG2

Hewlett-Packard Company  —  HP-UX Release 7.0: Sept 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026