Commit 8aa9540b authored by Alexander Aring's avatar Alexander Aring Committed by David Teigland

fs: dlm: add errno handling to check callback

This allows to return individual errno values for the config attribute
check callback instead of returning invalid argument only.
Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent e9a470ac
...@@ -125,7 +125,7 @@ static ssize_t cluster_cluster_name_store(struct config_item *item, ...@@ -125,7 +125,7 @@ static ssize_t cluster_cluster_name_store(struct config_item *item,
CONFIGFS_ATTR(cluster_, cluster_name); CONFIGFS_ATTR(cluster_, cluster_name);
static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
int *info_field, bool (*check_cb)(unsigned int x), int *info_field, int (*check_cb)(unsigned int x),
const char *buf, size_t len) const char *buf, size_t len)
{ {
unsigned int x; unsigned int x;
...@@ -137,8 +137,11 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, ...@@ -137,8 +137,11 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
if (rc) if (rc)
return rc; return rc;
if (check_cb && check_cb(x)) if (check_cb) {
return -EINVAL; rc = check_cb(x);
if (rc)
return rc;
}
*cl_field = x; *cl_field = x;
*info_field = x; *info_field = x;
...@@ -161,14 +164,20 @@ static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \ ...@@ -161,14 +164,20 @@ static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
} \ } \
CONFIGFS_ATTR(cluster_, name); CONFIGFS_ATTR(cluster_, name);
static bool dlm_check_zero(unsigned int x) static int dlm_check_zero(unsigned int x)
{ {
return !x; if (!x)
return -EINVAL;
return 0;
} }
static bool dlm_check_buffer_size(unsigned int x) static int dlm_check_buffer_size(unsigned int x)
{ {
return (x < DEFAULT_BUFFER_SIZE); if (x < DEFAULT_BUFFER_SIZE)
return -EINVAL;
return 0;
} }
CLUSTER_ATTR(tcp_port, dlm_check_zero); CLUSTER_ATTR(tcp_port, dlm_check_zero);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment