4、mtd_part 结构体分析 此结构定义在 ../drivers/mtd/mtdpart.c 中
- struct mtd_part {
- struct mtd_info mtd; // 分区的信息(大部分由其 master 决定)
- struct mtd_info *master; // 该分区的主分区
- uint64_t offset; // 分区的偏移地址
- struct list_head list; // 分区号
- };
其大部分成员有 mtd_part—> 决定,各种函数也指向主分区的相应函数。
5、mtd_partition 结构体分析 该结构体定义在 include/linux/mtd/partitions.h 中
- struct mtd_partition {
- char *name; /* identifier string */ // 标识字符串
- uint64_t size; /* partition size */ // 分区大小
- uint64_t offset; /* offset within the master MTD space */ // 主MTD空间内的偏移量
- uint32_t mask_flags; /* master MTD flags to mask out for this partition */ // 掩码标志
- struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only)*/
- };
mtd_partttion 会在MTD 原始设备层调用 add_mtd_partitons() 时传递分区信息,并通过下面两个函数进行注册和注销 分区:
- int add_mtd_partitions( struct mtd_info *master, struct mtd_partition *parts, int nbparts);
- int del_mtd_partitions (struct mtd_info *master);
