Module Name:    src
Committed By:   pooka
Date:           Wed Dec 15 18:37:55 UTC 2010

Modified Files:
        src/sbin/raidctl: Makefile raidctl.c
Added Files:
        src/sbin/raidctl: prog_ops.h raidctl_hostops.c raidctl_rumpops.c

Log Message:
Use RUMPPRG.

ok Greg Oster


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/raidctl/Makefile
cvs rdiff -u -r0 -r1.1 src/sbin/raidctl/prog_ops.h \
    src/sbin/raidctl/raidctl_hostops.c src/sbin/raidctl/raidctl_rumpops.c
cvs rdiff -u -r1.49 -r1.50 src/sbin/raidctl/raidctl.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/raidctl/Makefile
diff -u src/sbin/raidctl/Makefile:1.15 src/sbin/raidctl/Makefile:1.16
--- src/sbin/raidctl/Makefile:1.15	Mon Nov  8 12:42:35 2010
+++ src/sbin/raidctl/Makefile	Wed Dec 15 18:37:55 2010
@@ -1,16 +1,10 @@
-#	$NetBSD: Makefile,v 1.15 2010/11/08 12:42:35 pooka Exp $
+#	$NetBSD: Makefile,v 1.16 2010/12/15 18:37:55 pooka Exp $
 
-PROG=	raidctl 
+RUMPPRG=raidctl 
 SRCS=	rf_configure.c raidctl.c
 MAN=	raidctl.8
 
 DPADD=  ${LIBUTIL}
 LDADD=  -lutil
 
-.ifdef RUMP_ACTION
-CPPFLAGS+=	-DRUMP_ACTION -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE
-LDADD+=		-lrumpclient
-DBG=		-g
-.endif
-
 .include <bsd.prog.mk>

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.49 src/sbin/raidctl/raidctl.c:1.50
--- src/sbin/raidctl/raidctl.c:1.49	Mon Nov  8 12:42:35 2010
+++ src/sbin/raidctl/raidctl.c	Wed Dec 15 18:37:55 2010
@@ -1,4 +1,4 @@
-/*      $NetBSD: raidctl.c,v 1.49 2010/11/08 12:42:35 pooka Exp $   */
+/*      $NetBSD: raidctl.c,v 1.50 2010/12/15 18:37:55 pooka Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.49 2010/11/08 12:42:35 pooka Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.50 2010/12/15 18:37:55 pooka Exp $");
 #endif
 
 
@@ -58,15 +58,10 @@
 #include <unistd.h>
 #include <util.h>
 
-#ifdef RUMP_ACTION
-#include <rump/rump.h>
-#include <rump/rumpclient.h>
-#include <rump/rump_syscalls.h>
-#endif
-
 #include <dev/raidframe/raidframevar.h>
 #include <dev/raidframe/raidframeio.h>
 #include "rf_configure.h"
+#include "prog_ops.h"
 
 void	do_ioctl(int, u_long, void *, const char *);
 static  void rf_configure(int, char*, int);
@@ -127,11 +122,6 @@
 	force = 0;
 	openmode = O_RDWR;	/* default to read/write */
 
-#ifdef RUMP_ACTION
-	if (rumpclient_init() == -1)
-		err(1, "rump client init failed");
-#endif
-
 	while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuv")) 
 	       != -1)
 		switch(ch) {
@@ -267,13 +257,12 @@
 	if ((num_options > 1) || (argc == 0)) 
 		usage();
 
+	if (prog_init && prog_init() == -1)
+		err(1, "init failed");
+
 	strlcpy(name, argv[0], sizeof(name));
-#ifdef RUMP_ACTION
 	fd = opendisk1(name, openmode, dev_name, sizeof(dev_name), 0,
-	    rump_sys_open);
-#else
-	fd = opendisk(name, openmode, dev_name, sizeof(dev_name), 0);
-#endif
+	    prog_open);
 	if (fd == -1)
 		err(1, "Unable to open device file: %s", name);
 	if (fstat(fd, &st) == -1)
@@ -355,14 +344,14 @@
 		break;
 	}
 
-	close(fd);
+	prog_close(fd);
 	exit(0);
 }
 
 void
 do_ioctl(int fd, unsigned long command, void *arg, const char *ioctl_name)
 {
-	if (ioctl(fd, command, arg) == -1)
+	if (prog_ioctl(fd, command, arg) == -1)
 		err(1, "ioctl (%s) failed", ioctl_name);
 }
 
@@ -491,7 +480,7 @@
 	int dis, dr;
 	struct rf_pmstat st;
 
-	if (ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, &st) == -1) {
+	if (prog_ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, &st) == -1) {
 		if (errno == EINVAL) {
 			printf("raid%d: has no parity; parity map disabled\n",
 				raidID);

Added files:

Index: src/sbin/raidctl/prog_ops.h
diff -u /dev/null src/sbin/raidctl/prog_ops.h:1.1
--- /dev/null	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/prog_ops.h	Wed Dec 15 18:37:55 2010
@@ -0,0 +1,55 @@
+/*      $NetBSD: prog_ops.h,v 1.1 2010/12/15 18:37:55 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#ifndef _PROG_OPS_H_
+#define _PROG_OPS_H_
+
+#include <sys/types.h>
+
+#ifndef CRUNCHOPS
+struct prog_ops {
+	int (*op_init)(void);
+
+	int (*op_open)(const char *, int, ...);
+	int (*op_ioctl)(int, unsigned long, ...);
+	int (*op_close)(int);
+};
+extern const struct prog_ops prog_ops;
+
+#define prog_init prog_ops.op_init
+#define prog_open prog_ops.op_open
+#define prog_ioctl prog_ops.op_ioctl
+#define prog_close prog_ops.op_close
+#else
+#define prog_init ((int (*)(void))NULL)
+#define prog_open open
+#define prog_ioctl ioctl
+#define prog_close close
+#endif
+
+#endif /* _PROG_OPS_H_ */
Index: src/sbin/raidctl/raidctl_hostops.c
diff -u /dev/null src/sbin/raidctl/raidctl_hostops.c:1.1
--- /dev/null	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/raidctl_hostops.c	Wed Dec 15 18:37:55 2010
@@ -0,0 +1,46 @@
+/*	$NetBSD: raidctl_hostops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: raidctl_hostops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_open = open,
+	.op_ioctl = ioctl,
+	.op_close = close,
+};
Index: src/sbin/raidctl/raidctl_rumpops.c
diff -u /dev/null src/sbin/raidctl/raidctl_rumpops.c:1.1
--- /dev/null	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/raidctl_rumpops.c	Wed Dec 15 18:37:55 2010
@@ -0,0 +1,48 @@
+/*	$NetBSD: raidctl_rumpops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: raidctl_rumpops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+#include <rump/rumpclient.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_init =	rumpclient_init,
+
+	.op_open =	rump_sys_open,
+	.op_ioctl =	rump_sys_ioctl,
+	.op_close =	rump_sys_close,
+};

Reply via email to