#endif
#include <poll.h>
-#include <liblustre.h>
+#include <libcfs/libcfs.h>
#include <lnet/lnetctl.h>
#include <lustre/lustreapi.h>
#include <lustre_ioctl.h>
struct lmv_user_mds_data *objects = lum->lum_objects;
char *prefix = lum->lum_magic == LMV_USER_MAGIC ? "(Default)" : "";
int i, obdstripe = 0;
+ char *separator = "";
if (obdindex != OBD_NOT_FOUND) {
for (i = 0; i < lum->lum_stripe_count; i++) {
llapi_printf(LLAPI_MSG_NORMAL, "%s%s\n", prefix, path);
if (verbose & VERBOSE_COUNT) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
if (verbose & ~VERBOSE_COUNT)
llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_count: ");
- llapi_printf(LLAPI_MSG_NORMAL, "%u\n",
+ llapi_printf(LLAPI_MSG_NORMAL, "%u",
(int)lum->lum_stripe_count);
+ separator = "\n";
}
if (verbose & VERBOSE_OFFSET) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
if (verbose & ~VERBOSE_OFFSET)
llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_offset: ");
- llapi_printf(LLAPI_MSG_NORMAL, "%d\n",
+ llapi_printf(LLAPI_MSG_NORMAL, "%d",
(int)lum->lum_stripe_offset);
+ separator = "\n";
}
if (verbose & VERBOSE_OBJID && lum->lum_magic != LMV_USER_MAGIC) {
- if ((obdstripe == 1))
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
+ if (obdstripe == 1 && lum->lum_stripe_count > 0)
llapi_printf(LLAPI_MSG_NORMAL,
"mdtidx\t\t FID[seq:oid:ver]\n");
for (i = 0; i < lum->lum_stripe_count; i++) {
}
if ((verbose & VERBOSE_POOL) && (pool_name[0] != '\0')) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
if (verbose & ~VERBOSE_POOL)
llapi_printf(LLAPI_MSG_NORMAL, "%slmv_pool: ",
prefix);
llapi_printf(LLAPI_MSG_NORMAL, "%s%c ", pool_name, ' ');
+ separator = "\n";
}
- llapi_printf(LLAPI_MSG_NORMAL, "\n");
+
+ if (!(verbose & VERBOSE_OBJID))
+ llapi_printf(LLAPI_MSG_NORMAL, "\n");
}
void llapi_lov_dump_user_lmm(struct find_param *param, char *path, int is_dir)
lum->lum_stripe_count = 0;
lum->lum_stripe_offset = -1;
goto dump;
+ } else if (param->get_lmv) {
+ struct lmv_user_md *lum = param->fp_lmv_md;
+ int mdtidx;
+
+ ret = llapi_file_fget_mdtidx(dirfd(d), &mdtidx);
+ if (ret != 0)
+ goto err_out;
+ lum->lum_magic = LMV_MAGIC_V1;
+ lum->lum_stripe_count = 0;
+ lum->lum_stripe_offset = mdtidx;
+ goto dump;
} else {
struct lov_user_md *lmm = ¶m->lmd->lmd_lmm;
lmm->lmm_magic = LOV_USER_MAGIC_V1;
__func__, path);
} else {
ret = -errno;
- llapi_error(LLAPI_MSG_ERROR, ret,
- "error: %s: %s failed for %s",
- __func__, d ? "LL_IOC_LOV_GETSTRIPE" :
- "IOC_MDC_GETFILESTRIPE", path);
- }
+err_out:
+ llapi_error(LLAPI_MSG_ERROR, ret,
+ "error: %s: %s failed for %s",
+ __func__, d ? "LL_IOC_LOV_GETSTRIPE" :
+ "IOC_MDC_GETFILESTRIPE", path);
+ }
return ret;
}
if (rc != -ENOENT)
llapi_error(LLAPI_MSG_ERROR, rc, "ioctl err %d", rc);
} else {
- memcpy(buf, gf->gf_path, gf->gf_pathlen);
- *recno = gf->gf_recno;
- *linkno = gf->gf_linkno;
+ memcpy(buf, gf->gf_path, gf->gf_pathlen);
+ if (buf[0] == '\0') { /* ROOT path */
+ buf[0] = '/';
+ buf[1] = '\0';
+ }
+ *recno = gf->gf_recno;
+ *linkno = gf->gf_linkno;
}
free(gf);