???????????

???????????linux??????????豸?????????????豸?????豸???????????????????????????????????????????????????????????豸???????

????????Linux????????豸??????

????Linux???豸?????????????????????????豸?????????????????/dev???£?????豸???????ó??????????????д??Щ?豸??????????豸?????????????????????????????????????Щ?豸??????豸??????????豸?????????豸?????豸??????豸??????????????????豸???????豸????????????????????豸??????????豸??Linux????????????????????豸?????豸????4??

?????豸?????????

??????????У?dev_t  ????( ?? <linux/types.h>?????ж??? ) ????????豸??????????豸?????豸????????????? 2.6.x????dev_t???32λ???????и?12λ??????????豸?????20λ??????????豸???

?????? linux/types.h ??????????

????typedef __kernel_dev_t          dev_t;
????typedef __u32 __kernel_dev_t;

???????豸?????豸?????

???????д??????????????????????????豸?????豸???λ?????????????У????豸?????豸???λ???????????????????MAJOR???????豸??????MINOR??????????豸??????????????????壺??linux/kdev_t.h??

????#define MINORBITS   20                                 /*???豸??*/
????#define MINORMASK   ((1U << MINORBITS) - 1)            /*???豸??????*/
????#define MAJOR(dev)  ((unsigned int) ((dev) >> MINORBITS))  /*dev????20λ??????豸??*/
????#define MINOR(dev)  ((unsigned int) ((dev) & MINORMASK))   /*????豸????????????豸??*/

????MAJOR??dev_t???????20λ????????豸???MINOR??dev_t???12λ??????????豸???????????????豸?????豸???????豸???????dev_t??????ú?MKDEV???????????????

????#define MKDEV(ma??mi) (((ma) << MINORBITS) | (mi))

????MKDEV?????豸???ma??????20λ?????????豸???mi?????????豸??

???????????豸?????????????豸?????豸????????

????Linux???????????????????????豸???????????豸????????????????????豸??????

????????????????????豸???key???????????????????????????????????豸???豸??????????????????????豸????????????????豸?????????????????????豸???????豸?????????????д??????????????????????????????????豸??????????????????豸?????????????????????豸????????????????????????????????????????豸????????顣??????????

?1????ó??????open?????????豸????????????