Module Name:    src
Committed By:   christos
Date:           Mon Nov 30 19:59:34 UTC 2015

Modified Files:
        src/sbin/gpt: Makefile add.c gpt.8 gpt.c gpt.h resize.c
Added Files:
        src/sbin/gpt: main.c

Log Message:
- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/Makefile
cvs rdiff -u -r1.28 -r1.29 src/sbin/gpt/add.c
cvs rdiff -u -r1.37 -r1.38 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.45 -r1.46 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.21 -r1.22 src/sbin/gpt/gpt.h
cvs rdiff -u -r0 -r1.1 src/sbin/gpt/main.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/gpt/resize.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/Makefile
diff -u src/sbin/gpt/Makefile:1.15 src/sbin/gpt/Makefile:1.16
--- src/sbin/gpt/Makefile:1.15	Sun Nov 29 10:32:46 2015
+++ src/sbin/gpt/Makefile	Mon Nov 30 14:59:34 2015
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.15 2015/11/29 15:32:46 christos Exp $
+# $NetBSD: Makefile,v 1.16 2015/11/30 19:59:34 christos Exp $
 # $FreeBSD: src/sbin/gpt/Makefile,v 1.7 2005/09/01 02:49:20 marcel Exp $
 
 PROG=	gpt
 SRCS=	add.c biosboot.c create.c destroy.c gpt.c header.c label.c map.c \
-	migrate.c recover.c remove.c resize.c resizedisk.c \
+	main.c migrate.c recover.c remove.c resize.c resizedisk.c \
 	set.c show.c type.c unset.c gpt_uuid.c
 MAN=	gpt.8
 

Index: src/sbin/gpt/add.c
diff -u src/sbin/gpt/add.c:1.28 src/sbin/gpt/add.c:1.29
--- src/sbin/gpt/add.c:1.28	Sat Nov 28 19:14:46 2015
+++ src/sbin/gpt/add.c	Mon Nov 30 14:59:34 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: add.c,v 1.28 2015/11/29 00:14:46 christos Exp $");
+__RCSID("$NetBSD: add.c,v 1.29 2015/11/30 19:59:34 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -180,10 +180,9 @@ add(int fd)
 	gpt_write(fd, lbt);
 	gpt_write(fd, tpg);
 
-	printf("Partition %d added, use:\n", i + 1);
-	printf("\tdkctl %s addwedge <wedgename> %" PRIu64 " %" PRIu64
-	    " <type>\n", device_arg, map->map_start, map->map_size);
-	printf("to create a wedge for it\n");
+	printf("Partition %d added on %s: ", i + 1, device_arg);
+	printf("%s %" PRIu64 " %" PRIu64 "\n", type, map->map_start,
+	    map->map_size);
 }
 
 int

Index: src/sbin/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.37 src/sbin/gpt/gpt.8:1.38
--- src/sbin/gpt/gpt.8:1.37	Mon Nov  2 21:19:24 2015
+++ src/sbin/gpt/gpt.8	Mon Nov 30 14:59:34 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.37 2015/11/03 02:19:24 jnemeth Exp $
+.\" $NetBSD: gpt.8,v 1.38 2015/11/30 19:59:34 christos Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd November 2, 2015
+.Dd November 30, 2015
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -34,7 +34,10 @@
 .Nd GUID partition table maintenance utility
 .Sh SYNOPSIS
 .Nm
-.Op Ar general_options
+.Op Fl mnprqv
+.Op Fl m Ar mediasize
+.Op Fl p Ar partitions
+.Op Fl s Ar sectorsize
 .Ar command
 .Op Ar command_options
 .Ar device ...
@@ -66,44 +69,44 @@ The general options allow the user to ch
 change the behaviour that is applicable to all commands.
 Not all commands use all default settings, so some general options may not
 have an effect on all commands.
-.Pp
-The
-.Fl m Ar mediasize
-option overrides the default media size for the device (obtained
+.Bl -tag -width XXXX
+.It Fl m Ar mediasize
+Override the default media size for the device (obtained
 from the kernel if possible) or defaulting to the file size for
 plain files.
-.Pp
-The
-.Fl p Ar partitions
-option allows the user to change the number of partitions the GPT can
+.It Fl n
+Don't update the wedge information that
+.Nm
+changed.
+You need to use the
+.Xr dkctl 8
+command manually update the device's wedge configuration if you do that.
+.It Fl p Ar partitions
+Change the default number of partitions the GPT can
 accommodate.
 This is used whenever a new GPT is created.
 By default, the
 .Nm
 utility will create space for 128 partitions (or 32 sectors of 512 bytes).
-.Pp
-The
-.Fl r
-option causes the
+.It Fl r
+Open the device for reading only.
 .Nm
-utility to open the device for reading only.
 Currently this option is primarily useful for the
 .Ic show
-command, but the intent
-is to use it to implement dry-run behaviour.
-.Pp
-The
-.Fl s Ar sectorsize
-option overrides the default sector size for the device (obtained
+command, but the intent is to use it to implement dry-run behaviour.
+.It Fl q
+Don't print error messages.
+This is not implemented completely yet.
+.It Fl s Ar sectorsize
+Override the default sector size for the device (obtained
 from the kernel if possible) or
 .Dv 512
 for plain files.
-.Pp
-The
-.Fl v
-option controls the verbosity level.
+.It Fl v
+Controls the verbosity level.
 The level increases with every occurrence of this option.
 There is no formalized definition of the different levels yet.
+.El
 .Ss Commands
 .Bl -tag -width indent
 .\" ==== add ====
@@ -585,9 +588,6 @@ nas# gpt show wd3
   3907029135          32         Sec GPT table
   3907029167           1         Sec GPT header
 nas# gpt add -s 10486224 -t swap -i 1 wd3
-Partition added, use:
-        dkctl rwd3d addwedge dk<N> 34 10486224 <type>
-to create a wedge for it
 nas# gpt label -i 1 -l swap_1 wd3
 parition 1 on rwd3d labeled swap_1
 nas# gpt show wd3
@@ -612,6 +612,7 @@ nas#
 .Ed
 .Sh SEE ALSO
 .Xr boot 8 ,
+.Xr dkctl 8 ,
 .Xr fdisk 8 ,
 .Xr installboot 8 ,
 .Xr mount 8 ,

Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.45 src/sbin/gpt/gpt.c:1.46
--- src/sbin/gpt/gpt.c:1.45	Sun Nov 29 09:03:35 2015
+++ src/sbin/gpt/gpt.c	Mon Nov 30 14:59:34 2015
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.45 2015/11/29 14:03:35 christos Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.46 2015/11/30 19:59:34 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -68,7 +68,9 @@ off_t	mediasz;
 u_int	parts;
 u_int	secsz;
 
-int	readonly, verbose, quiet;
+int	readonly, verbose, quiet, nosync;
+
+static int modified;
 
 static uint32_t crc32_tab[] = {
 	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@@ -269,10 +271,11 @@ gpt_write(int fd, map_t *map)
 
 	count = map->map_size * secsz;
 	ofs = map->map_start * secsz;
-	if (lseek(fd, ofs, SEEK_SET) == ofs &&
-	    write(fd, map->map_data, count) == (ssize_t)count)
-		return (0);
-	return (-1);
+	if (lseek(fd, ofs, SEEK_SET) != ofs ||
+	    write(fd, map->map_data, count) != (ssize_t)count)
+		return -1;
+	modified = 1;
+	return 0;
 }
 
 static int
@@ -569,6 +572,12 @@ gpt_open(const char *dev, int flags)
 void
 gpt_close(int fd)
 {
+	int bits;
+
+	if (modified && !nosync)
+		if (ioctl(fd, DIOCMWEDGES, &bits) == -1)
+			warn("Can't update wedge information");
+
 	/* XXX post processing? */
 	close(fd);
 }
@@ -583,172 +592,3 @@ gpt_msg(const char *fmt, ...)
 	va_end(ap);
 	printf("\n");
 }
-
-static struct {
-	int (*fptr)(int, char *[]);
-	const char *name;
-} cmdsw[] = {
-	{ cmd_add, "add" },
-#ifndef HAVE_NBTOOL_CONFIG_H
-	{ cmd_backup, "backup" },
-#endif
-	{ cmd_biosboot, "biosboot" },
-	{ cmd_create, "create" },
-	{ cmd_destroy, "destroy" },
-	{ cmd_header, "header" },
-	{ NULL, "help" },
-	{ cmd_label, "label" },
-	{ cmd_migrate, "migrate" },
-	{ cmd_recover, "recover" },
-	{ cmd_remove, "remove" },
-	{ NULL, "rename" },
-	{ cmd_resize, "resize" },
-	{ cmd_resizedisk, "resizedisk" },
-#ifndef HAVE_NBTOOL_CONFIG_H
-	{ cmd_restore, "restore" },
-#endif
-	{ cmd_set, "set" },
-	{ cmd_show, "show" },
-	{ cmd_type, "type" },
-	{ cmd_unset, "unset" },
-	{ NULL, "verify" },
-	{ NULL, NULL }
-};
-
-__dead static void
-usage(void)
-{
-	extern const char addmsg1[], addmsg2[], biosbootmsg[];
-	extern const char createmsg[], destroymsg[], headermsg[], labelmsg1[];
-	extern const char labelmsg2[], labelmsg3[], migratemsg[], recovermsg[];
-	extern const char removemsg1[], removemsg2[], resizemsg[];
-	extern const char resizediskmsg[], setmsg[], showmsg[], typemsg1[];
-	extern const char typemsg2[], typemsg3[], unsetmsg[];
-#ifndef HAVE_NBTOOL_CONFIG_H
-	extern const char backupmsg[], restoremsg[];
-#endif
-	const char *p = getprogname();
-	const char *f =
-	    "[-rv] [-m <mediasize>] [-p <partitionnum>] [-s <sectorsize>]";
-
-	fprintf(stderr,
-	    "Usage: %s %s <command> [<args>]\n", p, f);
-	fprintf(stderr, 
-	    "Commands:\n"
-#ifndef HAVE_NBTOOL_CONFIG_H
-	    "       %s\n"
-	    "       %s\n"
-#endif
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n"
-	    "       %s\n",
-	    addmsg1, addmsg2,
-#ifndef HAVE_NBTOOL_CONFIG_H
-	    backupmsg,
-#endif
-	    biosbootmsg, createmsg, destroymsg,
-	    headermsg, labelmsg1, labelmsg2, labelmsg3,
-	    migratemsg, recovermsg,
-	    removemsg1, removemsg2,
-	    resizemsg, resizediskmsg,
-#ifndef HAVE_NBTOOL_CONFIG_H
-	    restoremsg,
-#endif
-	    setmsg, showmsg,
-	    typemsg1, typemsg2, typemsg3,
-	    unsetmsg);
-	exit(1);
-}
-
-static void
-prefix(const char *cmd)
-{
-	char *pfx;
-	const char *prg;
-
-	prg = getprogname();
-	pfx = malloc(strlen(prg) + strlen(cmd) + 2);
-	/* Don't bother failing. It's not important */
-	if (pfx == NULL)
-		return;
-
-	sprintf(pfx, "%s %s", prg, cmd);
-	setprogname(pfx);
-}
-
-int
-main(int argc, char *argv[])
-{
-	char *cmd, *p;
-	int ch, i;
-
-	/* Get the generic options */
-	while ((ch = getopt(argc, argv, "m:p:qrs:v")) != -1) {
-		switch(ch) {
-		case 'm':
-			if (mediasz > 0)
-				usage();
-			mediasz = strtoul(optarg, &p, 10);
-			if (*p != 0 || mediasz < 1)
-				usage();
-			break;
-		case 'p':
-			if (parts > 0)
-				usage();
-			parts = strtoul(optarg, &p, 10);
-			if (*p != 0 || parts < 1)
-				usage();
-			break;
-		case 'r':
-			readonly = 1;
-			break;
-		case 'q':
-			quiet = 1;
-			break;
-		case 's':
-			if (secsz > 0)
-				usage();
-			secsz = strtoul(optarg, &p, 10);
-			if (*p != 0 || secsz < 1)
-				usage();
-			break;
-		case 'v':
-			verbose++;
-			break;
-		default:
-			usage();
-		}
-	}
-	if (!parts)
-		parts = 128;
-
-	if (argc == optind)
-		usage();
-
-	cmd = argv[optind++];
-	for (i = 0; cmdsw[i].name != NULL && strcmp(cmd, cmdsw[i].name); i++);
-
-	if (cmdsw[i].fptr == NULL)
-		errx(1, "unknown command: %s", cmd);
-
-	prefix(cmd);
-	return ((*cmdsw[i].fptr)(argc, argv));
-}

Index: src/sbin/gpt/gpt.h
diff -u src/sbin/gpt/gpt.h:1.21 src/sbin/gpt/gpt.h:1.22
--- src/sbin/gpt/gpt.h:1.21	Sun Nov 29 10:32:46 2015
+++ src/sbin/gpt/gpt.h	Mon Nov 30 14:59:34 2015
@@ -65,7 +65,7 @@ extern const char *device_name;
 extern off_t mediasz;
 extern u_int parts;
 extern u_int secsz;
-extern int readonly, verbose, quiet;
+extern int readonly, verbose, quiet, nosync;
 
 uint32_t crc32(const void *, size_t);
 void	gpt_close(int);

Index: src/sbin/gpt/resize.c
diff -u src/sbin/gpt/resize.c:1.12 src/sbin/gpt/resize.c:1.13
--- src/sbin/gpt/resize.c:1.12	Sat Nov 28 19:14:46 2015
+++ src/sbin/gpt/resize.c	Mon Nov 30 14:59:34 2015
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resize.c,v 1.12 2015/11/29 00:14:46 christos Exp $");
+__RCSID("$NetBSD: resize.c,v 1.13 2015/11/30 19:59:34 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -166,10 +166,8 @@ resize(int fd)
 	gpt_write(fd, lbt);
 	gpt_write(fd, tpg);
 
-	printf("Partition %d resized, use:\n", entry);
-	printf("\tdkctl %s addwedge <wedgename> %" PRIu64 " %" PRIu64
-	    " <type>\n", device_arg, map->map_start, newsize);
-	printf("to create a wedge for it\n");
+	printf("Partition %d resized on %s: ", entry, device_arg);
+	printf("%" PRIu64 " %" PRIu64 "\n", map->map_start, newsize);
 }
 
 int

Added files:

Index: src/sbin/gpt/main.c
diff -u /dev/null src/sbin/gpt/main.c:1.1
--- /dev/null	Mon Nov 30 14:59:34 2015
+++ src/sbin/gpt/main.c	Mon Nov 30 14:59:34 2015
@@ -0,0 +1,213 @@
+/*	$NetBSD: main.c,v 1.1 2015/11/30 19:59:34 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2002 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * CRC32 code derived from work by Gary S. Brown.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <sys/cdefs.h>
+#ifdef __RCSID
+__RCSID("$NetBSD: main.c,v 1.1 2015/11/30 19:59:34 christos Exp $");
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <err.h>
+
+#include "map.h"
+#include "gpt.h"
+
+static struct {
+	int (*fptr)(int, char *[]);
+	const char *name;
+} cmdsw[] = {
+	{ cmd_add, "add" },
+#ifndef HAVE_NBTOOL_CONFIG_H
+	{ cmd_backup, "backup" },
+#endif
+	{ cmd_biosboot, "biosboot" },
+	{ cmd_create, "create" },
+	{ cmd_destroy, "destroy" },
+	{ cmd_header, "header" },
+	{ NULL, "help" },
+	{ cmd_label, "label" },
+	{ cmd_migrate, "migrate" },
+	{ cmd_recover, "recover" },
+	{ cmd_remove, "remove" },
+	{ NULL, "rename" },
+	{ cmd_resize, "resize" },
+	{ cmd_resizedisk, "resizedisk" },
+#ifndef HAVE_NBTOOL_CONFIG_H
+	{ cmd_restore, "restore" },
+#endif
+	{ cmd_set, "set" },
+	{ cmd_show, "show" },
+	{ cmd_type, "type" },
+	{ cmd_unset, "unset" },
+	{ NULL, "verify" },
+	{ NULL, NULL }
+};
+
+__dead static void
+usage(void)
+{
+	extern const char addmsg1[], addmsg2[], biosbootmsg[];
+	extern const char createmsg[], destroymsg[], headermsg[], labelmsg1[];
+	extern const char labelmsg2[], labelmsg3[], migratemsg[], recovermsg[];
+	extern const char removemsg1[], removemsg2[], resizemsg[];
+	extern const char resizediskmsg[], setmsg[], showmsg[], typemsg1[];
+	extern const char typemsg2[], typemsg3[], unsetmsg[];
+#ifndef HAVE_NBTOOL_CONFIG_H
+	extern const char backupmsg[], restoremsg[];
+#endif
+	const char *p = getprogname();
+	const char *f =
+	    "[-nrqv] [-m <mediasize>] [-p <partitionnum>] [-s <sectorsize>]";
+
+	fprintf(stderr,
+	    "Usage: %s %s <command> [<args>]\n", p, f);
+	fprintf(stderr, 
+	    "Commands:\n"
+#ifndef HAVE_NBTOOL_CONFIG_H
+	    "       %s\n"
+	    "       %s\n"
+#endif
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n"
+	    "       %s\n",
+	    addmsg1, addmsg2,
+#ifndef HAVE_NBTOOL_CONFIG_H
+	    backupmsg,
+#endif
+	    biosbootmsg, createmsg, destroymsg,
+	    headermsg, labelmsg1, labelmsg2, labelmsg3,
+	    migratemsg, recovermsg,
+	    removemsg1, removemsg2,
+	    resizemsg, resizediskmsg,
+#ifndef HAVE_NBTOOL_CONFIG_H
+	    restoremsg,
+#endif
+	    setmsg, showmsg,
+	    typemsg1, typemsg2, typemsg3,
+	    unsetmsg);
+	exit(1);
+}
+
+static void
+prefix(const char *cmd)
+{
+	char *pfx;
+
+	if (asprintf(&pfx, "%s %s", getprogname(), cmd) < 0)
+		pfx = NULL;
+	else
+		setprogname(pfx);
+}
+
+int
+main(int argc, char *argv[])
+{
+	char *cmd, *p;
+	int ch, i;
+
+	/* Get the generic options */
+	while ((ch = getopt(argc, argv, "m:np:qrs:v")) != -1) {
+		switch(ch) {
+		case 'm':
+			if (mediasz > 0)
+				usage();
+			mediasz = strtoul(optarg, &p, 10);
+			if (*p != 0 || mediasz < 1)
+				usage();
+			break;
+		case 'n':
+			nosync = 1;
+			break;
+		case 'p':
+			if (parts > 0)
+				usage();
+			parts = strtoul(optarg, &p, 10);
+			if (*p != 0 || parts < 1)
+				usage();
+			break;
+		case 'r':
+			readonly = 1;
+			break;
+		case 'q':
+			quiet = 1;
+			break;
+		case 's':
+			if (secsz > 0)
+				usage();
+			secsz = strtoul(optarg, &p, 10);
+			if (*p != 0 || secsz < 1)
+				usage();
+			break;
+		case 'v':
+			verbose++;
+			break;
+		default:
+			usage();
+		}
+	}
+	if (!parts)
+		parts = 128;
+
+	if (argc == optind)
+		usage();
+
+	cmd = argv[optind++];
+	for (i = 0; cmdsw[i].name != NULL && strcmp(cmd, cmdsw[i].name); i++);
+
+	if (cmdsw[i].fptr == NULL)
+		errx(1, "unknown command: %s", cmd);
+
+	prefix(cmd);
+	return ((*cmdsw[i].fptr)(argc, argv));
+}

Reply via email to