const char *tgttype = "identifier of target type. e.g. pblk.";
const char *lun_begin = "Define begin of luns to use for target.";
const char *lun_end = "Define set of luns to use for target.";
+ const char *flag_factory = "Create target in factory mode";
+ int flags;
struct config
{
char *tgttype;
__u32 lun_begin;
__u32 lun_end;
+ /* flags */
+ __u32 factory;
};
struct config cfg = {
.tgttype = "",
.lun_begin = -1,
.lun_end = -1,
+ .factory = 0,
};
const struct argconfig_commandline_options command_line_options[] = {
{"target-type", 't', "TARGETTYPE", CFG_STRING, &cfg.tgttype, required_argument, tgttype},
{"lun-begin", 'b', "NUM", CFG_POSITIVE, &cfg.lun_begin, required_argument, lun_begin},
{"lun-end", 'e', "NUM", CFG_POSITIVE, &cfg.lun_end, required_argument, lun_end},
+ {"factory", 'f', "FLAG", CFG_NONE, &cfg.factory, no_argument, flag_factory},
{NULL}
};
return -EINVAL;
}
- return lnvm_do_create_tgt(cfg.devname, cfg.tgtname, cfg.tgttype, cfg.lun_begin, cfg.lun_end);
+ flags = 0;
+ if (cfg.factory)
+ flags |= NVM_TARGET_FACTORY;
+
+ return lnvm_do_create_tgt(cfg.devname, cfg.tgtname, cfg.tgttype, cfg.lun_begin, cfg.lun_end, flags);
}
static int lnvm_remove_tgt(int argc, char **argv, struct command *cmd, struct plugin *plugin)
}
int lnvm_do_create_tgt(char *devname, char *tgtname, char *tgttype,
- int lun_begin, int lun_end)
+ int lun_begin, int lun_end, int flags)
{
struct nvm_ioctl_create c;
int fd, ret;
c.conf.type = 0;
c.conf.s.lun_begin = lun_begin;
c.conf.s.lun_end = lun_end;
+ c.flags = flags;
ret = ioctl(fd, NVM_DEV_CREATE, &c);
if (ret)
int lnvm_do_init(char *, char *);
int lnvm_do_list_devices(void);
int lnvm_do_info(void);
-int lnvm_do_create_tgt(char *, char *, char *, int, int);
+int lnvm_do_create_tgt(char *, char *, char *, int, int, int);
int lnvm_do_remove_tgt(char *);
int lnvm_do_factory_init(char *, int, int, int);
int lnvm_do_id_ns(int, int, unsigned int);