struct mgs_direntry *de;
char *key;
int rc, key_sz;
+ size_t suffix_len = sizeof(".bak") - 1;
INIT_LIST_HEAD(log_list);
}
/* filter out ".bak" files */
- /* sizeof(".bak") - 1 == 3 */
- if (key_sz >= 3 &&
- !memcmp(".bak", key + key_sz - 3, 3)) {
+ if (key_sz >= suffix_len &&
+ !memcmp(".bak", key + key_sz - suffix_len, suffix_len)) {
CDEBUG(D_MGS, "Skipping backup file %.*s\n",
key_sz, key);
goto next;
int cfg_len = rec->lrh_len;
char *cfg_buf = (char*) (rec + 1);
struct lustre_cfg *lcfg;
- __u32 index;
+ u32 index;
int rc = 0;
ENTRY;
CDEBUG(D_INFO, "cmd %x %s %s\n", lcfg->lcfg_command,
lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1));
- /* Figure out ost indicies */
- /* lov_modify_tgts add 0:lov1 1:ost1_UUID 2(index):0 3(gen):1 */
- if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD ||
- lcfg->lcfg_command == LCFG_LOV_DEL_OBD) {
- index = simple_strtoul(lustre_cfg_string(lcfg, 2),
- NULL, 10);
+ /* Figure out ost indicies */
+ /* lov_modify_tgts add 0:lov1 1:ost1_UUID 2(index):0 3(gen):1 */
+ if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD ||
+ lcfg->lcfg_command == LCFG_LOV_DEL_OBD) {
+ rc = kstrtouint(lustre_cfg_string(lcfg, 2), 10, &index);
+ if (rc)
+ RETURN(rc);
+
CDEBUG(D_MGS, "OST index for %s is %u (%s)\n",
lustre_cfg_string(lcfg, 1), index,
lustre_cfg_string(lcfg, 2));
return -ENOMEM;
lcfg = &lcr->lcr_cfg;
- lcfg->lcfg_num = convert ? simple_strtoul(tmp, NULL, 0) : 0;
+ if (convert) {
+ rc = kstrtouint(tmp, 0, &lcfg->lcfg_num);
+ if (rc)
+ GOTO(out_rec_free, rc);
+ } else {
+ lcfg->lcfg_num = 0;
+ }
+
/* truncate the comment to the parameter name */
ptr = tmp - 1;
sep = *ptr;
}
}
*ptr = sep;
+out_rec_free:
lustre_cfg_rec_free(lcr);
return rc;
}
sizeof(mti->mti_params))
GOTO(out, rc = -E2BIG);
- /* obdname2fsname reports devname as an obd device */
len = strcspn(param, ".=");
if (len && param[len] != '=') {
+ struct list_head *tmp;
char *ptr;
param += len + 1;
snprintf(mti->mti_svname, sizeof(mti->mti_svname), "%.*s",
(int)len, param);
- obdname2fsname(mti->mti_svname, mti->mti_fsname,
- sizeof(mti->mti_fsname));
+ mutex_lock(&mgs->mgs_mutex);
+ if (unlikely(list_empty(&mgs->mgs_fs_db_list))) {
+ mutex_unlock(&mgs->mgs_mutex);
+ GOTO(out, rc = -ENODEV);
+ }
+
+ list_for_each(tmp, &mgs->mgs_fs_db_list) {
+ fsdb = list_entry(tmp, struct fs_db, fsdb_list);
+ if (fsdb->fsdb_has_lproc_entry &&
+ strcmp(fsdb->fsdb_name, "params") != 0 &&
+ strstr(param, fsdb->fsdb_name)) {
+ snprintf(mti->mti_svname,
+ sizeof(mti->mti_svname), "%s",
+ fsdb->fsdb_name);
+ break;
+ }
+ fsdb = NULL;
+ }
+
+ if (!fsdb) {
+ snprintf(mti->mti_svname, sizeof(mti->mti_svname),
+ "general");
+ }
+ mutex_unlock(&mgs->mgs_mutex);
} else {
snprintf(mti->mti_svname, sizeof(mti->mti_svname), "general");
}
enum lcfg_command_type cmd, const char *nodemap_name,
char *param)
{
- lnet_nid_t nid[2];
- __u32 idmap[2];
- bool bool_switch;
- __u32 int_id;
- int rc = 0;
- ENTRY;
+ lnet_nid_t nid[2];
+ u32 idmap[2];
+ bool bool_switch;
+ u32 int_id;
+ int rc = 0;
+ ENTRY;
switch (cmd) {
case LCFG_NODEMAP_ADD:
rc = nodemap_add(nodemap_name);
rc = nodemap_del_range(nodemap_name, nid);
break;
case LCFG_NODEMAP_ADMIN:
- bool_switch = simple_strtoul(param, NULL, 10);
+ rc = kstrtobool(param, &bool_switch);
+ if (rc)
+ break;
rc = nodemap_set_allow_root(nodemap_name, bool_switch);
break;
case LCFG_NODEMAP_DENY_UNKNOWN:
- bool_switch = simple_strtoul(param, NULL, 10);
+ rc = kstrtobool(param, &bool_switch);
+ if (rc)
+ break;
rc = nodemap_set_deny_unknown(nodemap_name, bool_switch);
break;
case LCFG_NODEMAP_AUDIT_MODE:
rc = -EINVAL;
break;
case LCFG_NODEMAP_TRUSTED:
- bool_switch = simple_strtoul(param, NULL, 10);
+ rc = kstrtobool(param, &bool_switch);
+ if (rc)
+ break;
rc = nodemap_set_trust_client_ids(nodemap_name, bool_switch);
break;
case LCFG_NODEMAP_SQUASH_UID:
- int_id = simple_strtoul(param, NULL, 10);
+ rc = kstrtouint(param, 10, &int_id);
+ if (rc)
+ break;
rc = nodemap_set_squash_uid(nodemap_name, int_id);
break;
case LCFG_NODEMAP_SQUASH_GID:
- int_id = simple_strtoul(param, NULL, 10);
+ rc = kstrtouint(param, 10, &int_id);
+ if (rc)
+ break;
rc = nodemap_set_squash_gid(nodemap_name, int_id);
break;
case LCFG_NODEMAP_ADD_UIDMAP:
case LCFG_NODEMAP_SET_FILESET:
rc = nodemap_set_fileset(nodemap_name, param);
break;
+ case LCFG_NODEMAP_SET_SEPOL:
+ rc = nodemap_set_sepol(nodemap_name, param);
+ break;
default:
rc = -EINVAL;
}