mknod()

create a special file 

Function


SYNOPSIS

#include <sys/stat.h>

int mknod(const char *pathname, mode_t mode, dev_t dev);


DESCRIPTION

The mknod() function creates a new special file named by pathname. mode specifies the type of the file to be created and the file's access mode. With the PTC MKS Toolkit UNIX APIs, mknod() only supports creating FIFO special files, indicated by ORing S_IFIFO into the mode parameter. The dev parameter is ignored. Refer to mkfifo() for details on creating FIFO special files.


PARAMETERS

pathname 

Specifies the name of the new FIFO special file. The path name must specify a path under the fifos subdirectory of the NuTCRACKER Platform installation directory. You can use the _NutQueryRootDir() function to obtain this path.

mode 

Specifies the what access modes the FIFO special file has when it is created, and must have the S_IFIFO flag set in it as well, to indicate that a FIFO special file is being created. Refer to the documentation for stat() for a discussion of access mode flags.

dev 

Is ignored.


RETURN VALUES

If successful, mknod() returns zero. On failure, it returns -1, does not create the FIFO special file, and sets errno to one of the following values:

EACCES 

Search permission is denied on a component of the path prefix or write permission is denied on the parent directory of the file to be created.

EEXIST 

The named file already exists.

EINVAL 

pathname does not specify a path under the fifos subdirectory of the NuTCRACKER Platform installation directory.

EINVAL 

mode indicates a file type other than a FIFO special file.

ENAMETOOLONG 

The length of the path name parameter exceeds PATH_MAX or a path name component is longer than NAME_MAX.

ENOENT 

A component of the path name prefix does not exist or pathname points to an empty string.

ENOSPC 

The directory that contains the new file cannot be extended or the file system is out of file allocation resources.

ENOTDIR 

A component of the path prefix is not a directory.

EROFS 

The named file resides on a read-only file system.


CONFORMANCE

UNIX 98, with exceptions.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The NuTCRACKER Platform requires that FIFOS be created under the fifo subdirectory of the NuTCRACKER Platform installation directory. The following code fragment shows an example of how to establish a valid path:

#include <nutc.h>
#include <sys/types.h>
#include <sys/stat.h>
...
sprintf(path, "%s/fifos/myfifo", _NutQueryRootDir(1));
mknod(path, S_IFIFO | 0666, 0);
...

NuTCRACKER Platform FIFOs appear as regular files to non-NuTCRACKER Platform applications. If a non-NuTCRACKER Platform application writes to a FIFO, the FIFO is corrupted such that it no longer appears as a FIFO to NuTCRACKER Platform applications.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
chmod(), mkfifo(), stat(), umask()

Miscellaneous:
struct stat


PTC MKS Toolkit 10.4 Documentation Build 39.