Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Jul 2005 06:36:56 GMT
From:      soc-cjones <soc-cjones@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 79895 for review
Message-ID:  <200507100636.j6A6auu8034225@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=79895

Change 79895 by soc-cjones@soc-cjones_ides on 2005/07/10 06:36:22

	Fully fleshed-out userland for gvinum 'move'

Affected files ...

.. //depot/projects/soc2005/gvinum/src/sbin/gvinum/gvinum.c#3 edit

Differences ...

==== //depot/projects/soc2005/gvinum/src/sbin/gvinum/gvinum.c#3 (text+ko) ====

@@ -604,10 +604,71 @@
 	return;
 }
 
+/* Note that move is currently of form '[-r] target object [...]' */
 void
 gvinum_move(int argc, char **argv)
 {
-	/* NOP */
+	struct gctl_req *req;
+	int flags = 0, i, j;
+	const char *errstr;
+	char buf[20], *cmd;
+
+	if (argc) {
+		optreset = 1;
+		optind = 1;
+		cmd = argv[0];
+		while ((j = getopt(argc, argv, "r")) != -1) {
+			switch (j) {
+			case 'r':
+				flags |= GV_FLAG_R;
+				break;
+			case '?':
+			default:
+				return;
+			}
+		}
+		argc -= optind;
+		argv += optind;
+	}
+
+	req = gctl_get_handle();
+	gctl_ro_param(req, "class", -1, "VINUM");
+        gctl_ro_param(req, "verb", -1, "move");
+        gctl_ro_param(req, "cmd", -1, cmd);
+        gctl_ro_param(req, "argc", sizeof(int), &argc);
+        gctl_ro_param(req, "flags", sizeof(int), &flags);
+	if (argc) {
+		for (i = 0; i < argc; i++) {
+			snprintf(buf, sizeof(buf), "argv%d", i);
+			gctl_ro_param(req, buf, -1, argv[i]);
+		}
+	} else {
+		warnx("no destination or object(s) to move specified");
+		gctl_free(req);
+		return;
+	}
+
+	/* We incremented argv such that the 0th argument is 
+	   the destination, and arguments 1..$ are the objects. */
+        gctl_ro_param(req, "destination", -1, argv[0]);
+	if (argc > 1) {
+		for (i = 1; i < argc; i++) {
+			snprintf(buf, sizeof(buf), "object%d", i - 1);
+			gctl_ro_param(req, buf, -1, argv[i]);
+		}
+	} else { /* There isn't at least one object specified! */
+		warnx("no object(s) to move specified");
+		gctl_free(req);
+		return;
+	}
+	errstr = gctl_issue(req); 
+	if (errstr != NULL) {
+		warnx("can't move object(s):  %s", errstr);
+		gctl_free(req);
+		return;
+	}
+	gctl_free(req);
+	return;
 }
 
 void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507100636.j6A6auu8034225>