diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5 --- a/usr.sbin/ctld/ctl.conf.5 +++ b/usr.sbin/ctld/ctl.conf.5 @@ -555,36 +555,34 @@ "iqn.2012-06.com.example:target0" { alias = "Example target" auth-group = no-authentication - lun = [ - { - number = 0 + lun = { + 0 { path = /dev/zvol/tank/example_0 blocksize = 4096 size = 4GB } - ] + } } "iqn.2012-06.com.example:target1" { auth-group = ag0 portal-group = pg0 - lun = [ - { number = 0, name = example_1 }, - { - number = 1 + lun { + 0 = example_1 + 1 { path = /dev/zvol/tank/example_2 options { vendor = "FreeBSD" } } - ] + } } naa.50015178f369f092 { port = isp0 - lun = [ - { number = 0, name = example_1 } - ] + lun { + 0 = example_1 + } } } .Ed diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c --- a/usr.sbin/ctld/uclparse.c +++ b/usr.sbin/ctld/uclparse.c @@ -233,23 +233,39 @@ { const ucl_object_t *num; const ucl_object_t *name; - char *lun_name; + const char *key; + char *end, *lun_name; u_int id; bool ok; + key = ucl_object_key(obj); + if (key != NULL) { + id = strtoul(key, &end, 0); + if (*end != '\0') { + log_warnx("lun key \"%s\" in target \"%s\" is invalid", + key, t_name); + return (false); + } + + if (obj->type == UCL_STRING) + return (target_add_lun(id, ucl_object_tostring(obj))); + } + if (obj->type != UCL_OBJECT) { log_warnx("lun section entries in target \"%s\" must be objects", t_name); return (false); } - num = ucl_object_find_key(obj, "number"); - if (num == NULL || num->type != UCL_INT) { - log_warnx("lun section in target \"%s\" is missing " - "\"number\" integer property", t_name); - return (false); + if (key == NULL) { + num = ucl_object_find_key(obj, "number"); + if (num == NULL || num->type != UCL_INT) { + log_warnx("lun section in target \"%s\" is missing " + "\"number\" integer property", t_name); + return (false); + } + id = ucl_object_toint(num); } - id = ucl_object_toint(num); name = ucl_object_find_key(obj, "name"); if (name == NULL) {