if (copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
GOTO(out_lcfg, rc = -EFAULT);
+ rc = lustre_cfg_sanity_check(lcfg, data->ioc_plen1);
+ if (rc)
+ GOTO(out_lcfg, rc);
+
if (lcfg->lcfg_bufcount < 2)
- GOTO(out_lcfg, rc = -EFAULT);
+ GOTO(out_lcfg, rc = -EINVAL);
/* first arg is always <fsname>.<poolname> */
rc = mgs_extract_fs_pool(lustre_cfg_string(lcfg, 1), mgi->mgi_fsname,
if (copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
GOTO(out_free, rc = -EFAULT);
- if (lcfg->lcfg_bufcount < 1)
+ rc = lustre_cfg_sanity_check(lcfg, data->ioc_plen1);
+ if (rc)
GOTO(out_free, rc);
+ if (lcfg->lcfg_bufcount < 1)
+ GOTO(out_free, rc = -EINVAL);
+
rc = mgs_set_param(&env, mgs, lcfg);
if (rc)
CERROR("%s: setparam err: rc = %d\n",
{
struct mgs_fsdb_handler_data *d = data;
struct fs_db *fsdb = d->fsdb;
- int cfg_len = rec->lrh_len;
- char *cfg_buf = (char *)(rec + 1);
- struct lustre_cfg *lcfg;
+ struct lustre_cfg *lcfg = REC_DATA(rec);
u32 index;
int rc = 0;
RETURN(-EINVAL);
}
- rc = lustre_cfg_sanity_check(cfg_buf, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc) {
CERROR("Insane cfg\n");
RETURN(rc);
}
- lcfg = (struct lustre_cfg *)cfg_buf;
-
CDEBUG(D_INFO, "cmd %x %s %s\n", lcfg->lcfg_command,
lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1));
{
struct mgs_search_pool_data *d = data;
struct lustre_cfg *lcfg = REC_DATA(rec);
- int cfg_len = REC_DATA_LEN(rec);
char *fsname;
char *poolname;
char *ostname = NULL;
RETURN(-EINVAL);
}
- rc = lustre_cfg_sanity_check(lcfg, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc) {
CDEBUG(D_ERROR, "Insane cfg\n");
RETURN(rc);
struct mgs_modify_lookup *mml = data;
struct cfg_marker *marker;
struct lustre_cfg *lcfg = REC_DATA(rec);
- int cfg_len = REC_DATA_LEN(rec);
int rc;
ENTRY;
RETURN(-EINVAL);
}
- rc = lustre_cfg_sanity_check(lcfg, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc) {
CERROR("Insane cfg\n");
RETURN(rc);
struct llog_rec_hdr *rec,
void *data)
{
- struct mgs_replace_data *mrd;
+ struct mgs_replace_data *mrd = data;
struct lustre_cfg *lcfg = REC_DATA(rec);
- int cfg_len = REC_DATA_LEN(rec);
int rc;
- ENTRY;
- mrd = (struct mgs_replace_data *)data;
+ ENTRY;
if (rec->lrh_type != OBD_CFG_REC) {
CERROR("unhandled lrh_type: %#x, cmd %x %s %s\n",
RETURN(-EINVAL);
}
- rc = lustre_cfg_sanity_check(lcfg, cfg_len);
- if (rc) {
- /* Do not copy any invalidated records */
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
+ if (rc) /* Do not copy any invalidated records */
GOTO(skip_out, rc = 0);
- }
rc = check_markers(lcfg, mrd);
if (rc || mrd->state == REPLACE_SKIP)
struct llog_handle *llh,
struct llog_rec_hdr *rec, void *data)
{
- struct mgs_replace_data *mrd;
+ struct mgs_replace_data *mrd = data;
struct lustre_cfg *lcfg = REC_DATA(rec);
- int cfg_len = REC_DATA_LEN(rec);
int rc;
ENTRY;
- mrd = (struct mgs_replace_data *)data;
-
if (rec->lrh_type != OBD_CFG_REC) {
CDEBUG(D_MGS, "Config llog Name=%s, Record Index=%u, "
"Unhandled Record Type=%#x\n", llh->lgh_name,
RETURN(-EINVAL);
}
- rc = lustre_cfg_sanity_check(lcfg, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc) {
CDEBUG(D_MGS, "Config llog Name=%s, Invalid config file.",
llh->lgh_name);
struct mgs_target_info *mti = mcd->mcd_mti;
struct llog_handle *mdt_llh = mcd->mcd_llh;
struct fs_db *fsdb = mcd->mcd_fsdb;
- int cfg_len = rec->lrh_len;
- char *cfg_buf = (char *)(rec + 1);
- struct lustre_cfg *lcfg;
+ struct lustre_cfg *lcfg = REC_DATA(rec);
char *mdtsrc = llh->lgh_name;
char *s[5] = { 0 };
int i;
RETURN(-EINVAL);
}
- rc = lustre_cfg_sanity_check(cfg_buf, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc) {
CERROR("Insane cfg\n");
RETURN(rc);
}
- lcfg = (struct lustre_cfg *)cfg_buf;
-
if (lcfg->lcfg_command == LCFG_MARKER) {
struct cfg_marker *marker = lustre_cfg_buf(lcfg, 1);
{
struct mgs_steal_data *msd = data;
struct fs_db *fsdb = msd->msd_fsdb;
- int cfg_len = rec->lrh_len;
- char *cfg_buf = (char *)(rec + 1);
- struct lustre_cfg *lcfg;
+ struct lustre_cfg *lcfg = REC_DATA(rec);
char *s[5] = { 0 };
int i;
int rc = 0;
RETURN(-EINVAL);
}
- rc = lustre_cfg_sanity_check(cfg_buf, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc) {
CERROR("%s: insane cfg: rc = %d\n", llh->lgh_name, rc);
RETURN(rc);
}
- lcfg = (struct lustre_cfg *)cfg_buf;
-
if (lcfg->lcfg_command == LCFG_MARKER) {
struct cfg_marker *marker = lustre_cfg_buf(lcfg, 1);
char *comment = marker->cm_comment;
struct llog_rec_hdr *rec, void *data)
{
struct mgs_srpc_read_data *msrd = data;
- struct cfg_marker *marker;
- struct lustre_cfg *lcfg = REC_DATA(rec);
- char *svname, *param;
- int cfg_len, rc;
+ struct cfg_marker *marker;
+ struct lustre_cfg *lcfg = REC_DATA(rec);
+ char *svname, *param;
+ int rc;
ENTRY;
if (rec->lrh_type != OBD_CFG_REC) {
RETURN(-EINVAL);
}
- cfg_len = REC_DATA_LEN(rec);
-
- rc = lustre_cfg_sanity_check(lcfg, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc) {
CERROR("Insane cfg\n");
RETURN(rc);
struct llog_rec_hdr *rec, void *data)
{
struct config_llog_instance *cfg = data;
- int cfg_len = rec->lrh_len;
- char *cfg_buf = (char *) (rec + 1);
int rc = 0;
+
ENTRY;
/* class_config_dump_handler(handle, rec, data); */
switch (rec->lrh_type) {
case OBD_CFG_REC: {
- struct lustre_cfg *lcfg, *lcfg_new;
+ struct lustre_cfg *lcfg = REC_DATA(rec);
+ struct lustre_cfg *lcfg_new;
struct lustre_cfg_bufs bufs;
char *inst_name = NULL;
int inst_len = 0;
int swab = 0;
- lcfg = (struct lustre_cfg *)cfg_buf;
if (lcfg->lcfg_version == __swab32(LUSTRE_CFG_VERSION)) {
lustre_swab_lustre_cfg(lcfg);
swab = 1;
}
- rc = lustre_cfg_sanity_check(cfg_buf, cfg_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc)
GOTO(out, rc);
int class_config_yaml_output(struct llog_rec_hdr *rec, char *buf, int size,
unsigned int *cfg_flags, bool raw)
{
- struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1);
+ struct lustre_cfg *lcfg = REC_DATA(rec);
char *ptr = buf;
char *end = buf + size;
int rc = 0, i;
if (lcfg->lcfg_version == __swab32(LUSTRE_CFG_VERSION))
lustre_swab_lustre_cfg(lcfg);
- rc = lustre_cfg_sanity_check(lcfg, rec->lrh_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc < 0)
return rc;
*/
static int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size)
{
- struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1);
- char *ptr = buf;
- char *end = buf + size;
- int rc = 0;
+ struct lustre_cfg *lcfg = REC_DATA(rec);
+ char *ptr = buf;
+ char *end = buf + size;
+ int rc = 0;
ENTRY;
LASSERT(rec->lrh_type == OBD_CFG_REC);
- rc = lustre_cfg_sanity_check(lcfg, rec->lrh_len);
+ rc = lustre_cfg_sanity_check(lcfg, REC_DATA_LEN(rec));
if (rc < 0)
RETURN(rc);