Enhancements to Support Special and Device Files [ COMMUNICATOR 3000 MPE/iX General Release 5.0 (Core Software Release C.50.00) ] MPE/iX Communicators
COMMUNICATOR 3000 MPE/iX General Release 5.0 (Core Software Release C.50.00)
Enhancements to Support Special and Device Files
Rick Ehrhart, Robin Florentine, and Donna Gracyk
Commercial Systems Division
Overview
MPE/iX has been enhanced in this release to allow for the creation of
special files in a traditional UNIX manner through the mknod() and
mkfifo() C library functions and through the use of the MKNOD program. A
new intrinsic HPDEVCREATE has also been implemented to create these
special files. The three file types that can be created through these
application interfaces are described below.
Device Link Files.
Device link files are a new type of file introduced in this MPE/iX
release. These files can be compared to symbolic links where instead of
the link pointing to another file, the device link maps a name to a
particular device (which may or may not be configured) on the system.
Another analogy is to think of device link files as directory-based
device file equations. Just as with file equations, the attributes of
the file are taken from the attributes of the configured device. In the
file equation :FILE X;DEV=7, we never mention that this is a tape device.
It is simply implicit from the configuration information that the system
has on LDEV 7.
FIFO Files.
A FIFO is a UNIX type of special file defined in the POSIX.1 standard.
FIFO files are similar to pipes. Data is written and read from the file
in a First-In First-Out manner (i.e., the first byte written to the file
is the first byte read from the file). The difference between pipes and
FIFOs is that a FIFO has a name associated with it. Thus, unrelated
processes can share a FIFO.
Streams Files.
Streams files provide the interface to the Streams facility. The Streams
facility is a general set of tools for development of communications
services. It supports the implementation of services ranging from
individual device drivers to complete networking protocol suites.
Currently, streams modules and drivers are provided by HP.
File System Intrinsic Support
The file system supports these three new file types through the MPE
intrinsics and C Library functions. The new intrinsic, HPDEVCREATE, is
described below. Three new C Library functions: mknod, mklannod, and
mkfifo, are also discussed below.
HPDEVCREATE - New Intrinsic.
The HPDEVCREATE intrinsic provides an application interface to create a
streams, FIFO, and device link file. Below is the format of the
intrinsic:
______________________________________________________________
| |
| HPDEVCREATE( pathname, path_syntax, path_length, status|
| [,itemnum, item] [...]); |
______________________________________________________________
The intrinsic is similar to HPFOPEN in that you can define the
characteristics of the special file by specifying one or more
itemnum/item pairs. Some of these items include device file type, LDEV,
major number, minor number, and link name. Please refer to the MPE/iX
Intrinsics Reference Manual (32650-90028) for more details.
C Library Functions.
mknod().
The C library interface for mknod is similar to the HP-UX version of
mknod. The only difference is that system manager capability is not
required to make ordinary files.
_____________________________________
| |
| int mknod(path, mode, dev) |
| |
| const char *path; |
| mode_t mode; |
| dev_t dev; |
_____________________________________
mknod() creates a special or FIFO file. It takes three parameters. The
three parameters are: path, mode, and dev.
The path parameter must be a null-terminated string designating the name
of the special file to create.
The mode parameter is the bitwise inclusive OR of the file type to create
and the access permissions to set. Macros that can be used to
encode the permission bits and the file type can be found in
/usr/include/sys/stat.h.
Currently, the mknod function can make three types of special files:
FIFOs, streams, and device link files. For a FIFO file, the dev
parameter is ignored. For a character special file of the streams type,
the dev parameter should contain the major and minor numbers for the
streams device. For a character special file of the device link type,
the dev parameter should contain a major number of 0 and a minor number
that is the LDEV for the device. The makedev (major,minor) macro should
be used to create the dev parameter. The specification of this macro can
be found in the file <sys/sysmacros.h>.
If the file type is zero or is not specified, mknod creates a regular
file.
CD capability in a directory/MPE group is required to create FIFO or
regular files. Creating streams files requires SM and NM capability.
Creating device link files requires SM capability.
The mknod function sets the owner ID of the file to the effective-user-ID
of the process. mknod sets the file's group ID to the group ID of the
parent directory.
If mknod completes successfully, the functional return is zero. If an
error occurs, a value of -1 is returned and the global variable errno is
set with the resultant error.
mklannod().
_______________________________________________
| |
| int mklannod(path, mode, dev, link_name)|
| |
| const char *path; |
| mode_t mode; |
| dev_t dev; |
| const char * link_name; |
_______________________________________________
mklannod creates a streams device file (character special file). It
takes four parameters: path, mode, dev, and link_name. The path
parameter must be a null-terminated string designating the name of the
special file to create.
The mode parameter is the bitwise inclusive OR of the file type to create
and the access permissions to set the file. Macros that can be used to
encode the permission bits and the file type can be found in
/usr/include/sys/stat.h.
For a character special file of the streams type, the dev parameter
should contain the major and minor numbers for the streams device.
The makedev(major,minor) macro should be used to create the dev
parameter. The specification of this macro can be found in the file
<sys/sysmacros.h>.
The link_name parameter is used for the character special file of the
streams type that requires a link name, such as the DTS link which can be
found in the Network Node Manager (NMMGR). This name is limited to eight
characters and follows MPE syntax rules.
The mklannod function sets the owner ID of the file to the
effective-user-ID of the process. mklannod sets the file's group ID to
the group ID of the parent directory.
Creating streams files requires SM and NM capability.
If mklannod completes successfully, the functional return is zero. If an
error occurs, a value of -1 is returned and the global variable errno is
set with the resultant error.
mkfifo().
_____________________________________
| |
| int mkfifo(path, mode) |
| |
| const char *path; |
| mode_t mode; |
_____________________________________
mkfifo() creates a FIFO file. A FIFO file is a First-In First-Out queue
of data. Data written to such a file is read on a First-In-First-Out
basis, i.e., the first byte written is the first byte read. The purpose
of FIFO files is to allow communication between unrelated processes.
The mkfifo function creates a FIFO file with the name specified by the
path parameter. The path parameter must be a null-terminated string.
The file permission bits of the new FIFO file are initialized according
to the values specified in the mode parameter. The mkfifo function
always assumes a FIFO file is being created no matter what file type is
specified.
CD access control definition required in a directory/MPE group for
creation of FIFO device files.
MKNOD Program
The program MKNOD.PUB.SYS lets you create special and FIFO files. It
allows for the specification of special files in a traditional UNIX
manner of major and minor numbers. When creating a device link or
streams file (character-type file), both the major and minor numbers are
required. A major number of zero (0) creates a device link file which
resolves to the LDEV number specified in the minor number argument. A
major number greater than zero creates a streams file.
The program arguments are shown below:
Usage: mknod "name c|p major minor [link_name]".
name : name of the special file to create.
c|p : character mode or FIFO.
major : device major number.
minor : device minor number.
link_name : link name (from nmmgr link screen).
mknod can also be used as a POSIX shell command.
MPE/iX Communicators