X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fliblustreapi.c;h=bc16eb334d8c8cea54663ee1c27cd22bd2aee870;hb=ee7dfc5ad1;hp=ddad8a05abcaf6e5ec11ce0ee3288c6f08bde606;hpb=a4b5304ae5542373de4ad1f2bca193dfb95ef7ff;p=fs%2Flustre-release.git diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index ddad8a0..bc16eb3 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -354,7 +354,7 @@ int llapi_parse_size(const char *optarg, unsigned long long *size, * < 0, error code on failre */ static int llapi_stripe_param_verify(const struct llapi_stripe_param *param, - const char **pool_name) + const char **pool_name, char *fsname) { int count; static int page_size; @@ -419,6 +419,16 @@ static int llapi_stripe_param_verify(const struct llapi_stripe_param *param, "Invalid Poolname '%s'", *pool_name); goto out; } + + /* Make sure the pool exists */ + rc = llapi_search_ost(fsname, *pool_name, NULL); + if (rc < 0) { + llapi_error(LLAPI_MSG_ERROR, rc, + "pool '%s fsname %s' does not exist", + *pool_name, fsname); + rc = -EINVAL; + goto out; + } } out: @@ -543,14 +553,23 @@ int llapi_get_agent_uuid(char *path, char *buf, size_t bufsize) int llapi_file_open_param(const char *name, int flags, mode_t mode, const struct llapi_stripe_param *param) { + char fsname[MAX_OBD_NAME + 1] = { 0 }; struct lov_user_md *lum = NULL; const char *pool_name = param->lsp_pool; size_t lum_size; int fd, rc; + /* Make sure we are on a Lustre file system */ + rc = llapi_search_fsname(name, fsname); + if (rc) { + llapi_error(LLAPI_MSG_ERROR, rc, + "'%s' is not on a Lustre filesystem", name); + return rc; + } + /* Check if the stripe pattern is sane. */ - rc = llapi_stripe_param_verify(param, &pool_name); - if (rc != 0) + rc = llapi_stripe_param_verify(param, &pool_name, fsname); + if (rc < 0) return rc; if (param->lsp_is_specific)