Whamcloud - gitweb
LU-16029 utils: add options to lr_reader to parse raw files
[fs/lustre-release.git] / lustre / utils / liblustreapi_fid.c
index 578c6e6..8d3f268 100644 (file)
@@ -160,6 +160,15 @@ out:
        return rc;
 }
 
+static inline char *get_gf_path(struct getinfo_fid2path *gf)
+{
+#ifndef HAVE_FID2PATH_ANON_UNIONS
+       return gf->gf_u.gf_path;
+#else
+       return gf->gf_path;
+#endif
+}
+
 int llapi_fid2path_at(int mnt_fd, const struct lu_fid *fid,
                      char *path_buf, int path_buf_size,
                      long long *recno, int *linkno)
@@ -188,7 +197,7 @@ int llapi_fid2path_at(int mnt_fd, const struct lu_fid *fid,
                goto out;
        }
 
-       rc = copy_strip_dne_path(gf->gf_u.gf_path, path_buf, path_buf_size);
+       rc = copy_strip_dne_path(get_gf_path(gf), path_buf, path_buf_size);
 
        if (recno != NULL)
                *recno = gf->gf_recno;
@@ -215,10 +224,10 @@ int llapi_fid2path(const char *path_or_device, const char *fidstr, char *path,
 
        if (*path_or_device == '/')
                rc = get_root_path(WANT_FD, NULL, &mnt_fd,
-                                  (char *)path_or_device, -1);
+                                  (char *)path_or_device, -1, NULL);
        else
                rc = get_root_path(WANT_FD, (char *)path_or_device,
-                                  &mnt_fd, NULL, -1);
+                                  &mnt_fd, NULL, -1, NULL);
 
        if (rc < 0)
                goto out;
@@ -257,6 +266,7 @@ int llapi_get_mdt_index_by_fid(int fd, const struct lu_fid *fid,
 
 static int fid_from_lma(const char *path, int fd, struct lu_fid *fid)
 {
+#ifdef HAVE_SERVER_SUPPORT
        struct lustre_mdt_attrs *lma;
        char buf[512];
        int rc = -1;
@@ -271,6 +281,9 @@ static int fid_from_lma(const char *path, int fd, struct lu_fid *fid)
        lma = (struct lustre_mdt_attrs *)buf;
        memcpy(fid, &lma->lma_self_fid, sizeof(lma->lma_self_fid));
        return 0;
+#else
+       return -ENOTSUP;
+#endif
 }
 
 int llapi_fd2fid(int fd, struct lu_fid *fid)