summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-04-23 07:50:01 +0000
committerphk <phk@FreeBSD.org>2003-04-23 07:50:01 +0000
commit90684346d69d41794fef92b9545d0ca0a83d1fe4 (patch)
tree94442d29cbe8b010572d90450367d2ad4ec4c734 /sys/geom
parentee10d5398635179dbb8ae9f414fb9946308171f3 (diff)
downloadFreeBSD-src-90684346d69d41794fef92b9545d0ca0a83d1fe4.zip
FreeBSD-src-90684346d69d41794fef92b9545d0ca0a83d1fe4.tar.gz
Make gctl_error() take printfline varargs.
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom.h3
-rw-r--r--sys/geom/geom_ctl.c27
2 files changed, 23 insertions, 7 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h
index f09972a..fa90f91 100644
--- a/sys/geom/geom.h
+++ b/sys/geom/geom.h
@@ -334,6 +334,7 @@ extern struct sx topology_lock;
/* geom_ctl.c */
void *gctl_get_param(struct gctl_req *req, const char *param, int *len);
-int gctl_error(struct gctl_req *req, const char *errtxt);
+void *gctl_get_paraml(struct gctl_req *req, const char *param, int len);
+int gctl_error(struct gctl_req *req, const char *fmt, ...);
#endif /* _GEOM_GEOM_H_ */
diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c
index 279156e..a1133b3 100644
--- a/sys/geom/geom_ctl.c
+++ b/sys/geom/geom_ctl.c
@@ -46,6 +46,7 @@
#include <sys/disk.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
+#include <sys/sbuf.h>
#include <sys/lock.h>
#include <sys/mutex.h>
@@ -59,6 +60,8 @@
#include <geom/geom_ctl.h>
#include <geom/geom_ext.h>
+#include <machine/stdarg.h>
+
static d_ioctl_t g_ctl_ioctl;
static struct cdevsw g_ctl_cdevsw = {
@@ -87,16 +90,28 @@ g_ctl_init(void)
* XXX: should take printf like args.
*/
int
-gctl_error(struct gctl_req *req, const char *errtxt)
+gctl_error(struct gctl_req *req, const char *fmt, ...)
{
int error;
-
- if (g_debugflags & G_F_CTLDUMP)
- printf("gctl %p error \"%s\"\n", req, errtxt);
- error = copyout(errtxt, req->error,
- imin(req->lerror, strlen(errtxt) + 1));
+ va_list ap;
+ struct sbuf *sb;
+
+ sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ if (sb == NULL) {
+ error = copyout(fmt, req->error,
+ imin(req->lerror, strlen(fmt) + 1));
+ } else {
+ va_start(ap, fmt);
+ sbuf_vprintf(sb, fmt, ap);
+ sbuf_finish(sb);
+ if (g_debugflags & G_F_CTLDUMP)
+ printf("gctl %p error \"%s\"\n", req, sbuf_data(sb));
+ error = copyout(sbuf_data(sb), req->error,
+ imin(req->lerror, sbuf_len(sb) + 1));
+ }
if (!error)
error = EINVAL;
+ sbuf_delete(sb);
return (error);
}
OpenPOWER on IntegriCloud