免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2809 | 回复: 0
打印 上一主题 下一主题

[系统管理] __setup("init=", init_setup); [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-09-04 09:14 |只看该作者 |倒序浏览
本帖最后由 313675178 于 2012-09-04 10:04 编辑

在看linux内核时,有如下函数
__setup("init=", init_setup);

有查找到#define __setup(str, fn)                                        \
        __setup_param(str, fn, fn, 0)

#define __setup_param(str, unique_id, fn, early)                        \
        static char __setup_str_##unique_id[] __initdata = str;        \
        static struct obs_kernel_param __setup_##unique_id        \
                __attribute_used__                                \
                __attribute__((__section__(".init.setup")))        \
                __attribute__((aligned((sizeof(long)))))        \
                = { __setup_str_##unique_id, fn, early }


struct obs_kernel_param {
const char *str;
int (*setup_func)(char *);
int early;
};

网上说:
变量__setup_root_dev_setup_id的三个成员分别被初始化为:

__setup_str_root_dev_setup_id --> 前面定义的字符数组变量,初始内容为"root="。

root_dev_setup --> 通过宏传过来的处理函数。

0 -->常量0,该成员的作用以后分析。

我知道root_dev_setup是传过来的函数,为什么他就是处理__setup_str_root_dev_setup_id变量的函数?

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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP