Arrange the chief account

Source: Internet
Author: User

The best way to arrange the editor number is to use dynamic allocation by default, and leave the option permission to specify the editor number during loading, or even during compilation. scull works in this way; it uses a global variable scull_major to hold the selected number (there is also a scull_minor number ). this variable is initialized to scull_major, which is defined in scull. h. the default value of scull_major in the released source code is 0, which means "Dynamic Allocation ". you can accept the default value or select a special editor number, modify the macro definition before compilation, or specify a value for scull_major on the insmod command line. finally, by using the scull_load script, you can pass parameters to insmod in the command line of scull_load.

This is the code that we use in scull's source code to obtain the editor ID:

If (scull_major) {Dev = mkdev (scull_major, scull_minor); Result = equals (Dev, scull_nr_devs, "scull");} else {result = equals (& Dev, scull_minor, scull_nr_devs, "scull"); scull_major = major (Dev);} If (result <0) {printk (kern_warning "scull: Can't Get Major % d \ n ", scull_major); return result ;}

Almost all examples used in this book use similar code to distribute their editor numbers.

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.