X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=inline;f=lustre%2Futils%2Fobd.c;h=f029e925647eff3a392d9f07f5e304adf3c86b4c;hb=8633aaba2da245bc62b876e535e7ac26385e1385;hp=07fb7a9f2dbd3961ef6a0005d682bddba735d539;hpb=424e56abd685c5eabc6a276154dec1c031cf5044;p=fs%2Flustre-release.git diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 07fb7a9..f029e92 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -69,7 +69,7 @@ #include #include -#include +#include #include #include @@ -1150,18 +1150,21 @@ int jt_obd_md_common(int argc, char **argv, int cmd) char *name = NULL; struct jt_fid_space fid_space = {0}; int version = 0; - struct option long_opts[] = { - {"child_base_id", required_argument, 0, 'b'}, - {"stripe_count", required_argument, 0, 'c'}, - {"parent_basedir", required_argument, 0, 'd'}, - {"parent_dircount", required_argument, 0, 'D'}, - {"stripe_index", required_argument, 0, 'i'}, - {"mode", required_argument, 0, 'm'}, - {"count", required_argument, 0, 'n'}, - {"time", required_argument, 0, 't'}, - {"version", no_argument, 0, 'v'}, - {0, 0, 0, 0} - }; + struct option long_opts[] = { + { .val = 'b', .name = "child_base_id", + .has_arg = required_argument }, + { .val = 'c', .name = "stripe_count", + .has_arg = required_argument }, + { .val = 'd', .name = "parent_basedir", + .has_arg = required_argument }, + { .val = 'D', .name = "parent_dircount", + .has_arg = required_argument }, + { .val = 'i', .name = "stripe_index", .has_arg = required_argument }, + { .val = 'm', .name = "mode", .has_arg = required_argument }, + { .val = 'n', .name = "count", .has_arg = required_argument }, + { .val = 't', .name = "time", .has_arg = required_argument }, + { .val = 'v', .name = "version", .has_arg = no_argument }, + { .name = NULL } }; while ((c = getopt_long(argc, argv, "b:c:d:D:m:n:t:v", long_opts, NULL)) >= 0) { @@ -2653,14 +2656,13 @@ static int llog_cancel_parse_optional(int argc, char **argv, struct obd_ioctl_data *data) { int cOpt; - const char *const short_options = "c:l:i:h"; - const struct option long_options[] = { - {"catalog", required_argument, NULL, 'c'}, - {"log_id", required_argument, NULL, 'l'}, - {"log_idx", required_argument, NULL, 'i'}, - {"help", no_argument, NULL, 'h'}, - {NULL, 0, NULL, 0} - }; + const char *const short_opts = "c:l:i:h"; + const struct option long_opts[] = { + { .val = 'c', .name = "catalog", .has_arg = required_argument }, + { .val = 'h', .name = "help", .has_arg = no_argument }, + { .val = 'i', .name = "log_idx", .has_arg = required_argument }, + { .val = 'l', .name = "log_id", .has_arg = required_argument }, + { .name = NULL } }; /* sanity check */ if (!data || argc <= 1) { @@ -2668,8 +2670,8 @@ static int llog_cancel_parse_optional(int argc, char **argv, } /*now process command line arguments*/ - while ((cOpt = getopt_long(argc, argv, short_options, - long_options, NULL)) != -1) { + while ((cOpt = getopt_long(argc, argv, short_opts, + long_opts, NULL)) != -1) { switch (cOpt) { case 'c': data->ioc_inllen1 = strlen(optarg) + 1; @@ -3117,9 +3119,11 @@ static int pool_cmd(enum lcfg_command_type cmd, if (ostname != NULL) lustre_cfg_bufs_set_string(&bufs, 2, ostname); - lcfg = lustre_cfg_new(cmd, &bufs); + + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) return -ENOMEM; + lustre_cfg_init(lcfg, cmd, &bufs); memset(&data, 0, sizeof(data)); rc = data.ioc_dev = get_mgs_device(); @@ -3136,14 +3140,14 @@ static int pool_cmd(enum lcfg_command_type cmd, if (rc) { fprintf(stderr, "error: %s: invalid ioctl\n", jt_cmdname(cmdname)); - lustre_cfg_free(lcfg); + free(lcfg); return rc; } rc = l_ioctl(OBD_DEV_ID, OBD_IOC_POOL, buf); out: if (rc) rc = -errno; - lustre_cfg_free(lcfg); + free(lcfg); return rc; } @@ -3183,9 +3187,10 @@ static int nodemap_cmd(enum lcfg_command_type cmd, void *ret_data, } va_end(ap); - lcfg = lustre_cfg_new(cmd, &bufs); + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) return -ENOMEM; + lustre_cfg_init(lcfg, cmd, &bufs); memset(&data, 0, sizeof(data)); rc = data.ioc_dev = get_mgs_device(); @@ -3223,7 +3228,7 @@ static int nodemap_cmd(enum lcfg_command_type cmd, void *ret_data, memcpy(ret_data, data.ioc_pbuf1, ret_size); } out: - lustre_cfg_free(lcfg); + free(lcfg); return rc; } @@ -3433,28 +3438,15 @@ int jt_nodemap_add_range(int argc, char **argv) int rc = 0; int c; - static struct option long_options[] = { - { - .name = "name", - .has_arg = required_argument, - .flag = 0, - .val = 'n', - }, - { - .name = "range", - .has_arg = required_argument, - .flag = 0, - .val = 'r', - }, - { - NULL - } - }; + static struct option long_opts[] = { + { .val = 'n', .name = "name", .has_arg = required_argument }, + { .val = 'r', .name = "range", .has_arg = required_argument }, + { .name = NULL } }; INIT_LIST_HEAD(&nidlist); while ((c = getopt_long(argc, argv, "n:r:", - long_options, NULL)) != -1) { + long_opts, NULL)) != -1) { switch (c) { case 'n': nodemap_name = optarg; @@ -3607,26 +3599,13 @@ int jt_nodemap_set_fileset(int argc, char **argv) int rc = 0; int c; - static struct option long_options[] = { - { - .name = "name", - .has_arg = required_argument, - .flag = 0, - .val = 'n', - }, - { - .name = "fileset", - .has_arg = required_argument, - .flag = 0, - .val = 'f', - }, - { - NULL - } - }; + static struct option long_opts[] = { + { .val = 'f', .name = "fileset", .has_arg = required_argument }, + { .val = 'n', .name = "name", .has_arg = required_argument }, + { .name = NULL } }; while ((c = getopt_long(argc, argv, "n:f:", - long_options, NULL)) != -1) { + long_opts, NULL)) != -1) { switch (c) { case 'n': nodemap_name = optarg; @@ -3677,32 +3656,14 @@ int jt_nodemap_modify(int argc, char **argv) char *param = NULL; char *value = NULL; - static struct option long_options[] = { - { - .name = "name", - .has_arg = required_argument, - .flag = 0, - .val = 'n', - }, - { - .name = "property", - .has_arg = required_argument, - .flag = 0, - .val = 'p', - }, - { - .name = "value", - .has_arg = required_argument, - .flag = 0, - .val = 'v', - }, - { - NULL - } - }; + static struct option long_opts[] = { + { .val = 'n', .name = "name", .has_arg = required_argument }, + { .val = 'p', .name = "property", .has_arg = required_argument }, + { .val = 'v', .name = "value", .has_arg = required_argument }, + { .name = NULL } }; while ((c = getopt_long(argc, argv, "n:p:v:", - long_options, NULL)) != -1) { + long_opts, NULL)) != -1) { switch (c) { case 'n': nodemap_name = optarg;