在使用下列函数
int makedevs(struct makedevargs *args, struct cdev **cdev, const char *fmt, …);
struct cdev * make_dev(struct cdevsw *cdevsw, int unit, uidt uid, gidt gid, int perms, const char *fmt, …);
为设备创建cdev
结构体时,fmt
用来指定设备的名字:
The name is the expansion of fmt and following arguments as printf(9) would print it. The name determines its path under /dev or other devfs(5) mount point and may contain slash `/’ char- acters to denote subdirectories.
也就是/dev
下面节点的名字。
cdevsw
结构体中的d_name
指定的是driver
的名字:
struct cdevsw {
......
const char *d_name;
......
}
一个driver
可以用来操作多个设备。
参考资料:
MAKE_DEV。