purples 发表于 2003-5-5 21:57:01

parse_options函数的作用是什么?

在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;
}
大家谁能告诉我这段代码是做什么用的?谢谢

Dragonfly 发表于 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.

purples 发表于 2003-5-6 10:23:27

谢谢,但我仍有点不明白,那这段函数在系统中有什么用呢?本人愚昧,万望斑竹能悉心教我,谢谢

Dragonfly 发表于 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

purples 发表于 2003-5-6 10:36:22

thanks ,i know

Dragonfly 发表于 2003-5-6 10:38:04

welcome
页: [1]
查看完整版本: parse_options函数的作用是什么?