Unix - How do you create special files like named pipes and device files?

How do you create special files like named pipes and device files?

Using the mknod command, special files can be created.
Mknod [options] name type[major minor]

Here, if argument is “p” a named pipe of FIFO file is created.
If the argument is “b”, a block file is created. Here, the major or minor device numbers needs to be specified.
If the argument is “c or u”, a character file is created. Here, the major or minor device numbers needs to be specified.

How do you create special files like named pipes and device files?

Special files are created by the system call ‘mknod’. Upon using the following sequence of steps, a special file will be created.

-new inode is assigned by kernel
-sets the file type as a pipe, directory or special file
-Major and minor device numbers are the two entries created if the file type is a device file.

For example, for a disk, disk controller is the major device number and the disk is the minor device is the disk.

Unix example: $ mknod <pipe name> p
Unix - How do I use poll()?
How do I use poll()? - Poll() in UNIX is used for to wait for some event on a file descriptor.........
What is a compiler? - operating system
A compiler is a program that takes a source code as an input and converts it into an object code......
Loader and linker - operating system
A loader is a program used by an operating system to load programs from a secondary to main memory so as to be executed......
Post your comment