Date: Fri, 5 Jan 2007 00:26:32 GMT From: Matt Jacob <mjacob@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 112506 for review Message-ID: <200701050026.l050QWH4065988@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=112506 Change 112506 by mjacob@mjexp on 2007/01/05 00:26:10 Add 'clear' command. Affected files ... .. //depot/projects/mjexp/sbin/geom/class/multipath/geom_multipath.c#4 edit Differences ... ==== //depot/projects/mjexp/sbin/geom/class/multipath/geom_multipath.c#4 (text+ko) ==== @@ -47,11 +47,16 @@ static void mp_main(struct gctl_req *, unsigned int); static void mp_label(struct gctl_req *); +static void mp_clear(struct gctl_req *); struct g_command class_commands[] = { { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, G_NULL_OPTS, - "[-v] name prov prov" + "[-v] name prov ..." + }, + { + "clear", G_FLAG_VERBOSE, mp_main, G_NULL_OPTS, + "[-v] prov ..." }, { "destroy", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, @@ -72,6 +77,8 @@ } if (strcmp(name, "label") == 0) { mp_label(req); + } if (strcmp(name, "clear") == 0) { + mp_clear(req); } else { gctl_error(req, "Unknown command: %s.", name); } @@ -90,7 +97,7 @@ int error, i, nargs; nargs = gctl_get_int(req, "nargs"); - if (nargs != 3) { + if (nargs < 2) { gctl_error(req, "wrong number of arguments."); return; } @@ -201,3 +208,28 @@ } } } + +static void +mp_clear(struct gctl_req *req) +{ + const char *name; + int error, i, nargs; + + nargs = gctl_get_int(req, "nargs"); + if (nargs < 1) { + gctl_error(req, "Too few arguments."); + return; + } + + for (i = 0; i < nargs; i++) { + name = gctl_get_ascii(req, "arg%d", i); + error = g_metadata_clear(name, G_MULTIPATH_MAGIC); + if (error != 0) { + fprintf(stderr, "Can't clear metadata on %s: %s.\n", + name, strerror(error)); + gctl_error(req, "Not fully done."); + continue; + } + } +} +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701050026.l050QWH4065988>