From 1d798011f9f25944f7a51aa5545c37248d01dc4d Mon Sep 17 00:00:00 2001 From: haad Date: Fri, 4 Dec 2009 22:13:59 +0000 Subject: [PATCH] Add initial version of RUMP based device-mapper port. libdm compile whole device-mapper driver in userspace and allows us to test a develop new dm targets in userspace. --- sys/rump/dev/Makefile.rumpdev | 4 +- sys/rump/dev/lib/libdm/Makefile | 19 ++++++ sys/rump/dev/lib/libdm/component.c | 68 +++++++++++++++++++++ sys/rump/dev/lib/libdm/shlib_version | 4 ++ sys/rump/librump/rumpdev/rump_dev.c | 6 +- sys/rump/librump/rumpdev/rump_dev_private.h | 3 +- 6 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 sys/rump/dev/lib/libdm/Makefile create mode 100644 sys/rump/dev/lib/libdm/component.c create mode 100644 sys/rump/dev/lib/libdm/shlib_version diff --git a/sys/rump/dev/Makefile.rumpdev b/sys/rump/dev/Makefile.rumpdev index 5bacb3fa5f9b..b44d6cffc4ac 100644 --- a/sys/rump/dev/Makefile.rumpdev +++ b/sys/rump/dev/Makefile.rumpdev @@ -1,7 +1,7 @@ -# $NetBSD: Makefile.rumpdev,v 1.5 2009/10/11 11:26:40 pooka Exp $ +# $NetBSD: Makefile.rumpdev,v 1.6 2009/12/04 22:13:59 haad Exp $ # -RUMPDEVLIST= cgd disk netsmb raidframe rnd +RUMPDEVLIST= cgd disk netsmb raidframe rnd dm .for var in ${RUMPDEVLIST} RUMPDEVLIBS+=lib${var} diff --git a/sys/rump/dev/lib/libdm/Makefile b/sys/rump/dev/lib/libdm/Makefile new file mode 100644 index 000000000000..6195cbf7c504 --- /dev/null +++ b/sys/rump/dev/lib/libdm/Makefile @@ -0,0 +1,19 @@ +# $NetBSD: Makefile,v 1.1 2009/12/04 22:13:59 haad Exp $ +# + +.PATH: ${.CURDIR}/../../../../dev/dm + +LIB= rumpdev_dm + +SRCS= device-mapper.c dm_dev.c dm_ioctl.c dm_pdev.c dm_table.c dm_target.c \ + dm_target_linear.c dm_target_stripe.c + +SRCS+= component.c + +CPPFLAGS+= -Wno-pointer-sign +CPPFLAGS+= -I${RUMPTOP}/librump/rumpvfs + +LDADD+= -lrumpvfs + +.include +.include diff --git a/sys/rump/dev/lib/libdm/component.c b/sys/rump/dev/lib/libdm/component.c new file mode 100644 index 000000000000..0af10c69607f --- /dev/null +++ b/sys/rump/dev/lib/libdm/component.c @@ -0,0 +1,68 @@ +/* $NetBSD: component.c,v 1.1 2009/12/04 22:13:59 haad Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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 +__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2009/12/04 22:13:59 haad Exp $"); + +#include +#include +#include +#include +#include + +#include + + +#include "rump_dev_private.h" +#include "rump_vfs_private.h" + +void dmattach(int); + +void +rump_dev_dm_init() +{ + extern const struct bdevsw dm_bdevsw; + extern const struct cdevsw dm_cdevsw; + devmajor_t bmaj, cmaj; + int error; + + /* go, mydevfs */ + bmaj = cmaj = -1; + + if ((error = devsw_attach("dm", &dm_bdevsw, &bmaj, + &dm_cdevsw, &cmaj)) != 0) + panic("cannot attach dm: %d", error); + + do_sys_mkdir("/dev/mapper", 0770, UIO_SYSSPACE); + + if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/mapper/control", 0, + cmaj, 0, 1)) != 0) { + panic("cannot create device-mapper control device: %d", error); + + } + rump_pdev_add(dmattach, 1); +} diff --git a/sys/rump/dev/lib/libdm/shlib_version b/sys/rump/dev/lib/libdm/shlib_version new file mode 100644 index 000000000000..4e5494e46971 --- /dev/null +++ b/sys/rump/dev/lib/libdm/shlib_version @@ -0,0 +1,4 @@ +# $NetBSD: shlib_version,v 1.1 2009/12/04 22:13:59 haad Exp $ +# +major=0 +minor=0 diff --git a/sys/rump/librump/rumpdev/rump_dev.c b/sys/rump/librump/rumpdev/rump_dev.c index 740d350156d9..624039f348ff 100644 --- a/sys/rump/librump/rumpdev/rump_dev.c +++ b/sys/rump/librump/rumpdev/rump_dev.c @@ -1,4 +1,4 @@ -/* $NetBSD: rump_dev.c,v 1.8 2009/10/10 21:10:04 pooka Exp $ */ +/* $NetBSD: rump_dev.c,v 1.9 2009/12/04 22:13:59 haad Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.8 2009/10/10 21:10:04 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.9 2009/12/04 22:13:59 haad Exp $"); #include #include @@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.8 2009/10/10 21:10:04 pooka Exp $"); void nocomponent(void); void nocomponent() {} __weak_alias(rump_dev_cgd_init,nocomponent); +__weak_alias(rump_dev_dm_init,nocomponent); __weak_alias(rump_dev_raidframe_init,nocomponent); __weak_alias(rump_dev_netsmb_init,nocomponent); __weak_alias(rump_dev_rnd_init,nocomponent); @@ -55,6 +56,7 @@ rump_dev_init(void) config_init_mi(); rump_dev_cgd_init(); + rump_dev_dm_init(); rump_dev_raidframe_init(); rump_dev_netsmb_init(); rump_dev_rnd_init(); diff --git a/sys/rump/librump/rumpdev/rump_dev_private.h b/sys/rump/librump/rumpdev/rump_dev_private.h index 1583c55eac21..51a1d93bc125 100644 --- a/sys/rump/librump/rumpdev/rump_dev_private.h +++ b/sys/rump/librump/rumpdev/rump_dev_private.h @@ -1,4 +1,4 @@ -/* $NetBSD: rump_dev_private.h,v 1.6 2009/10/03 19:06:36 pooka Exp $ */ +/* $NetBSD: rump_dev_private.h,v 1.7 2009/12/04 22:13:59 haad Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -34,6 +34,7 @@ void rump_pdev_add(void (*fn)(int), int); void rump_pdev_finalize(void); void rump_dev_cgd_init(void); +void rump_dev_dm_init(void); void rump_dev_raidframe_init(void); void rump_dev_netsmb_init(void); void rump_dev_rnd_init(void);