Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/raidctl Use RUMPPRG.
details: https://anonhg.NetBSD.org/src/rev/8e2b1508e555
branches: trunk
changeset: 759732:8e2b1508e555
user: pooka <pooka%NetBSD.org@localhost>
date: Wed Dec 15 18:37:55 2010 +0000
description:
Use RUMPPRG.
ok Greg Oster
diffstat:
sbin/raidctl/Makefile | 10 +------
sbin/raidctl/prog_ops.h | 55 ++++++++++++++++++++++++++++++++++++++++++
sbin/raidctl/raidctl.c | 31 +++++++----------------
sbin/raidctl/raidctl_hostops.c | 46 +++++++++++++++++++++++++++++++++++
sbin/raidctl/raidctl_rumpops.c | 48 ++++++++++++++++++++++++++++++++++++
5 files changed, 161 insertions(+), 29 deletions(-)
diffs (274 lines):
diff -r d336f784e639 -r 8e2b1508e555 sbin/raidctl/Makefile
--- a/sbin/raidctl/Makefile Wed Dec 15 18:11:01 2010 +0000
+++ b/sbin/raidctl/Makefile Wed Dec 15 18:37:55 2010 +0000
@@ -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>
diff -r d336f784e639 -r 8e2b1508e555 sbin/raidctl/prog_ops.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/raidctl/prog_ops.h Wed Dec 15 18:37:55 2010 +0000
@@ -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_ */
diff -r d336f784e639 -r 8e2b1508e555 sbin/raidctl/raidctl.c
--- a/sbin/raidctl/raidctl.c Wed Dec 15 18:11:01 2010 +0000
+++ b/sbin/raidctl/raidctl.c Wed Dec 15 18:37:55 2010 +0000
@@ -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);
diff -r d336f784e639 -r 8e2b1508e555 sbin/raidctl/raidctl_hostops.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/raidctl/raidctl_hostops.c Wed Dec 15 18:37:55 2010 +0000
@@ -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,
+};
diff -r d336f784e639 -r 8e2b1508e555 sbin/raidctl/raidctl_rumpops.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/raidctl/raidctl_rumpops.c Wed Dec 15 18:37:55 2010 +0000
@@ -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,
+};
Home |
Main Index |
Thread Index |
Old Index