chrdevs数组
chrdevs数组是一张device_struct结构类型的表,所有的字符设备文件的名称以及相关的file_operation结构描述符都包含在该表中,device_struct和chrdevs数组都在fs/devics.c中定义。
fs/devices.c
struct device_struct{
const char *name;
struct file_operations *fops;
};
static struct device_struct chrdevs[MAX_CHRDEVS];
其中name是某类设备的名字,fops是指向file_operation机构体的指针。
Chrdevs数组包含着255个元素,每一个元素对应一个可能的主设备号,其中主设备号255是为将来的拓展而保留的。表的第一项为空,因为没有一个设备文件主设备号为0。