summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_ccd.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-06-02 20:50:03 +0000
committerphk <phk@FreeBSD.org>2003-06-02 20:50:03 +0000
commit44a9a5c714e3541ab5ceb99e1017d9ad4fa5774c (patch)
tree1aac5ead5dc342860686079b4031340872762408 /sys/geom/geom_ccd.c
parent9a8771a64bf9797acf482d4d7d4954be83a75095 (diff)
downloadFreeBSD-src-44a9a5c714e3541ab5ceb99e1017d9ad4fa5774c.zip
FreeBSD-src-44a9a5c714e3541ab5ceb99e1017d9ad4fa5774c.tar.gz
Begin deevilification of CCD:
Make CCD a GEOM class. For now only use this for implementing a OAM config method which can return a list of configured CCD devices in the format which "ccdconfig -g[v]" would normally output.
Diffstat (limited to 'sys/geom/geom_ccd.c')
-rw-r--r--sys/geom/geom_ccd.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c
index 541724a..ea3c5ee 100644
--- a/sys/geom/geom_ccd.c
+++ b/sys/geom/geom_ccd.c
@@ -63,10 +63,10 @@
#include <sys/namei.h>
#include <sys/conf.h>
#include <sys/stat.h>
-#include <sys/sysctl.h>
#include <sys/disk.h>
#include <sys/fcntl.h>
#include <sys/vnode.h>
+#include <geom/geom.h>
#include <geom/geom_disk.h>
#include <sys/ccdvar.h>
@@ -1264,3 +1264,58 @@ ccdunlock(struct ccd_s *cs)
wakeup(cs);
}
}
+
+static struct sbuf *
+g_ccd_list(int verbose)
+{
+ struct sbuf *sb;
+ struct ccd_s *cs;
+ int i;
+
+ sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ sbuf_clear(sb);
+ LIST_FOREACH(cs, &ccd_softc_list, list) {
+ if (!IS_INITED(cs))
+ continue;
+ if (verbose) {
+ sbuf_printf(sb,
+ "# ccd\t\tileave\tflags\tcomponent devices\n");
+ verbose = 0;
+ }
+ sbuf_printf(sb, "ccd%d\t\t%d\t%d\t",
+ cs->sc_unit, cs->sc_ileave, cs->sc_cflags & CCDF_USERMASK);
+
+ for (i = 0; i < cs->sc_nccdisks; ++i) {
+ sbuf_printf(sb, "%s%s", i == 0 ? "" : " ",
+ cs->sc_cinfo[i].ci_path);
+ }
+ sbuf_printf(sb, "\n");
+ }
+ sbuf_finish(sb);
+ return (sb);
+}
+
+static void
+g_ccd_config(struct gctl_req *req, struct g_class *mp, char const *verb)
+{
+ struct sbuf *sb;
+
+ g_topology_assert();
+ if (!strcmp(verb, "create geom")) {
+ gctl_error(req, "TBD");
+ } else if (!strcmp(verb, "destroy geom")) {
+ gctl_error(req, "TBD");
+ } else if (!strcmp(verb, "list")) {
+ sb = g_ccd_list(gctl_get_param(req, "verbose", NULL) ? 1 : 0);
+ gctl_set_param(req, "output", sbuf_data(sb), sbuf_len(sb) + 1);
+ } else {
+ gctl_error(req, "unknown verb");
+ }
+}
+
+static struct g_class g_ccd_class = {
+ .name = "CCD",
+ .ctlreq = g_ccd_config,
+};
+
+DECLARE_GEOM_CLASS(g_ccd_class, g_ccd);
OpenPOWER on IntegriCloud