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;
}
大家谁能告诉我这段代码是做什么用的?谢谢 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. 谢谢,但我仍有点不明白,那这段函数在系统中有什么用呢?本人愚昧,万望斑竹能悉心教我,谢谢 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 thanks ,i know welcome
页:
[1]