summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2014-01-23 19:31:17 +0000
committerae <ae@FreeBSD.org>2014-01-23 19:31:17 +0000
commitce531f97ec256e753f1750067ffe4eb30c25fa85 (patch)
tree343024f0b6454c458c8d416259908eaa2840bf80 /sys/geom
parent3ec50b516b53b75bc8d0a90f5118fdf19cf0de5e (diff)
downloadFreeBSD-src-ce531f97ec256e753f1750067ffe4eb30c25fa85.zip
FreeBSD-src-ce531f97ec256e753f1750067ffe4eb30c25fa85.tar.gz
Fix typo in r261084.
Add to the gctl_error() an ability to specify error description even if numeric error code is already specified. Also by default set error code to EINVAL. PR: 185852 MFC after: 1 week
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom_ctl.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c
index afdce69..51f49c3 100644
--- a/sys/geom/geom_ctl.c
+++ b/sys/geom/geom_ctl.c
@@ -84,8 +84,8 @@ g_ctl_init(void)
}
/*
- * Report an error back to the user in ascii format. Return whatever copyout
- * returned, or EINVAL if it succeeded.
+ * Report an error back to the user in ascii format. Return nerror
+ * or EINVAL if nerror isn't specified.
*/
int
gctl_error(struct gctl_req *req, const char *fmt, ...)
@@ -99,9 +99,10 @@ gctl_error(struct gctl_req *req, const char *fmt, ...)
if (sbuf_done(req->serror)) {
if (!req->nerror)
req->nerror = EEXIST;
- }
- if (req->nerror)
return (req->nerror);
+ }
+ if (!req->nerror)
+ req->nerror = EINVAL;
va_start(ap, fmt);
sbuf_vprintf(req->serror, fmt, ap);
@@ -109,7 +110,7 @@ gctl_error(struct gctl_req *req, const char *fmt, ...)
sbuf_finish(req->serror);
if (g_debugflags & G_F_CTLDUMP)
printf("gctl %p error \"%s\"\n", req, sbuf_data(req->serror));
- return (0);
+ return (req->nerror);
}
/*
@@ -122,7 +123,7 @@ geom_alloc_copyin(struct gctl_req *req, void *uaddr, size_t len)
void *ptr;
ptr = g_malloc(len, M_WAITOK);
- nreq->nerror = copyin(uaddr, ptr, len);
+ req->nerror = copyin(uaddr, ptr, len);
if (!req->nerror)
return (ptr);
if (ptr != NULL)
OpenPOWER on IntegriCloud