EmbLogic's Blog

diffrence between mknod and mkfifo

1.mknod
Syntax

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

where pathname corresponds to the fifo name, mode corresponds to the

file permissions. Since mknod can be used to create a regular file,

block or charcter special files and fifo. We have to specify the file

type. Corresponding to FIFO: the file type is S_IFIFO.

2. mkfifo
Syntax
int mkfifo(const char *pathname, mode_t mode);
where pathname correspnds to fifo name and mode corresponds to file
mode.

description——
The mknod subroutine creates a new regular file, special file, or FIFO file. Using the mk
nod subroutine to create file types (other than FIFO or special files) requires root user authority.

For the mknod subroutine to complete successfully, a process must have both search and write permission in the parent directory of the Path parameter.

The mkfifo subroutine is an interface to the mknod subroutine, where the new file to be created is a FIFO or special file. No special system privileges are required.

The new file has the following characteristics:

File type is specified by the Mode parameter.
Owner ID is set to the effective user ID of the process.
Group ID of the file is set to the group ID of the parent directory if the SetGroupID attribute (S_ISGID) of the parent directory is set. Otherwise, the group ID of the file is set to the effective group ID of the calling process.
Permission and attribute bits are set according to the value of the Mode parameter. All bits set in the file-mode creation mask of the process are cleared.

Upon successful completion, the mkfifo subroutine marks for update the st_atime, st_ctime, and st_mtime fields of the file. It also marks for update the st_ctime and st_mtime fields of the directory that contains the new entry.

If the new file is a character special file having the S_IMPX attribute (multiplexed character special file), when the file is used, additional path-name components can appear after the path name as if it were a directory. The additional part of the path name is available to the device driver of the file for interpretation. This feature provides a multiplexed interface to the device driver.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>