device number(dev_t)

来源:互联网 发布:树莓派gpio编程 编辑:程序博客网 时间:2024/06/17 07:11

dev_t

description:
    the dev_t type in is used to hold device numbers—both the major and minor

parts.

header:
    #include

constructor:
    MKDEV(int major, int minor);

method:
    MAJOR(dev_t dev);    //obtain the major part of a dev_t
    MINOR(dev_t dev);    //obtain the minor part of a dev_t
    register_chrdev_region();    //manually obtain(register) device numbers

from the system
    alloc_chrdev_region();        //allocate a major number  by kernel
    unregister_chrdev_region();    //free the device number back to kernel

int print_dev_t(char *buffer, dev_t dev); //encode the device number into the given buffer; char *format_dev_t(char *buffer, dev_t dev); //encode the device number into the given buffer;