Relationship Between/proc/devices and/dev

Source: Internet
Author: User
The device under/proc/devices/is generated by the driver, which can generate a major for mknod as the parameter.
The devices under/dev/are added by mknod. You can use this device name to access the driver.

The following script, scull_load, is part of the scull distribution. The user of a driver that is distributed in the form of a module can invoke such a script from the system'sRC. LocalFile or call it manually whenever the module is needed.


#! /Bin/sh
Module = "scull"
Device = "scull"
Mode = "664"

# Invoke insmod with all arguments we got
# And use a pathname, as newer modutils don't look in. By default
/Sbin/insmod./$ module. Ko $ * | Exit 1

# Remove stale nodes
Rm-F/dev/$ {Device} [0-3]

Major =$ (awk "\\2 2 ==\" $ module \ "{print \ $1}"/proc/devices)

Mknod/dev/$ {Device} 0 C $ major 0
Mknod/dev/$ {Device} 1 C $ major 1
Mknod/dev/$ {Device} 2 C $ major 2
Mknod/dev/$ {Device} 3 C $ major 3

# Give appropriate group/permissions, and change the group.
# Not all distributions have staff, some have "Wheel" instead.
Group = "staff"
Grep-Q '^ staff:'/etc/group | group = "Wheel"

Chgrp $ group/dev/$ {Device} [0-3]

Chmod $ mode/dev/$ {Device} [0-3]

 

Please
Q: In Linux, what is the difference between the content in the/dev/directory and that in the/proc/file devices? When I did my experiment on the target board, I found that when I loaded the driver to the board
The devices file is changed while the/dev file is not changed at all. Shouldn't the/dev/file be the device contact? Why is the device contact set for the module, /dev/has not changed
?

Thank you for your help !!!

The devices in/proc/devices/are loaded to the kernel through insmod, which generates a major for mknod as the parameter.
/Dev/*. * is added by mknod. The format is mknod device1 C/B major minor, for example, mknod DR1 C 254 0. You can use this device name to access your driver.

 

 

 

Please
Q: In Linux, what is the difference between the content in the/dev/directory and that in the/proc/file devices? I'm
When I did an experiment on the board, I found that when I loaded the driver module to the Board, there were changes in the devices file, and there was no change at all under/dev, shouldn't it be a device connection under/dev/? Why?
When the module establishes a device contact, it does not change under/dev?
Thank you for your help !!!

 

The devices in/proc/devices/are loaded to the kernel through insmod, which generates a major for mknod as the parameter.
/Dev/*. * is added by mknod. The format is mknod device1 C/B major minor, for example, mknod DR1 C 254 0. You can use this device name to access your driver.

 

 

Device File, device number # ll-A/dev in each row can see the device file, device number (master, times)
For each hardware device, the system kernel has a device driver responsible for processing it. In UNIX, device files are used to represent hardware devices. Each device driver is abstracted as a device file. In this way, a consistent file interface is provided for applications, it facilitates communication between applications and operating systems.

Traditionally, all device files are stored in the/dev directory.

The devices in/proc/devices/are loaded to the kernel through insmod, which generates a major for mknod as the parameter.
/Dev/*. * is added by mknod. The format is mknod device1 C/B major minor, for example, mknod DR1 C 254 0. You can use this device name to access your driver.

Mknod-Make block or character special files
Mknod [Option]... name type [major minor]
Option is-M.
Name Customization
Type has B, c, and P
Master device number
Device No.

The master device number is defined by/usr/src/Linux/include/Linux/major. h. A doc device is defined as follows:
# Define igel_flash_major 62

Assume that there is a command mknod Doc B 62 0:
Here, Doc is the defined name, B refers to the block device, and 0 refers to the entire Doc. If 0 is changed to 1, 1 indicates the first partition of the doc. 2 is 2nd, and so on.

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.