QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2532|回复: 5

parse_options函数的作用是什么?

[复制链接]
发表于 2003-5-5 21:57:01 | 显示全部楼层 |阅读模式
在proc_read_super(fs/proc/inode.c)中调用此函数,原型为:
static int parse_options(char *options,user_id_t *uid,gid_t *gid)
{
char *this_char,*value;

*uid = current->uid;
*gid = current->gid;
if (!options) return 1;
for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
if ((value = strchr(this_char,'=')) != NULL)
*value++ = 0;
if (!strcmp(this_char,"uid")) {
if (!value || !*value)
return 0;
*uid = simple_strtoul(value,&value,0);
if (*value)
return 0;
}
else if (!strcmp(this_char,"gid")) {
if (!value || !*value)
return 0;
*gid = simple_strtoul(value,&value,0);
if (*value)
return 0;
}
else return 1;
}
return 1;
}
大家谁能告诉我这段代码是做什么用的?谢谢
发表于 2003-5-5 22:18:13 | 显示全部楼层
please read this from man mount
Mount options for proc
   uid=value and gid=value   These options are recognized, but have no effect as far as I can see.

so this parse_option is to parse options to get uid and gid, otherwise use default current->uid and gid. should be zero here. similarly there are many parse_options in different file system types.
回复

使用道具 举报

 楼主| 发表于 2003-5-6 10:23:27 | 显示全部楼层
谢谢,但我仍有点不明白,那这段函数在系统中有什么用呢?本人愚昧,万望斑竹能悉心教我,谢谢
回复

使用道具 举报

发表于 2003-5-6 10:31:51 | 显示全部楼层
when u mount /proc fs, u may give it an option like uid=xx, gid=xx. so how to parse this option and set to correct variables in kernel, kenrel use this one.
kernel create a super block for proc fs, then check if there are options, if so, change the /proc super block uid gid info base on parsed data.

all the options u use when mount a file system will be parsed by a similar function in different fs
回复

使用道具 举报

 楼主| 发表于 2003-5-6 10:36:22 | 显示全部楼层
thanks ,i know
回复

使用道具 举报

发表于 2003-5-6 10:38:04 | 显示全部楼层
welcome
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-16 07:06 , Processed in 0.038223 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表