Linux mknod Command parsing

Source: Internet
Author: User

Linux mknod Command parsing

Http://www.cnblogs.com/cobbliu/archive/2011/07/05/2389014.html

The primary and secondary device numbers can be found in the./documenttation/devices.txt of the kernel source code. Of course, the location of the node does not have to be in/dev, but for ease of management It is usually specified/dev

Linux is the P552.

The person thinks that the Linux software design thought is extremely powerful, for example regards all the equipment as the file processing, greatly simplifies the programmer's burden, pays tribute to this thought the big God s!

Let's take a look at the basics of device management in Linux systems:

Our Linux operating system communicates with external devices (such as disks, CDs, etc.) through device files, and applications can open, close, and read and write these device files to read and write to the device, which is as easy as reading and writing ordinary files. Linux provides the same interface for different kinds of device files, such as read (), write (), open (), close ().

So before the system communicates with the device, the system first establishes a device file, which is stored in the/dev directory. In fact, the system has generated a lot of device files by default, but sometimes we need to manually create some new device files, this time will be used like mkdir, mknod such a command.

The standard form of Mknod is:

Mknod Devname {b | c} MAJOR MINOR

1,devname is the device file name to create, if you want to put the device files in a specific folder, you need to first use mkdir in the dev directory to create a new directory;

2, B and C represent block devices and character devices, respectively:

b means that when the system reads data from a block device, it reads the data directly from the buffer in memory without passing through the disk;

c indicates that the character device file and the device transmits data in the form of a character transmission, one character at a time, such as the printer, the terminal is the transmission of data in the form of characters;

3,major and minor represent the main device number and the secondary device number, respectively:

To manage devices, the system assigns a number to each device, and a device number consists of the main device number and the secondary device number. The main device number indicates a device of a certain kind, and the secondary device number is used to distinguish between devices of the same type. The Linux operating system assigns a 32-bit unsigned integer to the device file number, where the first 12 bits are the main device number and the last 20 bits are the secondary device number, so the main device number is not good more than 4095 when requesting the device file to the system, and the secondary device number is not good more than 2^20-1.

.

Below, we can use the Mknod command to apply for the device files.

mkdir -p/dev/cobingmknod

Linux mknod Command parsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.