mknod (BPX1MKN, BPX4MKN) — Make a directory, a FIFO, a character special, or a regular file

Function

The mknod callable service creates a new directory, a regular file, a character special file, or a FIFO special file (named pipe).

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1MKN): 31-bit
AMODE (BPX4MKN): 64-bit
ASC mode: Primary mode
Interrupt status: Enabled for interrupts
Locks: Unlocked
Control parameters: All parameters must be addressable by the caller and in the primary address space.

Format

CALL BPX1MKN,(Pathname_length,
              Pathname,
              Mode,
              Device_identifier,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4MKN with the same parameters.

Parameters

Pathname_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of the Pathname of the special file to be created.

Pathname
Supplied parameter
Type:
Character string
Character set:
No restriction
Length:
Specified by the Pathname_length parameter

The name of a field that contains the pathname of the file. The length of this field is specified in Pathname_length.

Pathnames can begin with or without a slash.
  • A pathname that begins with a slash is an absolute pathname. The slash refers to the root directory, and the search for the file starts at the root directory.
  • A pathname that does not begin with a slash is a relative pathname. The search for the file starts at the working directory.
Mode
Supplied parameter
Type:
Structure
Length:
Fullword

The name of a fullword in which the mode field is specified. The mode field specifies the file type and the permissions you grant to yourself, to your group, and to any user. Specify the file type with the BPXYFTYP mapping macro, and specify permissions with the BPXYMODE mapping macro. See BPXYFTYP — File type definitions and BPXYMODE — Map the mode constants of the file services.

Device_identifier
Supplied parameter
Type:
Structure
Length:
Fullword

The name of a fullword that contains a device identifier, or 0. The high-order 16 bits of Device_identifier is the device major number. The device major number corresponds to a device driver that supports a class of devices—for example, interactive terminals. The low-order 16 bits of Device_identifier is the device minor number. The device minor number corresponds to a specific device within the class of devices that are referred to by the device major number. Specify Device_identifier if you are creating a character special file.

If a FIFO, directory, or regular file is being created, Device_identifier is ignored.

The following device major numbers are currently defined:
Device major numbers Device class
1 Master pseudoterminal
2 Slave pseudoterminal
3 /dev/tty
4 /dev/null, /dev/zero, and /dev/random
5 /dev/fdn
6 Sockets
7 OCSRTY
8 OCSADMIN
9 /dev/console

For device major numbers 1, 2, and 7, the device minor numbers refer to specific pseudoterminal pairs and the values range from 0 and one less than the maximum number of pseudoterminal pairs defined by the installation.

For device major numbers 3, 6, 8, and 9, the device minor number is ignored.

For device major number 4, device minor numbers represent files as follows:
Device minor numbers for device major number 4 File
0 /dev/null
1 /dev/zero
2 /dev/random and /dev/urandom

For device major number 5, the device minor number value represents the file descriptor to be referred to. For example, device minor 0 refers to file descriptor 0.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the mknod service returns 0 if the request is successful, or -1 if it is not successful.

Return_code
Returned parameter
Type:
Integer
Length:
Fullword
The name of a fullword in which the mknod service stores the return code. The mknod service returns Return_code only if Return_value is -1. See z/OS UNIX System Services Messages and Codes for a complete list of possible return code values. The mknod service can return one of the following values in the Return_code parameter:
Return_code Explanation
EACCES The process does not have permission to search some component of Pathname; or does not have write permission for the directory of the file to be created.
EEXIST A file or directory named Pathname already exists. The following reason code can accompany the return code: JRSpFileExists.
EFBIG A request to create a new file is prohibited because the file size limit for the process is set to 0.
EINVAL The file type specified in the Mode parameter is not 1, 2, 3 or 4. The following reason code can accompany the return code: JRMknodInvalidType.
ELOOP A loop exists in symbolic links that were encountered during resolution of the Pathname argument. This error is issued if more than 24 symbolic links are detected in the resolution of Pathname.
ENAMETOOLONG Pathname is longer than 1023 characters; or a component Pathname has a name longer than 255 characters.
ENOENT A component of Pathname was not found; or no pathname was specified. The following reason code can accompany the return code: JREndingSlashMknod.
ENOTDIR A component of Pathname is not a directory.
EPERM The operation is not permitted. The operation requested requires a superuser authority. The following reason code can accompany the return code: JrUserNotPrivileged.
EROFS The directory of the file is on a read-only file system. The following reason code can accompany the return code: JRReadOnlyFilesetMknodReq.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the mknod service stores the reason code. The mknod service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.

Usage notes

  1. The file permission bits of Mode are modified by the process's file creation mask (see umask (BPX1UMK, BPX4UMK) — Set the file mode creation mask). They are then used to set the file permission bits of the file being created.
  2. The file's owner ID is set to the process's effective user ID (UID). By default, the owning GID is set to that of the parent directory. However, if the FILE.GROUPOWNER.SETGID profile exists in the UNIXPRIV class, the owning GID is determined by the set-gid bit of the parent directory, as follows:
    • If the parent's set-gid bit is on, the owning GID is set to that of the parent directory.
    • If the parent's set-gid bit is off, the owning GID is set to the effective GID of the process.
  3. The mknod service sets the access, change, and modification times for the new file. It also sets the change and modification times for the directory that contains the new file.

Related services

Characteristics and restrictions

When the mknod service is requested to create a character special file, a directory or a regular file, it is a privileged operation and requires superuser authority.

Examples

For an example using this callable service, see BPX1MKN (mknod) example.