Source-Changes-HG archive

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

[src/trunk]: src/sbin/cgdconfig Convert from the oldstyle cgd_kops.op_open to...



details:   https://anonhg.NetBSD.org/src/rev/7b2c4458d183
branches:  trunk
changeset: 759666:7b2c4458d183
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Dec 14 17:46:21 2010 +0000

description:
Convert from the oldstyle cgd_kops.op_open to the newstyle prog_open
and define RUMPPRG.  Get rid of the Makefile.inc stuff, since it was
useful only for the oldstyle regime.

diffstat:

 sbin/cgdconfig/Makefile            |  18 +++++++++-
 sbin/cgdconfig/Makefile.cgdconfig  |  32 --------------------
 sbin/cgdconfig/cgd_kernelops.c     |  47 ------------------------------
 sbin/cgdconfig/cgd_kernelops.h     |  45 ----------------------------
 sbin/cgdconfig/cgd_rumpops.c       |  49 -------------------------------
 sbin/cgdconfig/cgdconfig.c         |  38 ++++++++++--------------
 sbin/cgdconfig/cgdconfig_hostops.c |  47 ++++++++++++++++++++++++++++++
 sbin/cgdconfig/cgdconfig_rumpops.c |  49 +++++++++++++++++++++++++++++++
 sbin/cgdconfig/prog_ops.h          |  59 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 186 insertions(+), 198 deletions(-)

diffs (truncated from 526 to 300 lines):

diff -r b77f2a229db1 -r 7b2c4458d183 sbin/cgdconfig/Makefile
--- a/sbin/cgdconfig/Makefile   Tue Dec 14 17:27:32 2010 +0000
+++ b/sbin/cgdconfig/Makefile   Tue Dec 14 17:46:21 2010 +0000
@@ -1,8 +1,20 @@
-# $NetBSD: Makefile,v 1.13 2009/12/19 15:03:34 pooka Exp $
+# $NetBSD: Makefile,v 1.14 2010/12/14 17:46:21 pooka Exp $
 
-PROG=  cgdconfig
+RUMPPRG=cgdconfig
 MAN=   cgdconfig.8
 
-.include "${.CURDIR}/Makefile.cgdconfig"
+SRCS+= cgdconfig.c             \
+       cgdlex.l                \
+       cgdparse.y              \
+       pkcs5_pbkdf2.c          \
+       params.c                \
+       utils.c
+
+CPPFLAGS+= -I${.CURDIR} -I. -DYY_NO_INPUT
+
+YHEADER=1
+
+DPADD=  ${LIBUTIL} ${LIBCRYPTO} ${LIBCRYPT} ${LIBY} ${LIBL}
+LDADD=  -lutil -lcrypto -lcrypt -ly -ll
 
 .include <bsd.prog.mk>
diff -r b77f2a229db1 -r 7b2c4458d183 sbin/cgdconfig/Makefile.cgdconfig
--- a/sbin/cgdconfig/Makefile.cgdconfig Tue Dec 14 17:27:32 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#      $NetBSD: Makefile.cgdconfig,v 1.3 2010/12/05 20:13:26 pooka Exp $
-#
-
-SRCS+= cgdconfig.c             \
-       cgdlex.l                \
-       cgdparse.y              \
-       pkcs5_pbkdf2.c          \
-       params.c                \
-       utils.c
-
-CPPFLAGS+= -I${.CURDIR} -I. -DYY_NO_INPUT
-
-YHEADER=1
-
-DPADD=  ${LIBUTIL} ${LIBCRYPTO} ${LIBCRYPT} ${LIBY} ${LIBL}
-LDADD=  -lutil -lcrypto -lcrypt -ly -ll
-
-.include <bsd.own.mk>
-
-CGDCONFIGDIR=  ${NETBSDSRCDIR}/sbin/cgdconfig
-
-.PATH: ${CGDCONFIGDIR}
-
-CPPFLAGS+=     -I${CGDCONFIGDIR}
-
-.ifdef RUMP_ACTION
-LDADD+= -lrumpdev_cgd -lrumpdev_disk -lrumpdev -lrumpkern_crypto
-LDADD+= -lrumpvfs -lrump -lrumpuser -lpthread
-SRCS+= cgd_rumpops.c
-.else
-SRCS+= cgd_kernelops.c
-.endif
diff -r b77f2a229db1 -r 7b2c4458d183 sbin/cgdconfig/cgd_kernelops.c
--- a/sbin/cgdconfig/cgd_kernelops.c    Tue Dec 14 17:27:32 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*     $NetBSD: cgd_kernelops.c,v 1.2 2009/10/13 22:04:31 pooka Exp $  */
-
-/*
- * Copyright (c) 2009 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: cgd_kernelops.c,v 1.2 2009/10/13 22:04:31 pooka Exp $");
-#endif /* !lint */
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "cgd_kernelops.h"
-
-const struct cgd_kernelops cgd_kops = {
-       .ko_open = open,
-       .ko_ioctl = ioctl,
-       .ko_pread = pread,
-       .ko_close = close,
-};
diff -r b77f2a229db1 -r 7b2c4458d183 sbin/cgdconfig/cgd_kernelops.h
--- a/sbin/cgdconfig/cgd_kernelops.h    Tue Dec 14 17:27:32 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*      $NetBSD: cgd_kernelops.h,v 1.3 2009/10/13 22:04:31 pooka Exp $ */
-
-/*
- * Copyright (c) 2009 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 _CGD_KERNEL_OPS_H_
-#define _CGD_KERNEL_OPS_H_
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <fcntl.h>
-
-struct cgd_kernelops {
-       int (*ko_open)(const char *, int, ...);
-       int (*ko_ioctl)(int, unsigned long, ...);
-       int (*ko_close)(int);
-       ssize_t (*ko_pread)(int, void *, size_t, off_t);
-};
-extern const struct cgd_kernelops cgd_kops;
-
-#endif /* _CGD_KERNEL_OPS_H_ */
diff -r b77f2a229db1 -r 7b2c4458d183 sbin/cgdconfig/cgd_rumpops.c
--- a/sbin/cgdconfig/cgd_rumpops.c      Tue Dec 14 17:27:32 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*     $NetBSD: cgd_rumpops.c,v 1.1 2009/12/19 15:03:34 pooka Exp $    */
-
-/*
- * Copyright (c) 2009 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: cgd_rumpops.c,v 1.1 2009/12/19 15:03:34 pooka Exp $");
-#endif /* !lint */
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <rump/rump_syscalls.h>
-
-#include "cgd_kernelops.h"
-
-const struct cgd_kernelops cgd_kops = {
-       .ko_open = rump_sys_open,
-       .ko_ioctl = rump_sys_ioctl,
-       .ko_pread = rump_sys_pread,
-       .ko_close = rump_sys_close,
-};
diff -r b77f2a229db1 -r 7b2c4458d183 sbin/cgdconfig/cgdconfig.c
--- a/sbin/cgdconfig/cgdconfig.c        Tue Dec 14 17:27:32 2010 +0000
+++ b/sbin/cgdconfig/cgdconfig.c        Tue Dec 14 17:46:21 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgdconfig.c,v 1.31 2010/12/02 18:02:58 elric Exp $ */
+/* $NetBSD: cgdconfig.c,v 1.32 2010/12/14 17:46:21 pooka Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2002, 2003\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: cgdconfig.c,v 1.31 2010/12/02 18:02:58 elric Exp $");
+__RCSID("$NetBSD: cgdconfig.c,v 1.32 2010/12/14 17:46:21 pooka Exp $");
 #endif
 
 #include <err.h>
@@ -59,8 +59,8 @@
 #include "params.h"
 #include "pkcs5_pbkdf2.h"
 #include "utils.h"
-#include "cgd_kernelops.h"
 #include "cgdconfig.h"
+#include "prog_ops.h"
 
 #define CGDCONFIG_DIR          "/etc/cgd"
 #define CGDCONFIG_CFILE                CGDCONFIG_DIR "/cgd.conf"
@@ -170,18 +170,9 @@
        *action = value;
 }
 
-#ifndef CGDCONFIG_AS_LIB
 int
 main(int argc, char **argv)
 {
-
-       return cgdconfig(argc, argv);
-}
-#endif
-
-int
-cgdconfig(int argc, char *argv[])
-{
        struct params *p;
        struct params *tp;
        struct keygen *kg;
@@ -278,6 +269,9 @@
        if (!cfile)
                cfile = "";
 
+       if (prog_init && prog_init() == -1)
+               err(1, "init failed");
+
        /* validate the consistency of the arguments */
 
        switch (action) {
@@ -458,7 +452,7 @@
        if (flags == CONFIG_FLAGS_FROMALL && (argc < 2 || argc > 3))
                return -1;
 
-       fd = opendisk1(*argv, O_RDWR, buf, sizeof(buf), 1, cgd_kops.ko_open);
+       fd = opendisk1(*argv, O_RDWR, buf, sizeof(buf), 1, prog_open);
        if (fd == -1) {
                int saved_errno = errno;
 
@@ -475,7 +469,7 @@
                return 0;
 
        ret = unconfigure_fd(fd);
-       (void)cgd_kops.ko_close(fd);
+       (void)prog_close(fd);
        return ret;
 }
 
@@ -484,7 +478,7 @@
 {
        struct  cgd_ioctl ci;
 
-       if (cgd_kops.ko_ioctl(fd, CGDIOCCLR, &ci) == -1) {
+       if (prog_ioctl(fd, CGDIOCCLR, &ci) == -1) {
                warn("ioctl");
                return -1;
        }



Home | Main Index | Thread Index | Old Index