char *ll_read_opt(const char *opt, char *data);
int ll_set_opt(const char *opt, char *data, int fl);
-void ll_options(char *options, char **ost, char **mds, int *flags);
+void ll_options(char *options, int *flags);
void ll_lli_init(struct ll_inode_info *lli);
int ll_fill_super(struct super_block *sb);
void ll_put_super(struct super_block *sb);
RETURN(fl);
}
-void ll_options(char *options, char **ost, char **mdc, int *flags)
+void ll_options(char *options, int *flags)
{
int tmp;
char *this_char;
#endif
{
CDEBUG(D_SUPER, "this_char %s\n", this_char);
- if (!*ost && (*ost = ll_read_opt(LUSTRE_OSC_NAME, this_char)))
- continue;
- if (!*mdc && (*mdc = ll_read_opt(LUSTRE_MDC_NAME, this_char)))
- continue;
tmp = ll_set_opt("nolock", this_char, LL_SBI_NOLCK);
if (tmp) {
*flags |= tmp;
if (!sbi)
RETURN(-ENOMEM);
- ll_options(lsi->lsi_lmd->lmd_opts, &osc, &mdc, &sbi->ll_flags);
+ ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags);
/* Generate a string unique to this super, in case some joker tries
to mount the same fs at two mount points.
}
CERROR("Found profile %s: mdc=%s osc=%s\n", profilenm,
lprof->lp_mdc, lprof->lp_osc);
+
OBD_ALLOC(osc, strlen(lprof->lp_osc) +
strlen(ll_instance) + 2);
+ if (!osc)
+ GOTO(out_free, err = -ENOMEM);
+ sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance);
+
OBD_ALLOC(mdc, strlen(lprof->lp_mdc) +
strlen(ll_instance) + 2);
- if (!osc || !mdc)
+ if (!mdc)
GOTO(out_free, err = -ENOMEM);
-
- sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance);
sprintf(mdc, "%s-%s", lprof->lp_mdc, ll_instance);
/* connections, registrations, sb setup */
OBD_ALLOC(lprof, sizeof(*lprof));
if (lprof == NULL)
- GOTO(out, err = -ENOMEM);
+ RETURN(-ENOMEM);
INIT_LIST_HEAD(&lprof->lp_list);
LASSERT(proflen == (strlen(prof) + 1));
LASSERT(osclen == (strlen(osc) + 1));
OBD_ALLOC(lprof->lp_osc, osclen);
- if (lprof->lp_profile == NULL)
+ if (lprof->lp_osc == NULL)
GOTO(out, err = -ENOMEM);
memcpy(lprof->lp_osc, osc, osclen);
}
list_add(&lprof->lp_list, &lustre_profile_list);
+ RETURN(err);
out:
- RETURN(err);
+ if (lprof->lp_mdc)
+ OBD_FREE(lprof->lp_mdc, mdclen);
+ if (lprof->lp_osc)
+ OBD_FREE(lprof->lp_osc, osclen);
+ if (lprof->lp_profile)
+ OBD_FREE(lprof->lp_profile, proflen);
+ OBD_FREE(lprof, sizeof(*lprof));
+ RETURN(err);
}
void class_del_profile(char *prof)
*flagp = 0;
nextopt = orig_options;
while ((opt = strsep(&nextopt, ","))) {
+ if (!*opt)
+ /* empty option */
+ continue;
if (parse_one_option(opt, flagp) > 0)
continue;
/* no mount flags set, so pass this on as an option */
strcat(options, ",");
strcat(options, opt);
}
+ /* options will always be <= orig_options */
strcpy(orig_options, options);
free(options);
return 0;
int main(int argc, char *const argv[])
{
- char *source, *target, *options = "", *optcopy;
+ char default_options[] = "";
+ char *source, *target, *options = default_options, *optcopy;
int i, nargs = 3, opt, rc, flags, optlen;
static struct option long_opt[] = {
{"fake", 0, 0, 'f'},
/* In Linux 2.4, the target device doesn't get passed to any of our
functions. So we'll stick it on the end of the options. */
- optlen = strlen(options) + strlen(",device=") + strlen(source);
+ optlen = strlen(options) + strlen(",device=") + strlen(source) + 1;
optcopy = malloc(optlen);
strcpy(optcopy, options);
if (*optcopy)