aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2002-04-09 15:13:42 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2002-04-09 15:13:42 +0000
commita4ef1c5f9271de21aa01d2b40033a9971a7b4ade (patch)
treeeffbd6f18d862f56c9a014c534009cc6d646e31f /sys
parent0d3f37a8043fa635540b44faab649dec10506b99 (diff)
downloadsrc-a4ef1c5f9271de21aa01d2b40033a9971a7b4ade.tar.gz
src-a4ef1c5f9271de21aa01d2b40033a9971a7b4ade.zip
Introduce the convenience function g_getattr() and make it DWIM.
Sponsored by: DARPA & NAI Labs.
Notes
Notes: svn path=/head/; revision=94284
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/geom.h2
-rw-r--r--sys/geom/geom_subr.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h
index 4c9b3f0664bb..6dfe745eadba 100644
--- a/sys/geom/geom.h
+++ b/sys/geom/geom.h
@@ -193,6 +193,8 @@ void g_destroy_geom(struct g_geom *pp);
void g_destroy_provider(struct g_provider *pp);
void g_dettach(struct g_consumer *cp);
void g_error_provider(struct g_provider *pp, int error);
+int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);
+#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v))
int g_haveattr(struct bio *bp, char *attribute, void *val, int len);
int g_haveattr_int(struct bio *bp, char *attribute, int val);
int g_haveattr_off_t(struct bio *bp, char *attribute, off_t val);
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index b9c6236ce10b..1bc2ced8c6a4 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -640,3 +640,16 @@ g_insert_geom(char *class, struct g_consumer *cp)
return (gp);
}
+int
+g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len)
+{
+ int error, i;
+
+ i = len;
+ error = g_io_getattr(attr, cp, &i, var);
+ if (error)
+ return (error);
+ if (i != len)
+ return (EINVAL);
+ return (0);
+}