* \retval -1 Invalid argument, errno set to EINVAL.
*/
int llapi_layout_pool_name_set(struct llapi_layout *layout,
- char *pool_name);
+ const char *pool_name);
/******************** File Creation ********************/
int llapi_heat_get(int fd, struct lu_heat *heat);
int llapi_heat_set(int fd, __u64 flags);
-int llapi_layout_sanity(struct llapi_layout *layout, const char *fname,
- bool incomplete, bool flr);
+int llapi_layout_sanity(struct llapi_layout *layout, bool incomplete, bool flr);
+int llapi_layout_sanity_fsname_check(struct llapi_layout *layout,
+ const char *pathname,
+ bool incomplete,
+ bool flr);
void llapi_layout_sanity_perror(int error);
int llapi_layout_dom_size(struct llapi_layout *layout, uint64_t *size);
/* set non-contiguous extent will fail */
rc = llapi_layout_comp_extent_set(layout, start[1] * 2, end[1]);
ASSERTF(rc == 0, "errno %d", errno);
- rc = llapi_layout_sanity(layout, NULL, false, false);
+ rc = llapi_layout_sanity(layout, false, false);
ASSERTF(rc == 12 /*LSE_NOT_ADJACENT_PREV*/, "rc %d", rc);
rc = llapi_layout_comp_extent_set(layout, start[1], end[1]);
layout = llapi_layout_get_by_path(path, 0);
ASSERTF(layout != NULL, "errno = %d", errno);
- rc = llapi_layout_sanity(layout, NULL, false, false);
+ rc = llapi_layout_sanity(layout, false, false);
ASSERTF(rc == 0, "errno %d", errno);
}
rc = -errno;
goto free_layout;
}
- rc = llapi_layout_sanity(layout, fname, false, true);
+ rc = llapi_layout_sanity_fsname_check(layout, fname, false, true);
if (rc < 0) {
llapi_layout_sanity_perror(errno);
goto free_layout;
return -ENODATA;
}
- rc = llapi_layout_sanity(layout, fname, false, true);
+ rc = llapi_layout_sanity_fsname_check(layout, fname,
+ false, true);
llapi_layout_free(layout);
}
}
- rc = llapi_layout_sanity(list->m_layout, fname, false, true);
+ rc = llapi_layout_sanity_fsname_check(list->m_layout, fname,
+ false, true);
if (rc) {
llapi_layout_sanity_perror(rc);
return rc;
return -EINVAL;
}
- rc = llapi_layout_sanity(layout, fname, false, true);
+ rc = llapi_layout_sanity_fsname_check(layout, fname, false, true);
if (rc) {
llapi_layout_sanity_perror(rc);
goto free_layout;
/* XXX: llapi_xxx() functions return negative values upon failure */
-int llapi_layout_search_ost(__u32 ost, char *pname, char *fsname)
+int llapi_layout_search_ost(__u32 ost, const char *pname, char *fsname)
{
char ostname[MAX_OBD_NAME + 64];
- char *pool_name = pname;
+ const char *pool_name = pname;
int rc = 0;
/**
* < 0, error code on failre
*/
static int llapi_stripe_param_verify(const struct llapi_stripe_param *param,
- char **pool_name,
+ const char **pool_name,
char *fsname)
{
int count;
if (param->lsp_stripe_pattern == LOV_PATTERN_MDT) {
rc = -EINVAL;
llapi_error(LLAPI_MSG_ERROR, rc,
- "Invalid pattern: %d, must be specified with -E\n",
- param->lsp_stripe_pattern);
+ "Invalid pattern: '-L mdt', must be specified "
+ "with -E\n");
goto out;
} else {
if (!llapi_stripe_count_is_valid(count)) {
{
char fsname[MAX_OBD_NAME + 1] = { 0 };
struct lov_user_md *lum = NULL;
- char *pool_name = param->lsp_pool;
+ const char *pool_name = param->lsp_pool;
size_t lum_size;
int fd, rc;
* \retval -1 if arguments are invalid or pool name is too long
*/
int llapi_layout_pool_name_set(struct llapi_layout *layout,
- char *pool_name)
+ const char *pool_name)
{
struct llapi_layout_comp *comp;
}
if (layout) {
- rc = llapi_layout_sanity((struct llapi_layout *)layout,
- path, false,
- !!(layout->llot_mirror_count > 1));
+ rc = llapi_layout_sanity_fsname_check(
+ (struct llapi_layout *)layout, path, false,
+ !!(layout->llot_mirror_count > 1));
if (rc) {
llapi_layout_sanity_perror(rc);
return -1;
goto out;
}
- rc = llapi_layout_sanity(existing_layout, path, false, false);
+ rc = llapi_layout_sanity_fsname_check(existing_layout, path,
+ false, false);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
goto out;
}
- rc = llapi_layout_sanity(existing_layout, path, false, false);
+ rc = llapi_layout_sanity_fsname_check(existing_layout, path,
+ false, false);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
goto out;
}
- rc = llapi_layout_sanity(existing_layout, path, false, false);
+ rc = llapi_layout_sanity_fsname_check(existing_layout, path,
+ false, false);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
* \retval 0, success, positive: various errors, see
* llapi_layout_sanity_perror, -1, failure
*/
-int llapi_layout_sanity(struct llapi_layout *layout,
- const char *fname,
- bool incomplete,
- bool flr)
+static int __llapi_layout_sanity(struct llapi_layout *layout,
+ const char *fname,
+ bool incomplete,
+ bool flr)
{
struct llapi_layout_sanity_args args = { { 0 } };
struct llapi_layout_comp *curr;
return rc;
}
+int llapi_layout_sanity(struct llapi_layout *layout,
+ bool incomplete,
+ bool flr)
+{
+ return __llapi_layout_sanity(layout, NULL, incomplete, flr);
+}
+
+int llapi_layout_sanity_fsname_check(struct llapi_layout *layout,
+ const char *pathname,
+ bool incomplete,
+ bool flr)
+{
+ return __llapi_layout_sanity(layout, pathname, incomplete, flr);
+}
+
int llapi_layout_dom_size(struct llapi_layout *layout, uint64_t *size)
{
uint64_t pattern, start;
return index >= -1 && index <= LOV_V1_INSANE_STRIPE_COUNT;
}
-static inline bool llapi_pool_name_is_valid(char **pool_name,
+static inline bool llapi_pool_name_is_valid(const char **pool_name,
const char *fsname)
{
- char *ptr;
+ const char *ptr;
if (*pool_name == NULL)
return false;
*/
ptr = strchr(*pool_name, '.');
if (ptr != NULL) {
- *ptr = '\0';
- if (fsname != NULL && strcmp(*pool_name, fsname) != 0) {
- *ptr = '.';
- return false;
+ if (fsname != NULL) {
+ int fslen = strlen(fsname);
+
+ if (fslen != ptr - *pool_name ||
+ strncmp(*pool_name, fsname, fslen) != 0)
+ return false;
}
*pool_name = ptr + 1;
}
}
-int llapi_layout_search_ost(__u32 ost, char *pname, char *fsname);
+int llapi_layout_search_ost(__u32 ost, const char *pname, char *fsname);
/* Compatibility macro for legacy llapi functions that use "offset"
* terminology instead of the preferred "index". */