注册和挂载proc
start_kernel(init/main.c)-> proc_root_init(fs/proc/root.c)此函数注册了proc文件系统,同时也进行了挂载(但是为什么在有些系统还在启动的时候使用命令"mount -t proc proc /proc" 来手动挂载呢?待解决)
proc_init_inodecache();
err = register_filesystem(&proc_fs_type);
if (err)
return;
mnt = kern_mount_data(&proc_fs_type, &init_pid_ns);
if (IS_ERR(mnt)) {
unregister_filesystem(&proc_fs_type);
return;
}
如何在驱动里面向proc文件系统下增删改查文件和目录
待续
3.注册和挂载sys
start_kernel(init/main.c)->vfs_caches_init(fs/dcatch.c)->mnt_init(fs/namespace.c)->sysfs_init(fs/sysfs/mount.c)
err = sysfs_inode_init();
if (err)
goto out_err;
err = register_filesystem(&sysfs_fs_type);
if (!err) {
sysfs_mnt = kern_mount(&sysfs_fs_type);
如何在驱动里面向proc文件系统下增删改查文件和目录
待续
4.注册和挂载nfs
static struct file_system_type nfs_fs_type = {.owner = THIS_MODULE,
.name = "nfs",
.mount = nfs_fs_mount,
.kill_sb = nfs_kill_super,
.fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
};
init_nfs_fs(fs/nfs/inode.c)->register_nfs_fs(fs/nfs/super.c)->register_filesystem(&nfs_fs_type);
在需要的时候手动挂载
如mount -t nfs 192.168.1.2:/opt/ /mnt -o nolock,tcp