Module Name:    src
Committed By:   pooka
Date:           Fri Feb  4 19:42:13 UTC 2011

Modified Files:
        src/bin/dd: Makefile args.c dd.c dd.h
        src/distrib/sets/lists/base: mi
        src/distrib/sets/lists/comp: mi
Added Files:
        src/bin/dd: dd_hostops.c dd_rumpops.c

Log Message:
Remove the rif/rof options and add rump.dd.  This makes usage
consistent with other rump clients.  Copying between kernels is
done using the host pipe, e.g.:

  dd if=foo rof=bar skip=1 seek=1 => dd if=foo skip=1 | rump.dd of=bar seek=1

Also, the pipe idiom extends to copying between different rump
kernels, e.g.:

  env RUMP_SERVER=unix://srv1 rump.dd if=thefile \
      | env RUMP_SERVER=unix://srv2 rump.dd of=thefile

Pipe approach suggested by yamt (thanks!)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/bin/dd/Makefile src/bin/dd/dd.h
cvs rdiff -u -r1.33 -r1.34 src/bin/dd/args.c
cvs rdiff -u -r1.46 -r1.47 src/bin/dd/dd.c
cvs rdiff -u -r0 -r1.1 src/bin/dd/dd_hostops.c src/bin/dd/dd_rumpops.c
cvs rdiff -u -r1.919 -r1.920 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1580 -r1.1581 src/distrib/sets/lists/comp/mi

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

Modified files:

Index: src/bin/dd/Makefile
diff -u src/bin/dd/Makefile:1.14 src/bin/dd/Makefile:1.15
--- src/bin/dd/Makefile:1.14	Mon Nov 22 21:59:09 2010
+++ src/bin/dd/Makefile	Fri Feb  4 19:42:12 2011
@@ -1,7 +1,7 @@
-#	$NetBSD: Makefile,v 1.14 2010/11/22 21:59:09 pooka Exp $
+#	$NetBSD: Makefile,v 1.15 2011/02/04 19:42:12 pooka Exp $
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
 
-PROG=	dd
+RUMPPRG=dd
 SRCS=	args.c conv.c dd.c misc.c position.c
 
 DPADD+=	${LIBUTIL}
Index: src/bin/dd/dd.h
diff -u src/bin/dd/dd.h:1.14 src/bin/dd/dd.h:1.15
--- src/bin/dd/dd.h:1.14	Mon Dec  6 15:23:29 2010
+++ src/bin/dd/dd.h	Fri Feb  4 19:42:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dd.h,v 1.14 2010/12/06 15:23:29 pooka Exp $	*/
+/*	$NetBSD: dd.h,v 1.15 2011/02/04 19:42:12 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,6 +38,8 @@
 #include <sys/stat.h>
 
 struct ddfops {
+	int (*op_init)(void);
+
 	int (*op_open)(const char *, int, ...);
 	int (*op_close)(int);
 
@@ -119,6 +121,3 @@
 #define	C_UNBLOCK	0x80000
 #define	C_OSYNC		0x100000
 #define	C_SPARSE	0x200000
-#define C_RIF		0x400000
-#define C_ROF		0x800000
-#define C_RUMP		0x1000000

Index: src/bin/dd/args.c
diff -u src/bin/dd/args.c:1.33 src/bin/dd/args.c:1.34
--- src/bin/dd/args.c:1.33	Thu Jan 13 23:45:13 2011
+++ src/bin/dd/args.c	Fri Feb  4 19:42:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.33 2011/01/13 23:45:13 jym Exp $	*/
+/*	$NetBSD: args.c,v 1.34 2011/02/04 19:42:12 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: args.c,v 1.33 2011/01/13 23:45:13 jym Exp $");
+__RCSID("$NetBSD: args.c,v 1.34 2011/02/04 19:42:12 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -55,12 +55,6 @@
 #include "dd.h"
 #include "extern.h"
 
-#if !defined(SMALL) && defined(__NetBSD__)
-#define _HAVE_RUMPOPS
-
-#include <rump/rumpclient.h>
-#endif
-
 static int	c_arg(const void *, const void *);
 #ifndef	NO_CONV
 static int	c_conv(const void *, const void *);
@@ -78,11 +72,6 @@
 static void	f_skip(char *);
 static void	f_progress(char *);
 
-#ifdef _HAVE_RUMPOPS
-static void	f_rif(char *);
-static void	f_rof(char *);
-#endif
-
 static const struct arg {
 	const char *name;
 	void (*f)(char *);
@@ -96,16 +85,12 @@
 	{ "count",	f_count,	C_COUNT, C_COUNT },
 	{ "files",	f_files,	C_FILES, C_FILES },
 	{ "ibs",	f_ibs,		C_IBS,	 C_BS|C_IBS },
-	{ "if",		f_if,		C_IF,	 C_IF|C_RIF },
+	{ "if",		f_if,		C_IF,	 C_IF },
 	{ "iseek",	f_skip,		C_SKIP,	 C_SKIP },
 	{ "obs",	f_obs,		C_OBS,	 C_BS|C_OBS },
-	{ "of",		f_of,		C_OF,	 C_OF|C_ROF },
+	{ "of",		f_of,		C_OF,	 C_OF },
 	{ "oseek",	f_seek,		C_SEEK,	 C_SEEK },
 	{ "progress",	f_progress,	0,	 0 },
-#ifdef _HAVE_RUMPOPS
-	{ "rif",	f_rif,		C_RIF|C_RUMP,	 C_RIF|C_IF },
-	{ "rof",	f_rof,		C_ROF|C_RUMP,	 C_ROF|C_OF },
-#endif
 	{ "seek",	f_seek,		C_SEEK,	 C_SEEK },
 	{ "skip",	f_skip,		C_SKIP,	 C_SKIP },
 };
@@ -207,12 +192,6 @@
 	 * if (in.offset > INT_MAX/in.dbsz || out.offset > INT_MAX/out.dbsz)
 	 *	errx(1, "seek offsets cannot be larger than %d", INT_MAX);
 	 */
-	
-#ifdef _HAVE_RUMPOPS
-	if (ddflags & C_RUMP)
-		if (rumpclient_init() == -1)
-			err(1, "rumpclient init failed");
-#endif
 }
 
 static int
@@ -285,40 +264,6 @@
 	out.name = arg;
 }
 
-#ifdef _HAVE_RUMPOPS
-#include <rump/rump.h>
-#include <rump/rump_syscalls.h>
-
-static const struct ddfops ddfops_rump = {
-	.op_open = rump_sys_open,
-	.op_close = rump_sys_close,
-	.op_fcntl = rump_sys_fcntl,
-	.op_ioctl = rump_sys_ioctl,
-	.op_fstat = rump_sys_fstat,
-	.op_fsync = rump_sys_fsync,
-	.op_ftruncate = rump_sys_ftruncate,
-	.op_lseek = rump_sys_lseek,
-	.op_read = rump_sys_read,
-	.op_write = rump_sys_write,
-};
-
-static void
-f_rif(char *arg)
-{
-
-	in.name = arg;
-	in.ops = &ddfops_rump;
-}
-
-static void
-f_rof(char *arg)
-{
-
-	out.name = arg;
-	out.ops = &ddfops_rump;
-}
-#endif
-
 static void
 f_seek(char *arg)
 {

Index: src/bin/dd/dd.c
diff -u src/bin/dd/dd.c:1.46 src/bin/dd/dd.c:1.47
--- src/bin/dd/dd.c:1.46	Thu Dec 23 21:55:40 2010
+++ src/bin/dd/dd.c	Fri Feb  4 19:42:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dd.c,v 1.46 2010/12/23 21:55:40 riz Exp $	*/
+/*	$NetBSD: dd.c,v 1.47 2011/02/04 19:42:12 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)dd.c	8.5 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: dd.c,v 1.46 2010/12/23 21:55:40 riz Exp $");
+__RCSID("$NetBSD: dd.c,v 1.47 2011/02/04 19:42:12 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -87,7 +87,10 @@
 const u_char	*ctab;			/* conversion table */
 sigset_t	infoset;		/* a set blocking SIGINFO */
 
-static const struct ddfops ddfops_host = {
+/*
+ * Ops for stdin/stdout and crunch'd dd.  These are always host ops.
+ */
+static const struct ddfops ddfops_stdfd = {
 	.op_open = open,
 	.op_close = close,
 	.op_fcntl = fcntl,
@@ -99,6 +102,7 @@
 	.op_read = read,
 	.op_write = write,
 };
+extern const struct ddfops ddfops_prog;
 
 int
 main(int argc, char *argv[])
@@ -119,6 +123,10 @@
 	argv += (optind - 1);
 
 	jcl(argv);
+#ifndef CRUNCHOPS
+	if (ddfops_prog.op_init && ddfops_prog.op_init() == -1)
+		err(1, "prog init");
+#endif
 	setup();
 
 	(void)signal(SIGINFO, summaryx);
@@ -139,15 +147,18 @@
 static void
 setup(void)
 {
+#ifdef CRUNCHOPS
+	const struct ddfops *prog_ops = &ddfops_stdfd;
+#else
+	const struct ddfops *prog_ops = &ddfops_prog;
+#endif
 
-	if (in.ops == NULL)
-		in.ops = &ddfops_host;
-	if (out.ops == NULL)
-		out.ops = &ddfops_host;
 	if (in.name == NULL) {
 		in.name = "stdin";
 		in.fd = STDIN_FILENO;
+		in.ops = &ddfops_stdfd;
 	} else {
+		in.ops = prog_ops;
 		in.fd = ddop_open(in, in.name, O_RDONLY, 0);
 		if (in.fd < 0)
 			err(EXIT_FAILURE, "%s", in.name);
@@ -168,7 +179,9 @@
 		/* No way to check for read access here. */
 		out.fd = STDOUT_FILENO;
 		out.name = "stdout";
+		out.ops = &ddfops_stdfd;
 	} else {
+		out.ops = prog_ops;
 #define	OFLAGS \
     (O_CREAT | (ddflags & (C_SEEK | C_NOTRUNC) ? 0 : O_TRUNC))
 		out.fd = ddop_open(out, out.name, O_RDWR | OFLAGS, DEFFILEMODE);

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.919 src/distrib/sets/lists/base/mi:1.920
--- src/distrib/sets/lists/base/mi:1.919	Fri Jan 28 18:52:48 2011
+++ src/distrib/sets/lists/base/mi	Fri Feb  4 19:42:12 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.919 2011/01/28 18:52:48 pooka Exp $
+# $NetBSD: mi,v 1.920 2011/02/04 19:42:12 pooka Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -24,6 +24,7 @@
 ./bin/chgrp					base-util-root
 ./bin/date					base-util-root
 ./bin/dd					base-util-root
+./bin/rump.dd					base-util-root
 ./bin/df					base-util-root
 ./bin/domainname				base-nis-root
 ./bin/echo					base-util-root

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1580 src/distrib/sets/lists/comp/mi:1.1581
--- src/distrib/sets/lists/comp/mi:1.1580	Fri Feb  4 07:32:37 2011
+++ src/distrib/sets/lists/comp/mi	Fri Feb  4 19:42:13 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1580 2011/02/04 07:32:37 yamt Exp $
+#	$NetBSD: mi,v 1.1581 2011/02/04 19:42:13 pooka Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2934,6 +2934,7 @@
 ./usr/libdata/debug/bin/csh.debug		comp-util-debug		debug
 ./usr/libdata/debug/bin/date.debug		comp-util-debug		debug
 ./usr/libdata/debug/bin/dd.debug		comp-util-debug		debug
+./usr/libdata/debug/bin/rump.dd.debug		comp-util-debug		debug
 ./usr/libdata/debug/bin/df.debug		comp-util-debug		debug
 ./usr/libdata/debug/bin/domainname.debug	comp-nis-debug		debug
 ./usr/libdata/debug/bin/echo.debug		comp-util-debug		debug

Added files:

Index: src/bin/dd/dd_hostops.c
diff -u /dev/null src/bin/dd/dd_hostops.c:1.1
--- /dev/null	Fri Feb  4 19:42:14 2011
+++ src/bin/dd/dd_hostops.c	Fri Feb  4 19:42:12 2011
@@ -0,0 +1,53 @@
+/*      $NetBSD: dd_hostops.c,v 1.1 2011/02/04 19:42:12 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: dd_hostops.c,v 1.1 2011/02/04 19:42:12 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "dd.h"
+
+const struct ddfops ddfops_prog = {
+	.op_open = open,
+	.op_close = close,
+	.op_fcntl = fcntl,
+	.op_ioctl = ioctl,
+	.op_fstat = fstat,
+	.op_fsync = fsync,
+	.op_ftruncate = ftruncate,
+	.op_lseek = lseek,
+	.op_read = read,
+	.op_write = write,
+};
Index: src/bin/dd/dd_rumpops.c
diff -u /dev/null src/bin/dd/dd_rumpops.c:1.1
--- /dev/null	Fri Feb  4 19:42:14 2011
+++ src/bin/dd/dd_rumpops.c	Fri Feb  4 19:42:12 2011
@@ -0,0 +1,52 @@
+/*      $NetBSD: dd_rumpops.c,v 1.1 2011/02/04 19:42:12 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: dd_rumpops.c,v 1.1 2011/02/04 19:42:12 pooka Exp $");
+#endif /* !lint */
+
+#include <rump/rump_syscalls.h>
+#include <rump/rumpclient.h>
+
+#include "dd.h"
+
+const struct ddfops ddfops_prog = {
+	.op_init = rumpclient_init,
+
+	.op_open = rump_sys_open,
+	.op_close = rump_sys_close,
+	.op_fcntl = rump_sys_fcntl,
+	.op_ioctl = rump_sys_ioctl,
+	.op_fstat = rump_sys_fstat,
+	.op_fsync = rump_sys_fsync,
+	.op_ftruncate = rump_sys_ftruncate,
+	.op_lseek = rump_sys_lseek,
+	.op_read = rump_sys_read,
+	.op_write = rump_sys_write,
+};

Reply via email to