Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Remove the rif/rof options and add rump.dd. This makes usage



details:   https://anonhg.NetBSD.org/src/rev/8661d3129042
branches:  trunk
changeset: 761667:8661d3129042
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Feb 04 19:42:12 2011 +0000

description:
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!)

diffstat:

 bin/dd/Makefile            |   4 +-
 bin/dd/args.c              |  63 ++-------------------------------------------
 bin/dd/dd.c                |  27 ++++++++++++++-----
 bin/dd/dd.h                |   7 ++--
 bin/dd/dd_hostops.c        |  53 ++++++++++++++++++++++++++++++++++++++
 bin/dd/dd_rumpops.c        |  52 +++++++++++++++++++++++++++++++++++++
 distrib/sets/lists/base/mi |   3 +-
 distrib/sets/lists/comp/mi |   3 +-
 8 files changed, 138 insertions(+), 74 deletions(-)

diffs (truncated from 383 to 300 lines):

diff -r b1b6664f1825 -r 8661d3129042 bin/dd/Makefile
--- a/bin/dd/Makefile   Fri Feb 04 17:38:15 2011 +0000
+++ b/bin/dd/Makefile   Fri Feb 04 19:42:12 2011 +0000
@@ -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}
diff -r b1b6664f1825 -r 8661d3129042 bin/dd/args.c
--- a/bin/dd/args.c     Fri Feb 04 17:38:15 2011 +0000
+++ b/bin/dd/args.c     Fri Feb 04 19:42:12 2011 +0000
@@ -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)
 {
diff -r b1b6664f1825 -r 8661d3129042 bin/dd/dd.c
--- a/bin/dd/dd.c       Fri Feb 04 17:38:15 2011 +0000
+++ b/bin/dd/dd.c       Fri Feb 04 19:42:12 2011 +0000
@@ -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);
diff -r b1b6664f1825 -r 8661d3129042 bin/dd/dd.h
--- a/bin/dd/dd.h       Fri Feb 04 17:38:15 2011 +0000
+++ b/bin/dd/dd.h       Fri Feb 04 19:42:12 2011 +0000
@@ -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
diff -r b1b6664f1825 -r 8661d3129042 bin/dd/dd_hostops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/dd/dd_hostops.c       Fri Feb 04 19:42:12 2011 +0000
@@ -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,
+};
diff -r b1b6664f1825 -r 8661d3129042 bin/dd/dd_rumpops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/dd/dd_rumpops.c       Fri Feb 04 19:42:12 2011 +0000
@@ -0,0 +1,52 @@
+/*      $NetBSD: dd_rumpops.c,v 1.1 2011/02/04 19:42:12 pooka Exp $    */
+
+/*-



Home | Main Index | Thread Index | Old Index