#include <stdio.h>
#include <yaml.h>
-static char * lcfg_devname;
+static char *lcfg_devname;
int lcfg_set_devname(char *name)
{
- char *ptr;
- int digit = 1;
-
- if (name) {
- if (lcfg_devname)
- free(lcfg_devname);
- /* quietly strip the unnecessary '$' */
- if (*name == '$' || *name == '%')
- name++;
-
- ptr = name;
- while (*ptr != '\0') {
- if (!isdigit(*ptr)) {
- digit = 0;
- break;
- }
- ptr++;
- }
-
- if (digit) {
- /* We can't translate from dev # to name */
- lcfg_devname = NULL;
- } else {
- lcfg_devname = strdup(name);
- }
- } else {
- lcfg_devname = NULL;
- }
- return 0;
+ char *ptr;
+ int digit = 1;
+
+ if (name) {
+ if (lcfg_devname)
+ free(lcfg_devname);
+ /* quietly strip the unnecessary '$' */
+ if (*name == '$' || *name == '%')
+ name++;
+
+ ptr = name;
+ while (*ptr != '\0') {
+ if (!isdigit(*ptr)) {
+ digit = 0;
+ break;
+ }
+ ptr++;
+ }
+
+ if (digit) {
+ /* We can't translate from dev # to name */
+ lcfg_devname = NULL;
+ } else {
+ lcfg_devname = strdup(name);
+ }
+ } else {
+ lcfg_devname = NULL;
+ }
+ return 0;
}
-char * lcfg_get_devname(void)
+char *lcfg_get_devname(void)
{
- return lcfg_devname;
+ return lcfg_devname;
}
int jt_lcfg_device(int argc, char **argv)
{
- return jt_obd_device(argc, argv);
+ return jt_obd_device(argc, argv);
}
static int jt_lcfg_ioctl(struct lustre_cfg_bufs *bufs, char *arg, int cmd)
int rc;
lcfg = malloc(lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen));
- if (lcfg == NULL) {
+ if (!lcfg) {
rc = -ENOMEM;
} else {
lustre_cfg_init(lcfg, cmd, bufs);
int jt_lcfg_attach(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
- int rc;
+ struct lustre_cfg_bufs bufs;
+ int rc;
- if (argc != 4)
- return CMD_HELP;
+ if (argc != 4)
+ return CMD_HELP;
- lustre_cfg_bufs_reset(&bufs, NULL);
+ lustre_cfg_bufs_reset(&bufs, NULL);
- lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
- lustre_cfg_bufs_set_string(&bufs, 0, argv[2]);
- lustre_cfg_bufs_set_string(&bufs, 2, argv[3]);
+ lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
+ lustre_cfg_bufs_set_string(&bufs, 0, argv[2]);
+ lustre_cfg_bufs_set_string(&bufs, 2, argv[3]);
rc = jt_lcfg_ioctl(&bufs, argv[0], LCFG_ATTACH);
if (rc == 0)
int jt_lcfg_setup(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
- int i;
+ struct lustre_cfg_bufs bufs;
+ int i;
- if (lcfg_devname == NULL) {
- fprintf(stderr, "%s: please use 'device name' to set the "
- "device name for config commands.\n",
- jt_cmdname(argv[0]));
- return -EINVAL;
- }
+ if (!lcfg_devname) {
+ fprintf(stderr,
+ "%s: please use 'device name' to set the device name for config commands.\n",
+ jt_cmdname(argv[0]));
+ return -EINVAL;
+ }
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
- if (argc > 6)
- return CMD_HELP;
+ if (argc > 6)
+ return CMD_HELP;
- for (i = 1; i < argc; i++) {
- lustre_cfg_bufs_set_string(&bufs, i, argv[i]);
- }
+ for (i = 1; i < argc; i++)
+ lustre_cfg_bufs_set_string(&bufs, i, argv[i]);
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_SETUP);
}
int jt_obd_detach(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
+ struct lustre_cfg_bufs bufs;
- if (lcfg_devname == NULL) {
- fprintf(stderr, "%s: please use 'device name' to set the "
- "device name for config commands.\n",
- jt_cmdname(argv[0]));
- return -EINVAL;
- }
+ if (!lcfg_devname) {
+ fprintf(stderr,
+ "%s: please use 'device name' to set the device name for config commands.\n",
+ jt_cmdname(argv[0]));
+ return -EINVAL;
+ }
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
- if (argc != 1)
- return CMD_HELP;
+ if (argc != 1)
+ return CMD_HELP;
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DETACH);
}
int jt_obd_cleanup(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
- char force = 'F';
- char failover = 'A';
- char flags[3] = { 0 };
- int flag_cnt = 0, n;
-
- if (lcfg_devname == NULL) {
- fprintf(stderr, "%s: please use 'device name' to set the "
- "device name for config commands.\n",
- jt_cmdname(argv[0]));
- return -EINVAL;
- }
-
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
-
- if (argc < 1 || argc > 3)
- return CMD_HELP;
-
- /* we are protected from overflowing our buffer by the argc
- * check above
- */
- for (n = 1; n < argc; n++) {
- if (strcmp(argv[n], "force") == 0) {
- flags[flag_cnt++] = force;
- } else if (strcmp(argv[n], "failover") == 0) {
- flags[flag_cnt++] = failover;
+ struct lustre_cfg_bufs bufs;
+ char force = 'F';
+ char failover = 'A';
+ char flags[3] = { 0 };
+ int flag_cnt = 0, n;
+
+ if (!lcfg_devname) {
+ fprintf(stderr,
+ "%s: please use 'device name' to set the device name for config commands.\n",
+ jt_cmdname(argv[0]));
+ return -EINVAL;
+ }
+
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+
+ if (argc < 1 || argc > 3)
+ return CMD_HELP;
+
+ /*
+ * we are protected from overflowing our buffer by the argc
+ * check above
+ */
+ for (n = 1; n < argc; n++) {
+ if (strcmp(argv[n], "force") == 0) {
+ flags[flag_cnt++] = force;
+ } else if (strcmp(argv[n], "failover") == 0) {
+ flags[flag_cnt++] = failover;
} else {
fprintf(stderr, "unknown option: %s\n", argv[n]);
return CMD_HELP;
}
}
- if (flag_cnt) {
- lustre_cfg_bufs_set_string(&bufs, 1, flags);
- }
+ if (flag_cnt)
+ lustre_cfg_bufs_set_string(&bufs, 1, flags);
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_CLEANUP);
}
struct lustre_cfg *lcfg;
lustre_cfg_bufs_reset(&bufs, lcfg_devname);
- if (uuid != NULL)
+ if (uuid)
lustre_cfg_bufs_set_string(&bufs, 1, uuid);
lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
- if (lcfg == NULL) {
+ if (!lcfg) {
rc = -ENOMEM;
} else {
lustre_cfg_init(lcfg, LCFG_ADD_UUID, &bufs);
rc = lcfg_ioctl(func, OBD_DEV_ID, lcfg);
free(lcfg);
}
- if (rc) {
- fprintf(stderr, "IOC_PORTAL_ADD_UUID failed: %s\n",
- strerror(errno));
- return -1;
- }
+ if (rc) {
+ fprintf(stderr, "IOC_PORTAL_ADD_UUID failed: %s\n",
+ strerror(errno));
+ return -1;
+ }
- if (uuid != NULL)
+ if (uuid)
printf("Added uuid %s: %s\n", uuid, libcfs_nid2str(nid));
return 0;
int jt_lcfg_add_uuid(int argc, char **argv)
{
- lnet_nid_t nid;
+ lnet_nid_t nid;
- if (argc != 3) {
- return CMD_HELP;
- }
+ if (argc != 3)
+ return CMD_HELP;
- nid = libcfs_str2nid(argv[2]);
- if (nid == LNET_NID_ANY) {
- fprintf (stderr, "Can't parse NID %s\n", argv[2]);
- return (-1);
- }
+ nid = libcfs_str2nid(argv[2]);
+ if (nid == LNET_NID_ANY) {
+ fprintf(stderr, "Can't parse NID %s\n", argv[2]);
+ return (-1);
+ }
- return do_add_uuid(argv[0], argv[1], nid);
+ return do_add_uuid(argv[0], argv[1], nid);
}
int jt_lcfg_del_uuid(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
+ struct lustre_cfg_bufs bufs;
- if (argc != 2) {
- fprintf(stderr, "usage: %s <uuid>\n", argv[0]);
- return 0;
- }
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s <uuid>\n", argv[0]);
+ return 0;
+ }
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
- if (strcmp (argv[1], "_all_"))
- lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+ if (strcmp(argv[1], "_all_"))
+ lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DEL_UUID);
}
int jt_lcfg_del_mount_option(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
+ struct lustre_cfg_bufs bufs;
- if (argc != 2)
- return CMD_HELP;
+ if (argc != 2)
+ return CMD_HELP;
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
- /* profile name */
- lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
+ /* profile name */
+ lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DEL_MOUNTOPT);
}
int jt_lcfg_set_timeout(int argc, char **argv)
{
- int rc;
- struct lustre_cfg_bufs bufs;
- struct lustre_cfg *lcfg;
-
- fprintf(stderr, "%s has been deprecated. Use conf_param instead.\n"
- "e.g. conf_param lustre-MDT0000 obd_timeout=50\n",
- jt_cmdname(argv[0]));
- return CMD_HELP;
+ int rc;
+ struct lustre_cfg_bufs bufs;
+ struct lustre_cfg *lcfg;
+ fprintf(stderr,
+ "%s has been deprecated. Use conf_param instead.\ne.g. conf_param lustre-MDT0000 obd_timeout=50\n",
+ jt_cmdname(argv[0]));
+ return CMD_HELP;
- if (argc != 2)
- return CMD_HELP;
+ if (argc != 2)
+ return CMD_HELP;
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
- if (lcfg == NULL) {
+ if (!lcfg) {
rc = -ENOMEM;
} else {
lustre_cfg_init(lcfg, LCFG_SET_TIMEOUT, &bufs);
rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
free(lcfg);
}
- if (rc < 0) {
- fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
- strerror(rc = errno));
- }
- return rc;
+ if (rc < 0) {
+ fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
+ strerror(rc = errno));
+ }
+ return rc;
}
int jt_lcfg_add_conn(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
- struct lustre_cfg *lcfg;
- int priority;
- int rc;
+ struct lustre_cfg_bufs bufs;
+ struct lustre_cfg *lcfg;
+ int priority;
+ int rc;
- if (argc == 2)
- priority = 0;
- else if (argc == 3)
- priority = 1;
- else
- return CMD_HELP;
+ if (argc == 2)
+ priority = 0;
+ else if (argc == 3)
+ priority = 1;
+ else
+ return CMD_HELP;
- if (lcfg_devname == NULL) {
- fprintf(stderr, "%s: please use 'device name' to set the "
- "device name for config commands.\n",
- jt_cmdname(argv[0]));
- return -EINVAL;
- }
+ if (!lcfg_devname) {
+ fprintf(stderr,
+ "%s: please use 'device name' to set the device name for config commands.\n",
+ jt_cmdname(argv[0]));
+ return -EINVAL;
+ }
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
- lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
+ lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
- if (lcfg == NULL) {
+ if (!lcfg) {
rc = -ENOMEM;
} else {
lustre_cfg_init(lcfg, LCFG_ADD_CONN, &bufs);
rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
free(lcfg);
}
- if (rc < 0) {
- fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
- strerror(rc = errno));
- }
+ if (rc < 0) {
+ fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
+ strerror(rc = errno));
+ }
- return rc;
+ return rc;
}
int jt_lcfg_del_conn(int argc, char **argv)
{
- struct lustre_cfg_bufs bufs;
+ struct lustre_cfg_bufs bufs;
- if (argc != 2)
- return CMD_HELP;
+ if (argc != 2)
+ return CMD_HELP;
- if (lcfg_devname == NULL) {
- fprintf(stderr, "%s: please use 'device name' to set the "
- "device name for config commands.\n",
- jt_cmdname(argv[0]));
- return -EINVAL;
- }
+ if (!lcfg_devname) {
+ fprintf(stderr,
+ "%s: please use 'device name' to set the device name for config commands.\n",
+ jt_cmdname(argv[0]));
+ return -EINVAL;
+ }
- lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+ lustre_cfg_bufs_reset(&bufs, lcfg_devname);
- /* connection uuid */
- lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
+ /* connection uuid */
+ lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DEL_MOUNTOPT);
}
struct lustre_cfg_bufs bufs;
int i;
- if (argc >= LUSTRE_CFG_MAX_BUFCOUNT)
- return CMD_HELP;
+ if (argc >= LUSTRE_CFG_MAX_BUFCOUNT)
+ return CMD_HELP;
- lustre_cfg_bufs_reset(&bufs, NULL);
+ lustre_cfg_bufs_reset(&bufs, NULL);
- for (i = 1; i < argc; i++) {
- lustre_cfg_bufs_set_string(&bufs, i, argv[i]);
- }
+ for (i = 1; i < argc; i++)
+ lustre_cfg_bufs_set_string(&bufs, i, argv[i]);
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_PARAM);
}
int lcfg_setparam_perm(char *func, char *buf)
{
- int rc = 0;
+ int rc = 0;
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
lustre_cfg_bufs_reset(&bufs, NULL);
- /* This same command would be executed on all nodes, many
+ /*
+ * This same command would be executed on all nodes, many
* of which should fail (silently) because they don't have
* that proc file existing locally. There would be no
* preprocessing on the MGS to try to figure out which
lustre_cfg_bufs_set_string(&bufs, 1, buf);
-
lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount,
bufs.lcfg_buflen));
- if (lcfg == NULL) {
+ if (!lcfg) {
rc = -ENOMEM;
fprintf(stderr, "error: allocating lcfg for %s: %s\n",
jt_cmdname(func), strerror(rc));
return rc;
}
-/* Param set to single log file, used by all clients and servers.
+/*
+ * Param set to single log file, used by all clients and servers.
* This should be loaded after the individual config logs.
* Called from set param with -P option.
*/
return CMD_HELP;
for (i = first_param, rc = 0; i < argc; i++) {
-
len = strlen(argv[i]);
buf = argv[i];
/* put an '=' on the end in case it doesn't have one */
if (popt->po_delete && argv[i][len - 1] != '=') {
buf = malloc(len + 1);
- if (buf == NULL) {
+ if (!buf) {
rc = -ENOMEM;
break;
}
/* We could put other opcodes here. */
lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
- if (lcfg == NULL) {
+ if (!lcfg) {
rc = -ENOMEM;
} else {
lustre_cfg_init(lcfg, LCFG_PARAM, &bufs);
return rc;
}
-/* Param set in config log on MGS */
-/* conf_param key=value */
-/* Note we can actually send mgc conf_params from clients, but currently
+/*
+ * Param set in config log on MGS
+ * conf_param key=value
+ *
+ * Note we can actually send mgc conf_params from clients, but currently
* that's only done for default file striping (see ll_send_mgc_param),
- * and not here. */
-/* After removal of a parameter (-d) Lustre will use the default
- * AT NEXT REBOOT, not immediately. */
+ * and not here.
+ *
+ * After removal of a parameter (-d) Lustre will use the default
+ * AT NEXT REBOOT, not immediately.
+ */
int jt_lcfg_confparam(int argc, char **argv)
{
int rc;
/* for delete, make it "<param>=\0" */
buf = malloc(strlen(argv[optind]) + 2);
- if (buf == NULL) {
+ if (!buf) {
rc = -ENOMEM;
goto out;
}
/* Take the original filename string and chop off the glob addition */
tmp = strstr(filename, "/lustre/");
- if (tmp == NULL) {
+ if (!tmp) {
tmp = strstr(filename, "/lnet/");
- if (tmp != NULL)
+ if (tmp)
tmp += strlen("/lnet/");
} else {
tmp += strlen("/lustre/");
/* Allocate return string */
param_name = strdup(tmp);
- if (param_name == NULL)
+ if (!param_name)
return NULL;
/* replace '/' with '.' to match conf_param and sysctl */
suffix_len = strlen(suffix);
tmp = realloc(param_name, suffix_len + strlen(param_name) + 1);
- if (tmp != NULL) {
+ if (tmp) {
param_name = tmp;
strncat(param_name, suffix,
strlen(param_name) + suffix_len);
/* BEWARE - kernel definition of strnchr has args in different order! */
static char *strnchr(const char *p, char c, size_t n)
{
- if (!p)
- return (0);
-
- while (n-- > 0) {
- if (*p == c)
- return ((char *)p);
- p++;
- }
- return (0);
+ if (!p)
+ return (0);
+
+ while (n-- > 0) {
+ if (*p == c)
+ return ((char *)p);
+ p++;
+ }
+ return (0);
}
/**
/* get rid of '\', glob doesn't like it */
tmp = strrchr(path, '\\');
- if (tmp != NULL) {
+ if (tmp) {
char *tail = path + strlen(path);
while (tmp != path) {
/* Does this path contain a NID string ? */
tmp = strchr(path, '@');
- if (tmp != NULL) {
+ if (tmp) {
char *find_nid = strdup(path);
lnet_nid_t nid;
- if (find_nid == NULL)
+ if (!find_nid)
return -ENOMEM;
- /* First we need to chop off rest after nid string.
- * Since find_nid is a clone of path it better have
- * '@' */
+ /*
+ * First we need to chop off rest after nid string.
+ * Since find_nid is a clone of path it better have '@'
+ */
tmp = strchr(find_nid, '@');
tmp = strchr(tmp, '.');
- if (tmp != NULL)
+ if (tmp)
*tmp = '\0';
/* Now chop off the front. */
nid = libcfs_str2nid(tmp);
if (nid != LNET_NID_ANY) {
nidstr = libcfs_nid2str(nid);
- if (nidstr == NULL)
+ if (!nidstr)
return -EINVAL;
break;
}
if (!strncmp(tmp, "MGC", 3))
tmp += 3;
- /* There exist cases where some of the subdirectories of the
+ /*
+ * There exist cases where some of the subdirectories of the
* the parameter tree has embedded in its name a NID string.
* This means that it is possible that these subdirectories
* could have actual '.' in its name. If this is the case we
- * don't want to blindly replace the '.' with '/'. */
- if (nidstr != NULL) {
+ * don't want to blindly replace the '.' with '/'.
+ */
+ if (nidstr) {
char *match = strstr(tmp, nidstr);
if (tmp == match)
int fd, rc = 0;
ssize_t count;
- if (value == NULL)
+ if (!value)
return -EINVAL;
/* Write the new value to the file */
}
} else if (count < strlen(value)) { /* Truncate case */
rc = -EINVAL;
- fprintf(stderr, "error: set_param: setting %s=%s: "
- "wrote only %zd\n", path, value, count);
+ fprintf(stderr,
+ "error: set_param: setting %s=%s: wrote only %zd\n",
+ path, value, count);
} else if (popt->po_show_path) {
printf("%s=%s\n", param_name, value);
}
}
dup_cache = calloc(paths.gl_pathc, sizeof(char *));
- if (dup_cache == NULL) {
+ if (!dup_cache) {
rc = -ENOMEM;
fprintf(stderr,
"error: %s: allocating '%s' dup_cache[%zd]: %s\n",
for (i = 0; i < paths.gl_pathc; i++) {
char *param_name = NULL, *tmp;
- char pathname[PATH_MAX], param_dir[PATH_MAX+2];
+ char pathname[PATH_MAX], param_dir[PATH_MAX + 2];
struct stat st;
int rc2, j;
continue;
param_name = display_name(paths.gl_pathv[i], &st, popt);
- if (param_name == NULL) {
+ if (!param_name) {
fprintf(stderr,
"error: %s: generating name for '%s': %s\n",
opname, paths.gl_pathv[i], strerror(ENOMEM));
* small amounts of data, less than a page in size, are
* located under /sys/fs/lustre and in the case of large
* parameter data files, think stats for example, are
- * located in the debugfs tree. Since the files are split
- * across two trees the directories are often duplicated
- * which means these directories are listed twice which
- * leads to duplicate output to the user. To avoid
- * scanning a directory twice we have to cache any
- * directory and check if a search has been requested
- * twice.
+ * located in the debugfs tree. Since the files are
+ * split across two trees the directories are often
+ * duplicated which means these directories are listed
+ * twice which leads to duplicate output to the user.
+ * To avoid scanning a directory twice we have to cache
+ * any directory and check if a search has been
+ * requested twice.
*/
for (j = 0; j < dup_count; j++) {
if (!strcmp(dup_cache[j], param_name))
break;
}
- /* Only directories are searched recursively if
- * requested by the user */
+ /*
+ * Only directories are searched recursively if
+ * requested by the user
+ */
if (!S_ISDIR(st.st_mode) || !popt->po_recursive) {
free(param_name);
param_name = NULL;
memset(¶m_dir, '\0', sizeof(param_dir));
/* Shouldn't happen but just in case */
- if (tmp == NULL) {
+ if (!tmp) {
if (rc == 0)
rc = -EINVAL;
continue;
rc2 = snprintf(pathname, sizeof(pathname), "%s/*", tmp);
if (rc2 < 0) {
- /* snprintf() should never an error, and if it does
- * there isn't much point trying to use fprintf() */
+ /*
+ * snprintf() should never an error, and if it does
+ * there isn't much point trying to use fprintf()
+ */
continue;
}
if (rc2 >= sizeof(pathname)) {
}
rc2 = param_display(&popt, path, NULL,
- popt.po_only_path ? LIST_PARAM : GET_PARAM);
+ popt.po_only_path ? LIST_PARAM : GET_PARAM);
if (rc2 < 0) {
if (rc == 0)
rc = rc2;
*/
int jt_nodemap_info(int argc, char **argv)
{
- const char usage_str[] = "usage: nodemap_info "
- "[list|nodemap_name|all]\n";
- struct param_opts popt;
- int rc = 0;
+ const char usage_str[] = "usage: nodemap_info [list|nodemap_name|all]\n";
+ struct param_opts popt;
+ int rc = 0;
memset(&popt, 0, sizeof(popt));
popt.po_show_path = 1;
snprintf(pattern, sizeof(pattern), "nodemap/%s/*", argv[1]);
rc = param_display(&popt, pattern, NULL, LIST_PARAM);
if (rc == -ESRCH)
- fprintf(stderr, "error: nodemap_info: cannot find "
- "nodemap %s\n", argv[1]);
+ fprintf(stderr,
+ "error: nodemap_info: cannot find nodemap %s\n",
+ argv[1]);
}
return rc;
}
static int setparam_cmdline(int argc, char **argv, struct param_opts *popt)
{
- int ch;
+ int ch;
- popt->po_show_path = 1;
- popt->po_only_path = 0;
- popt->po_show_type = 0;
- popt->po_recursive = 0;
+ popt->po_show_path = 1;
+ popt->po_only_path = 0;
+ popt->po_show_type = 0;
+ popt->po_recursive = 0;
popt->po_perm = 0;
popt->po_delete = 0;
popt->po_file = 0;
while ((ch = getopt(argc, argv, "nPdF")) != -1) {
- switch (ch) {
- case 'n':
- popt->po_show_path = 0;
- break;
+ switch (ch) {
+ case 'n':
+ popt->po_show_path = 0;
+ break;
case 'P':
popt->po_perm = 1;
break;
case 'F':
popt->po_file = 1;
break;
- default:
- return -1;
- }
- }
- return optind;
+ default:
+ return -1;
+ }
+ }
+ return optind;
}
enum paramtype {
PT_CONFPARAM
};
-
#define PS_NONE 0
#define PS_PARAM_FOUND 1
#define PS_PARAM_SET 2
{ PS_NONE, "none" }
};
-
void conf_to_set_param(enum paramtype confset, const char *param,
const char *device, char *buf,
int bufsize)
* sys.* params are top level, we just need to trim the sys.
*/
tmp = strstr(param, "sys.");
- if (tmp != NULL) {
+ if (tmp) {
tmp += 4;
strncpy(buf, tmp, bufsize);
return;
int size = strlen(parameter) + strlen(value) + 2;
char *buf = malloc(size);
- if (buf == NULL) {
+ if (!buf) {
rc = 2;
break;
}
return CMD_HELP;
if (popt.po_perm)
- /* We can't delete parameters that were
- * set with old conf_param interface */
+ /*
+ * We can't delete parameters that were
+ * set with old conf_param interface
+ */
return jt_lcfg_setparam_perm(argc, argv, &popt);
if (popt.po_file)
for (i = index; i < argc; i++) {
int rc2;
- path = argv[i];
+ path = argv[i];
value = strchr(path, '=');
- if (value != NULL) {
+ if (value) {
/* format: set_param a=b */
*value = '\0';
value++;
if (rc == 0)
rc = -EINVAL;
break;
- } else {
- value = argv[i];
}
+ value = argv[i];
}
rc2 = clean_path(&popt, path);