diff options
author | mav <mav@FreeBSD.org> | 2015-10-05 08:52:37 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-10-05 08:52:37 +0000 |
commit | 3f61db5756a866fb4ec6b09cacd0ccbce7410361 (patch) | |
tree | d369d267fc93dd2f4f997f191e4630af47e29402 /usr.sbin/ctld/kernel.c | |
parent | c060972cd4ad911e494f964ecbd92d6c4ffd0f10 (diff) | |
download | FreeBSD-src-3f61db5756a866fb4ec6b09cacd0ccbce7410361.zip FreeBSD-src-3f61db5756a866fb4ec6b09cacd0ccbce7410361.tar.gz |
MFC r287500: Allow LUN options modification via CTL_LUNREQ_MODIFY.
Not all changes take effect, but that is a different question.
Diffstat (limited to 'usr.sbin/ctld/kernel.c')
-rw-r--r-- | usr.sbin/ctld/kernel.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c index 3c714ea..914d027 100644 --- a/usr.sbin/ctld/kernel.c +++ b/usr.sbin/ctld/kernel.c @@ -743,9 +743,11 @@ kernel_lun_add(struct lun *lun) } int -kernel_lun_resize(struct lun *lun) +kernel_lun_modify(struct lun *lun) { + struct lun_option *lo; struct ctl_lun_req req; + int error, i, num_options; bzero(&req, sizeof(req)); @@ -755,7 +757,30 @@ kernel_lun_resize(struct lun *lun) req.reqdata.modify.lun_id = lun->l_ctl_lun; req.reqdata.modify.lun_size_bytes = lun->l_size; - if (ioctl(ctl_fd, CTL_LUN_REQ, &req) == -1) { + num_options = 0; + TAILQ_FOREACH(lo, &lun->l_options, lo_next) + num_options++; + + req.num_be_args = num_options; + if (num_options > 0) { + req.be_args = malloc(num_options * sizeof(*req.be_args)); + if (req.be_args == NULL) { + log_warn("error allocating %zd bytes", + num_options * sizeof(*req.be_args)); + return (1); + } + + i = 0; + TAILQ_FOREACH(lo, &lun->l_options, lo_next) { + str_arg(&req.be_args[i], lo->lo_name, lo->lo_value); + i++; + } + assert(i == num_options); + } + + error = ioctl(ctl_fd, CTL_LUN_REQ, &req); + free(req.be_args); + if (error != 0) { log_warn("error issuing CTL_LUN_REQ ioctl"); return (1); } |