sd.name = name;
sd.cross_ref = cr;
sd.rc = -ENOENT;
- vfs_readdir(file, filldir, &sd);
+ rc = vfs_readdir(file, filldir, &sd);
+ if (!rc)
+ rc = sd.rc;
filp_close(file, 0);
- rc = sd.rc;
out:
OBD_FREE(pname, len);
} else {
*type = PP_SPLIT_SLAVE;
*pid = mea->mea_ids[mea->mea_master];
+ LASSERT(id_fid(pid));
}
} else {
int mds_num = id_group(&pkg->pp_id1);
ENTRY;
- LASSERT(mds_num >= 0);
-
//for cross-ref dir we should send request to parent's MDS
if (pkg->pp_type == PP_CROSS_DIR)
mds_num = id_group(&pkg->pp_id2);
+ LASSERT(mds_num >= 0);
+
if (mds_num == obd->u.mds.mds_num) {
rc = local_parse_id(obd, pkg);
} else {
RETURN(rc);
exp = lmv->tgts[mds_num].ltd_exp;
- LASSERT(exp);
+ LASSERTF(exp, "No export for MDS #%i\n", mds_num);
req = ptlrpc_prep_req(class_exp2cliimp(exp),
LUSTRE_MDS_VERSION, MDS_PARSE_ID, 1,
CERROR("log is not plain\n");
RETURN(-EINVAL);
}
-
+
if (rec->lrh_type != SMFS_AUDIT_NAME_REC)
RETURN(0);
-
+
ad_rec = (struct audit_record *)(rec + 1);
-
- if (ad_rec->result ||
- ad_rec->opcode != AUDIT_UNLINK ||
- ad_rec->opcode != AUDIT_RENAME)
+ if (ad_rec->result ||
+ (ad_rec->opcode != AUDIT_UNLINK &&
+ ad_rec->opcode != AUDIT_RENAME))
RETURN(0);
cid_rec = (struct audit_id_record *)(ad_rec + 1);
pid_rec = cid_rec + 1;
nm_rec = (struct audit_name_record *)(pid_rec + 1);
-
+
if (cid_rec->au_num == id_ino(&pkg->pp_id1) &&
cid_rec->au_gen == id_gen(&pkg->pp_id1)) {
+ LASSERT(pid_rec->au_fid);
/* get parent id */
id_ino(&pkg->pp_id2) = pid_rec->au_num;
id_gen(&pkg->pp_id2) = pid_rec->au_gen;
/* get name */
memcpy(pkg->pp_name, nm_rec->name,
le32_to_cpu(nm_rec->name_len));
-
RETURN(LLOG_PROC_BREAK);
}
RETURN(0);
int rc = 0;
ENTRY;
+ pkg->pp_rc = 0;
if (ctxt)
llh = ctxt->loc_handle;
if (llh == NULL)
- RETURN(-ENOENT);
+ GOTO(out, rc = -ENOENT);
rc = llog_cat_process(llh, (llog_cb_t)&scan_audit_log_cb, (void *)pkg);
if (rc != LLOG_PROC_BREAK) {
CWARN("process catalog log failed: rc(%d)\n", rc);
- RETURN(-ENOENT);
+ rc = -ENOENT;
+ } else {
+ rc = 0;
}
- RETURN(0);
+out:
+ pkg->pp_rc = rc;
+ RETURN(rc);
}
static int
RETURN(rc);
exp = lmv->tgts[mds_num].ltd_exp;
- LASSERT(exp);
+ LASSERTF(exp, "No export for MDS #%i\n", mds_num);
req = ptlrpc_prep_req(class_exp2cliimp(exp),
LUSTRE_MDS_VERSION, MDS_PARSE_ID, 1,
INIT_LIST_HEAD(&list);
cur_id = *id;
+ if (!id_ino(&cur_id)) {
+ CERROR("Invalid id!\n");
+ RETURN(-EINVAL);
+ }
if (id_fid(&cur_id) == ROOT_FID)
RETURN(0);
+
next:
memset(&parent_id, 0, sizeof(parent_id));
rc = mds_id2name(obd, &cur_id, &list, &parent_id);
if (rc == -ENOENT) {
/* can't reconstruct name from id, turn to audit log */
- LASSERT(id_fid(&parent_id));
cur_id = parent_id;
memset(&parent_id, 0, sizeof(parent_id));
item = list_entry(pos, struct name_item, link);
*namelen += strlen(item->name) + 1;
}
- OBD_ALLOC(*name, *namelen + 1);
+
+ (*namelen)++; /* for the ending '\0' of string */
+ OBD_ALLOC(*name, *namelen);
if (*name == NULL)
rc = -ENOMEM;
out:
}
list_del_init(&item->link);
OBD_FREE(item, sizeof(*item));
- LASSERT(strlen(*name) <= *namelen);
+ if (*name)
+ LASSERT(strlen(*name) < *namelen);
}
RETURN(rc);
}