}
static int
-nrs_tbf_jobid_list_add(struct cfs_lstr *id, struct list_head *jobid_list)
+nrs_tbf_jobid_list_add(char *id, struct list_head *jobid_list)
{
struct nrs_tbf_jobid *jobid;
char *ptr;
if (jobid == NULL)
return -ENOMEM;
- OBD_ALLOC(jobid->tj_id, id->ls_len + 1);
+ OBD_ALLOC(jobid->tj_id, strlen(id) + 1);
if (jobid->tj_id == NULL) {
OBD_FREE_PTR(jobid);
return -ENOMEM;
}
- memcpy(jobid->tj_id, id->ls_str, id->ls_len);
- ptr = lprocfs_strnstr(id->ls_str, "*", id->ls_len);
+ strcpy(jobid->tj_id, id);
+ ptr = strchr(id, '*');
if (ptr == NULL)
jobid->tj_match_flag = NRS_TBF_MATCH_FULL;
else
}
static int
-nrs_tbf_jobid_list_parse(char *str, int len, struct list_head *jobid_list)
+nrs_tbf_jobid_list_parse(char *orig, struct list_head *jobid_list)
{
- struct cfs_lstr src;
- struct cfs_lstr res;
+ char *str, *copy;
int rc = 0;
ENTRY;
- src.ls_str = str;
- src.ls_len = len;
+ copy = kstrdup(orig, GFP_KERNEL);
+ if (!copy)
+ return -ENOMEM;
+ str = copy;
INIT_LIST_HEAD(jobid_list);
- while (src.ls_str) {
- rc = cfs_gettok(&src, ' ', &res);
- if (rc == 0) {
- rc = -EINVAL;
- break;
- }
- rc = nrs_tbf_jobid_list_add(&res, jobid_list);
- if (rc)
- break;
+ while (str && rc == 0) {
+ char *tok = strsep(&str, " ");
+
+ if (*tok)
+ rc = nrs_tbf_jobid_list_add(tok, jobid_list);
}
+ if (list_empty(jobid_list))
+ rc = -EINVAL;
if (rc)
nrs_tbf_jobid_list_free(jobid_list);
+ kfree(copy);
RETURN(rc);
}
/* parse jobid list */
rc = nrs_tbf_jobid_list_parse(cmd->u.tc_start.ts_jobids_str,
- strlen(cmd->u.tc_start.ts_jobids_str),
&cmd->u.tc_start.ts_jobids);
if (rc)
nrs_tbf_jobid_cmd_fini(cmd);
INIT_LIST_HEAD(&rule->tr_jobids);
if (!list_empty(&start->u.tc_start.ts_jobids)) {
rc = nrs_tbf_jobid_list_parse(rule->tr_jobids_str,
- strlen(rule->tr_jobids_str),
&rule->tr_jobids);
if (rc)
CERROR("jobids {%s} illegal\n", rule->tr_jobids_str);
len -= 2;
if (strcmp(field, "nid") == 0) {
- if (cfs_parse_nidlist(str, len,
- &expr->te_cond) <= 0)
+ if (cfs_parse_nidlist(str, len, &expr->te_cond) <= 0)
GOTO(out, rc = -EINVAL);
expr->te_field = NRS_TBF_FIELD_NID;
} else if (strcmp(field, "jobid") == 0) {
- if (nrs_tbf_jobid_list_parse(str, len,
- &expr->te_cond) < 0)
+ if (nrs_tbf_jobid_list_parse(str, &expr->te_cond) < 0)
GOTO(out, rc = -EINVAL);
expr->te_field = NRS_TBF_FIELD_JOBID;
} else if (strcmp(field, "opcode") == 0) {
- if (nrs_tbf_opcode_list_parse(str, len,
- &expr->te_opcodes) < 0)
+ if (nrs_tbf_opcode_list_parse(str, len, &expr->te_opcodes) < 0)
GOTO(out, rc = -EINVAL);
expr->te_field = NRS_TBF_FIELD_OPCODE;
} else if (strcmp(field, "uid") == 0) {
- if (nrs_tbf_id_list_parse(str,
- &expr->te_cond,
+ if (nrs_tbf_id_list_parse(str, &expr->te_cond,
NRS_TBF_FLAG_UID) < 0)
GOTO(out, rc = -EINVAL);
expr->te_field = NRS_TBF_FIELD_UID;
} else if (strcmp(field, "gid") == 0) {
- if (nrs_tbf_id_list_parse(str,
- &expr->te_cond,
+ if (nrs_tbf_id_list_parse(str, &expr->te_cond,
NRS_TBF_FLAG_GID) < 0)
GOTO(out, rc = -EINVAL);
expr->te_field = NRS_TBF_FIELD_GID;