extern int llapi_is_lustre_mnttype(const char *type);
extern int parse_size(char *optarg, unsigned long long *size,
unsigned long long *size_units);
+extern int llapi_path2fid(const char *path, unsigned long long *seq,
+ unsigned long *oid, unsigned long *ver);
+
struct mntent;
#define HAVE_LLAPI_IS_LUSTRE_MNT
extern int llapi_is_lustre_mnt(struct mntent *mnt);
#define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long)
#define LL_IOC_LLOOP_INFO _IOWR('f', 171, long)
#define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long)
+#define LL_IOC_PATH2FID _IOR ('f', 173, long)
#define LL_STATFS_MDC 1
#define LL_STATFS_LOV 2
static int lfs_cp(int argc, char **argv);
static int lfs_ls(int argc, char **argv);
static int lfs_poollist(int argc, char **argv);
+static int lfs_path2fid(int argc, char **argv);
/* all avaialable commands */
command_t cmdlist[] = {
{"ls", lfs_ls, 0,
"Remote user list directory contents.\n"
"usage: ls [OPTION]... [FILE]..."},
+ {"path2fid", lfs_path2fid, 0, "Display the fid for a given path.\n"
+ "usage: path2fid <path>"},
{"help", Parser_help, 0, "help"},
{"exit", Parser_quit, 0, "quit"},
{"quit", Parser_quit, 0, "quit"},
return rc;
}
+static int lfs_path2fid(int argc, char **argv)
+{
+ char *path;
+ unsigned long long seq;
+ unsigned long oid, ver;
+ int rc;
+
+ if (argc != 2)
+ return CMD_HELP;
+
+ path = argv[1];
+ rc = llapi_path2fid(path, &seq, &oid, &ver);
+ if (rc) {
+ fprintf(stderr, "error: can't get fid for %s\n", path);
+ return rc;
+ }
+
+ printf("%llu:%lu", seq, oid);
+ if (ver)
+ printf(":%lu", ver);
+
+ printf("\n");
+
+ return 0;
+}
+
#define COOK(value) \
({ \
int radix = 0; \
exit(execvp(argv[0], argv));
}
+
+int llapi_path2fid(const char *path, unsigned long long *seq,
+ unsigned long *oid, unsigned long *ver)
+{
+ struct lu_fid fid;
+ int fd, rc;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -errno;
+
+ rc = ioctl(fd, LL_IOC_PATH2FID, &fid);
+ *seq = fid_seq(&fid);
+ *oid = fid_oid(&fid);
+ *ver = fid_ver(&fid);
+
+ close(fd);
+ return rc;
+}