From: yangsheng Date: Fri, 19 Mar 2010 06:49:24 +0000 (+0800) Subject: b=19919 support relative path in llapi_search_fsname() X-Git-Tag: v1_8_2_53~2 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=74427fb616385005a6c5ef497622d81789337220;p=fs%2Flustre-release.git b=19919 support relative path in llapi_search_fsname() i=adilger i=johann Use realpath() to provide absolute pathname. --- diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index c8ae1d3..4e3360b 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -607,8 +607,19 @@ int llapi_search_mounts(const char *pathname, int index, char *mntdir, int llapi_search_fsname(const char *pathname, char *fsname) { + char *path = (char*)pathname, buf[PATH_MAX + 1]; + + if (pathname[0] != '/') { /* Need a absolute path */ + memset(buf, '\0', sizeof(buf)); + if (realpath(pathname, buf) == NULL) { + llapi_err(LLAPI_MSG_ERROR, "pathname '%s' cannot expand", + pathname); + return -EINVAL; + } + path = buf; + } return get_root_path(WANT_FSNAME | WANT_ERROR, fsname, NULL, - (char *)pathname, -1); + path, -1); } /* return the first file matching this pattern */