Linux内核 mnt_want_write()

函数:mnt_want_write()

mnt_want_write()函数的功能是判断传入的参数vfsmount结构体是否可写。该函数工作在低等级的将要被写入数据的文件系统上,为其判断是否有可写权限。在写操作结束之后,必须得调用mnt_drop_write()函数,从而获得一个有效的引用计数。

文件包含:

#include <linux/mount.h>

函数定义:

在内核源码中的位置:linux-3.19.3/fs/namespace.c

函数定义格式:

int mnt_want_write(struct vfsmount *mnt)

输入参数说明:

  • mnt:要判断的是否有可写权限的vfsmount结构体变量,其定义及详细解释请参考酷客教程函数__mnt_is_readonly()的输入参数说明部分。

返回参数说明:

  • mnt_want_write()函数的返回值是整型变量,可能的取值是0或-EROFS,如果此结构体对应的挂载点是可写的,则返回0;否则,返回错误号-EROFS。其中宏EROFS定义在linux-3.19.3/include/uapi/asm-generic/errno-base.h中,值为30。

实例解析:

本函数实例解析参考酷客教程中的__mnt_is_readonly()函数中的实例解析。

酷客网相关文章:

赞(0)

评论 抢沙发

评论前必须登录!