#include <sys/types.h> #include <sys/stat.h> int mknod(const char *path, mode_t mode, rdev_t device_id);
mknodcreates a new character special file or a FIFO special file. The
pathargument specifies the pathname of the special file, and the
modeargument determines which type of special file is created. The following symbols can be specified as the
The file permissions bits of the new special file can also
be initialized with the
mode argument. To do this,
use a bitwise OR
operation to combine any of the permissions symbols described
mode argument of the
chmod function with
device_id argument identifies the specific device
associated with a character special file. This argument is not
used with FIFO special files.
device_id argument is one word long, with the high-order
16 bits used to identify the device driver for a class of devices,
such as interactive terminals. See
IBM's Application Callable Services for OpenEdition MVS (SC23-3020)
for an explanation of device IDs.
0if successful and
-1if it is unsuccessful.
mknodefunction is useful in POSIX applications; however, it is not defined by POSIX.1 and should not be used in strictly conforming applications. POSIX.1 does not provide a way to make character special files.
mknodto create a character special file with user read and write permissions set and a
0x00020003. (It is a slave pseudo TTY.)
#include <sys/stat.h> #include <unistd.h> #include <stdio.h> #define deviceClass 0x00020000 #define ttyNumber 3 . . . char charSpecial="pseudo.tty"; . . . mknod(charSpecial, S_IFCHR|S_RUSR|S_IWUSR, deviceClass|ttyNumber); . . .
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.