聪明文档网

聪明文档网

最新最全的文档下载
当前位置: 首页> mount系统调用分析

mount系统调用分析

时间:2012-11-15 17:08:13    下载该word文档

结合exofs的挂载分析mount系统调用。

比如执行命令:mount -t exofs -o pid=65536 /dev/osd0 /mnt/exofs/ exofs进行挂载。

mount系统调用的原型为:

#include

int mount(const char *source, const char *target,

const char *filesystemtype, unsigned long mountflags,

const void *data);

实际调用为:mount("/dev/osd0", "/mnt/exofs/", "exofs", MS_MGC_VAL, "pid=65536"),其中参数MS_MGC_VAL仅仅是为了兼容以前的老版本,没什么实际意义。类型为exofs,也就是在/proc/filesystems文件中列出的。

接下来就会传到内核里面来,内核里的mount系统调用(3.3内核)原型如下:

./fs/namespace.c

SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,

char __user *, type, unsigned long, flags, void __user *, data)

接下来调用:

do_mount(“/dev/osd0”, “/mnt/exofs”, “exofs”, MS_MGC_VAL, "pid=65536");

函数原型如下:

long do_mount(char *dev_name, char *dir_name, char *type_page,

unsigned long flags, void *data_page)

这里由于flagsMS_MGC_VAL,所以函数do_mount()最终调用do_new_mount()函数,原型如下:

static int do_new_mount(struct path *path, char *type, int flags,

int mnt_flags, char *name, void *data)

这里mnt_flags0name为设备名。

该函数首先调用do_kern_mount()获取虚拟文件系统挂载信息结构体struct vfsmount。该函数原型如下:

static struct vfsmount *

do_kern_mount(const char *fstype, int flags, const char *name, void *data)

该函数具体步骤如下:

1. 首先调用get_fs_type()由文件系统类型字符串获取该文件系统对应的文件系统描述符结构体struct file_system_type(这里一般是在文件系统模块插入调用register_filesystem()进行注册的)。

2. 调用vfs_kern_mount()进行实际的挂载操作,获取安装点(创建文件系统实例结构体struct vfsmount)。(实际是通过调用mount_fs()获取文件系统的根目录项,然后根据该根目录项初始化一个文件系统实例结构体struct vfsmount,并将其返回)

3. 如果上述过程没有出错,并且文件系统类型标志type->fs_flagsFS_HAS_SUBTYPE置位,并且加载时超级块为空,则调用获取子类型的超级块。

4. 调用put_filesystem()释放文件系统描述符。

函数mount_fs()的核心是调用之前特定文件系统(这里是exofs)自定义的挂载函数获取对应的根目录项。

exofs对应的挂载函数实现为exofs_mount()

免费下载 Word文档免费下载: mount系统调用分析

  • 29.8

    ¥45 每天只需1.0元
    1个月 推荐
  • 9.9

    ¥15
    1天
  • 59.8

    ¥90
    3个月

选择支付方式

  • 微信付款
郑重提醒:支付后,系统自动为您完成注册

请使用微信扫码支付(元)

订单号:
支付后,系统自动为您完成注册
遇到问题请联系 在线客服

常用手机号:
用于找回密码
图片验证码:
看不清?点击更换
短信验证码:
新密码:
 
绑定后可用手机号登录
请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系 在线客服