lvm代码分析(二)

 继续分析lvm2_main:    _close_stray_fds();    base = last_path_component(argv[0]);    while (*base == /)        base++;    if (strcmp(base, "lvm") && strcmp(base, "lvm.static") &&        strcmp(base, "i
摘要由CSDN通过智能技术生成
 继续分析lvm2_main:
  1.     _close_stray_fds();
  2.     base = last_path_component(argv[0]);
  3.     while (*base == '/')
  4.         base++;
  5.     if (strcmp(base"lvm") && strcmp(base"lvm.static") &&
  6.         strcmp(base"initrd-lvm"))
  7.         alias = 1;
  8.     if (is_static && strcmp(base"lvm.static") &&
  9.         path_exists(LVM_SHARED_PATH) &&
  10.         !getenv("LVM_DID_EXEC")) {
  11.         setenv("LVM_DID_EXEC"base, 1);
  12.         execvp(LVM_SHARED_PATH, argv);
  13.         unsetenv("LVM_DID_EXEC");
  14.     }
第1行的函数_close_stray_fds(),没看懂,不过貌似和主干数据流没有多大的影响,暂且不管。希望以后多回头几次能读懂。咔咔。接下来的last_path_component(argv[0])是将输入的命令进行一些处理,最后得到命令名,下面的两个if是判断做一些相关处理。就pvcreate /dev/sda0而言,两个if都没有执行。
继续往下:
  1.     if (!(cmd = init_lvm(is_static)))
  2.         return -1;
此处调用init_lvm(is_static),is_static==0
  1. struct cmd_context *init_lvm(unsigned is_static)
  2. {
  3.     struct cmd_context *cmd;
  4.     _cmdline.the_args = &_the_args[0];
  5.     if (!(cmd = create_toolcontext(_cmdline.the_args, is_static, 0)))
  6.         return_NULL;
  7.     _init_rand();
  8.     _apply_settings(cmd);
  9.     return cmd;
  10. }
此处的_cmdline是一个静态变量
  1. static struct cmdline_context _cmdline;
而这个_the_arg[0]的赋值也着实让我见识到啥是c语言高级编程,把我最后一点自信给毁了。
  1. /*
  2.  * Table of valid switches
  3.  */
  4. static struct arg _the_args[ARG_COUNT + 1] = {
  5. #define arg(a, b, c, d, e) {b, "", "--" c, d, e, 0, NULL, 0, 0, INT64_C(0), UINT64_C(0), SIGN_NONE, PERCENT_NONE, NULL},
  6. #include "args.h"
  7. #undef arg
  8. };
在代码中,我始终没找到ARG_COUNT这个变量的定义,可能是se的问题吧。
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值