X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fliblustreapi_fid.c;h=bf326bcc024c443aa4a89cf70a1316edb8510f10;hb=718e3f3e680f422d865a15890ac60e66dcd9e240;hp=d6fb8b5f215f1f65a378c8b461c671f135524215;hpb=0991267eab728e9a6e49a31e80ea91b865159b7f;p=fs%2Flustre-release.git diff --git a/lustre/utils/liblustreapi_fid.c b/lustre/utils/liblustreapi_fid.c index d6fb8b5..bf326bc 100644 --- a/lustre/utils/liblustreapi_fid.c +++ b/lustre/utils/liblustreapi_fid.c @@ -233,18 +233,13 @@ int llapi_fid2path(const char *path_or_device, const char *fidstr, char *path, goto out; } - if (path_or_device[0] == '/') - rc = get_root_path(WANT_FD, NULL, &mnt_fd, - (char *)path_or_device, -1, NULL, NULL); - else - rc = get_root_path(WANT_FD, (char *)path_or_device, - &mnt_fd, NULL, -1, NULL, NULL); - + rc = llapi_root_path_open(path_or_device, &mnt_fd); if (rc < 0) goto out; /* mnt_fd is cached internally, no need to close it */ rc = llapi_fid2path_at(mnt_fd, &fid, path, pathlen, recno, linkno); + close(mnt_fd); out: return rc; @@ -443,7 +438,7 @@ int llapi_fid_to_handle(struct file_handle **_handle, const struct lu_fid *fid) */ int llapi_open_by_fid_at(int lustre_fd, const struct lu_fid *fid, int flags) { - struct file_handle *handle; + struct file_handle *handle = NULL; int fd; int rc; @@ -477,15 +472,12 @@ int llapi_open_by_fid(const char *lustre_dir, const struct lu_fid *fid, { int mnt_fd, rc; - /* this will return a cached FD if available, so only one open needed. - * WANT_FD doesn't modify lustre_dir so casting away "const" is OK */ - rc = get_root_path(WANT_FD, NULL, &mnt_fd, (char *)lustre_dir, 0, NULL, - NULL); + rc = llapi_root_path_open(lustre_dir, &mnt_fd); if (rc) goto out; - /* "mnt_fd" is cached internally for reuse, no need to close it */ rc = llapi_open_by_fid_at(mnt_fd, fid, flags); + close(mnt_fd); out: return rc; }