Commit 90d1e588 authored by James Simmons's avatar James Simmons Committed by Greg Kroah-Hartman

staging: lustre: uapi: move lustre_cfg_string() to obd_config.c

To perserve the truncate warning move lustre_cfg_string()
to obd_config.c. A identical function was created for
userland. This function was a bit big for a inline function.
Signed-off-by: default avatarJames Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401
Reviewed-on: https://review.whamcloud.com/26966Reviewed-by: default avatarQuentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: default avatarBen Evans <bevans@cray.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 402fba76
......@@ -179,35 +179,6 @@ static inline void lustre_cfg_bufs_init(struct lustre_cfg_bufs *bufs,
}
}
static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, __u32 index)
{
char *s;
if (lcfg->lcfg_buflens[index] == 0)
return NULL;
s = lustre_cfg_buf(lcfg, index);
if (!s)
return NULL;
/*
* make sure it's NULL terminated, even if this kills a char
* of data. Try to use the padding first though.
*/
if (s[lcfg->lcfg_buflens[index] - 1] != '\0') {
size_t last = min((size_t)lcfg->lcfg_buflens[index],
cfs_size_round(lcfg->lcfg_buflens[index]) - 1);
char lost = s[last];
s[last] = '\0';
if (lost != '\0') {
CWARN("Truncated buf %d to '%s' (lost '%c'...)\n",
index, s, lost);
}
}
return s;
}
static inline __u32 lustre_cfg_len(__u32 bufcount, __u32 *buflens)
{
__u32 i;
......
......@@ -107,6 +107,7 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
struct llog_rec_hdr *, void *);
/* obd_config.c */
char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index);
int class_process_config(struct lustre_cfg *lcfg);
int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
struct lustre_cfg *lcfg, void *data);
......
......@@ -170,6 +170,40 @@ int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh)
}
EXPORT_SYMBOL(class_parse_nid_quiet);
char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index)
{
char *s;
if (!lcfg->lcfg_buflens[index])
return NULL;
s = lustre_cfg_buf(lcfg, index);
if (!s)
return NULL;
/*
* make sure it's NULL terminated, even if this kills a char
* of data. Try to use the padding first though.
*/
if (s[lcfg->lcfg_buflens[index] - 1] != '\0') {
size_t last = ALIGN(lcfg->lcfg_buflens[index], 8) - 1;
char lost;
/* Use the smaller value */
if (last > lcfg->lcfg_buflens[index])
last = lcfg->lcfg_buflens[index];
lost = s[last];
s[last] = '\0';
if (lost != '\0') {
CWARN("Truncated buf %d to '%s' (lost '%c'...)\n",
index, s, lost);
}
}
return s;
}
EXPORT_SYMBOL(lustre_cfg_string);
/********************** class fns **********************/
/**
......
......@@ -37,6 +37,7 @@
#include <linux/key.h>
#include "../include/obd.h"
#include "../include/obd_class.h"
#include "../include/obd_support.h"
#include "../include/lustre_import.h"
#include "../../include/uapi/linux/lustre/lustre_param.h"
......
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