X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Fliblustreapi.c;h=429b27de3e104dae09679830d0a031658473f7ed;hp=f81effb1cf309b20054c9449ed52ac3eff6e2e0f;hb=3fa730299876a612695270a6c65e1ab1d3762a1f;hpb=61295974fe1eb20b7e5525cf553fa2bfc43f3ba6 diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index f81effb..429b27d 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -1578,47 +1578,45 @@ int llapi_get_poolmembers(const char *poolname, char **members, int llapi_get_poollist(const char *name, char **poollist, int list_size, char *buffer, int buffer_size) { - char rname[PATH_MAX]; glob_t pathname; char *fsname; - char *ptr; - DIR *dir; + char *ptr; + DIR *dir; struct dirent *pool; - int rc = 0; - unsigned int nb_entries = 0; - unsigned int used = 0; - unsigned int i; + int rc = 0; + unsigned int nb_entries = 0; + unsigned int used = 0; + unsigned int i; /* initialize output array */ - for (i = 0; i < list_size; i++) - poollist[i] = NULL; - - /* is name a pathname ? */ - ptr = strchr(name, '/'); - if (ptr != NULL) { - /* only absolute pathname is supported */ - if (*name != '/') - return -EINVAL; + for (i = 0; i < list_size; i++) + poollist[i] = NULL; - if (!realpath(name, rname)) { - rc = -errno; - llapi_error(LLAPI_MSG_ERROR, rc, "invalid path '%s'", - name); - return rc; - } + /* is name a pathname ? */ + ptr = strchr(name, '/'); + if (ptr != NULL) { + char fsname_buf[MAXNAMLEN]; - fsname = strdup(rname); + /* We will need fsname for printing later */ + rc = llapi_getname(name, fsname_buf, sizeof(fsname_buf)); + if (rc) + return rc; + + ptr = strrchr(fsname_buf, '-'); + if (ptr) + *ptr = '\0'; + + fsname = strdup(fsname_buf); if (!fsname) return -ENOMEM; - - rc = poolpath(&pathname, NULL, rname); } else { /* name is FSNAME */ fsname = strdup(name); if (!fsname) return -ENOMEM; - rc = poolpath(&pathname, fsname, NULL); } + + rc = poolpath(&pathname, fsname, NULL); if (rc != 0) { llapi_error(LLAPI_MSG_ERROR, rc, "Lustre filesystem '%s' not found", name);