CVS commit: src/share/examples/rump

2016-01-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jan 25 11:01:17 UTC 2016

Modified Files:
src/share/examples/rump/ttyserv: Makefile
src/share/examples/rump/umserv: Makefile

Log Message:
add -D_KERNTYPES


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/ttyserv/Makefile
cvs rdiff -u -r1.3 -r1.4 src/share/examples/rump/umserv/Makefile

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

Modified files:

Index: src/share/examples/rump/ttyserv/Makefile
diff -u src/share/examples/rump/ttyserv/Makefile:1.2 src/share/examples/rump/ttyserv/Makefile:1.3
--- src/share/examples/rump/ttyserv/Makefile:1.2	Mon Jun 14 14:48:51 2010
+++ src/share/examples/rump/ttyserv/Makefile	Mon Jan 25 11:01:17 2016
@@ -5,6 +5,8 @@ LDADD+=-lrumpkern_tty
 LDADD+=-lrumpvfs
 LDADD+=-lrump -lrumpuser -lpthread
 
+CPPFLAGS+= -D_KERNTYPES
+
 WARNS=4
 DBG=-g
 

Index: src/share/examples/rump/umserv/Makefile
diff -u src/share/examples/rump/umserv/Makefile:1.3 src/share/examples/rump/umserv/Makefile:1.4
--- src/share/examples/rump/umserv/Makefile:1.3	Mon Aug 23 20:56:27 2010
+++ src/share/examples/rump/umserv/Makefile	Mon Jan 25 11:01:17 2016
@@ -5,6 +5,8 @@ LDADD+=-lrumpdev_disk -lrumpdev
 LDADD+=-lrumpvfs
 LDADD+=-lrump -lrumpuser -lpthread
 
+CPPFLAGS+= -D_KERNTYPES
+
 WARNS=4
 DBG=-g
 



CVS commit: src/share/examples/rump

2010-11-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov 11 23:04:24 UTC 2010

Added Files:
src/share/examples/rump: README

Log Message:
Add readme explaining which grue has ok'd the eating of some code
until recently located here.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/README

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

Added files:

Index: src/share/examples/rump/README
diff -u /dev/null src/share/examples/rump/README:1.1
--- /dev/null	Thu Nov 11 23:04:24 2010
+++ src/share/examples/rump/README	Thu Nov 11 23:04:24 2010
@@ -0,0 +1,8 @@
+	$NetBSD: README,v 1.1 2010/11/11 23:04:24 pooka Exp $
+
+
+This directory contains various examples on how to interface with
+a rump kernel.  Another place which contains even more examples
+is src/tests and its subdirectories.  Some programs which were
+located here have in fact been moved to src/tests to serve as
+automated tests.



CVS commit: src/share/examples/rump

2010-11-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov 11 23:01:01 UTC 2010

Modified Files:
src/share/examples/rump: Makefile
Removed Files:
src/share/examples/rump/img2cgd: Makefile cgd.conf img2cgd.c
src/share/examples/rump/pad_nothai: Makefile musa.c pad_nothai.c
src/share/examples/rump/swwdog_arm: Makefile swwdog_arm.c

Log Message:
Remove some programs which live as atf tests now.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/examples/rump/Makefile
cvs rdiff -u -r1.2 -r0 src/share/examples/rump/img2cgd/Makefile
cvs rdiff -u -r1.1 -r0 src/share/examples/rump/img2cgd/cgd.conf
cvs rdiff -u -r1.3 -r0 src/share/examples/rump/img2cgd/img2cgd.c
cvs rdiff -u -r1.1 -r0 src/share/examples/rump/pad_nothai/Makefile \
src/share/examples/rump/pad_nothai/musa.c \
src/share/examples/rump/pad_nothai/pad_nothai.c
cvs rdiff -u -r1.1 -r0 src/share/examples/rump/swwdog_arm/Makefile \
src/share/examples/rump/swwdog_arm/swwdog_arm.c

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

Modified files:

Index: src/share/examples/rump/Makefile
diff -u src/share/examples/rump/Makefile:1.5 src/share/examples/rump/Makefile:1.6
--- src/share/examples/rump/Makefile:1.5	Sat May  1 23:31:01 2010
+++ src/share/examples/rump/Makefile	Thu Nov 11 23:01:00 2010
@@ -1,7 +1,7 @@
-#	$NetBSD: Makefile,v 1.5 2010/05/01 23:31:01 pooka Exp $
+#	$NetBSD: Makefile,v 1.6 2010/11/11 23:01:00 pooka Exp $
 #
 
-SUBDIR=	btplay img2cgd pad_nothai sdread swwdog_arm tipsy ttyserv	\
+SUBDIR=	btplay sdread tipsy ttyserv	\
 	ulptprint umserv ukbd_read ums_draw wirelessconf
 
 .include 



CVS commit: src/share/examples/rump

2010-08-23 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Aug 23 20:56:27 UTC 2010

Modified Files:
src/share/examples/rump/sdread: Makefile
src/share/examples/rump/umserv: Makefile

Log Message:
update component lists: scsipi is independent of umass now


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/examples/rump/sdread/Makefile
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/umserv/Makefile

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

Modified files:

Index: src/share/examples/rump/sdread/Makefile
diff -u src/share/examples/rump/sdread/Makefile:1.5 src/share/examples/rump/sdread/Makefile:1.6
--- src/share/examples/rump/sdread/Makefile:1.5	Wed Feb 17 20:43:35 2010
+++ src/share/examples/rump/sdread/Makefile	Mon Aug 23 20:56:27 2010
@@ -1,10 +1,11 @@
-#	$NetBSD: Makefile,v 1.5 2010/02/17 20:43:35 pooka Exp $
+#	$NetBSD: Makefile,v 1.6 2010/08/23 20:56:27 pooka Exp $
 #
 
 PROG=	sdread
 
 LDADD+=	-lrumpfs_cd9660 -lrumpfs_ffs -lrumpfs_msdos -lrumpvfs
-LDADD+=	-lrumpdev_disk -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev_umass -lrumpdev
+LDADD+=	-lrumpdev_disk -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev_umass
+LDADD+=	-lrumpdev_scsipi -lrumpdev
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread
 

Index: src/share/examples/rump/umserv/Makefile
diff -u src/share/examples/rump/umserv/Makefile:1.2 src/share/examples/rump/umserv/Makefile:1.3
--- src/share/examples/rump/umserv/Makefile:1.2	Wed Feb 10 02:31:01 2010
+++ src/share/examples/rump/umserv/Makefile	Mon Aug 23 20:56:27 2010
@@ -1,6 +1,7 @@
 PROG=umserv
 NOMAN=
-LDADD+=-lrumpdev_ugenhc -lrumpdev_umass -lrumpdev_usb -lrumpdev_disk -lrumpdev
+LDADD+=-lrumpdev_ugenhc -lrumpdev_umass -lrumpdev_scsipi -lrumpdev_usb
+LDADD+=-lrumpdev_disk -lrumpdev
 LDADD+=-lrumpvfs
 LDADD+=-lrump -lrumpuser -lpthread
 



CVS commit: src/share/examples/rump/virtual_ip_router

2010-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Jul  4 17:24:10 UTC 2010

Modified Files:
src/share/examples/rump/virtual_ip_router: rumprouter.c

Log Message:
send routing messages via routing sucket -- works better than via inet sucket


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/share/examples/rump/virtual_ip_router/rumprouter.c

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

Modified files:

Index: src/share/examples/rump/virtual_ip_router/rumprouter.c
diff -u src/share/examples/rump/virtual_ip_router/rumprouter.c:1.4 src/share/examples/rump/virtual_ip_router/rumprouter.c:1.5
--- src/share/examples/rump/virtual_ip_router/rumprouter.c:1.4	Sun Jul  4 15:44:46 2010
+++ src/share/examples/rump/virtual_ip_router/rumprouter.c	Sun Jul  4 17:24:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumprouter.c,v 1.4 2010/07/04 15:44:46 pooka Exp $	*/
+/*	$NetBSD: rumprouter.c,v 1.5 2010/07/04 17:24:10 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -126,7 +126,7 @@
 	DP("Entering %s\n", __FUNCTION__);
 
 	DP("Open a routing socket\n");
-	s = rump_sys_socket(PF_INET, SOCK_DGRAM, 0);
+	s = rump_sys_socket(PF_ROUTE, SOCK_RAW, 0);
 	if (s == -1) {
 		err(1, "rump_sys_socket");
 	}



CVS commit: src/share/examples/rump

2010-06-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jun 14 14:48:51 UTC 2010

Modified Files:
src/share/examples/rump/tipsy: Makefile
src/share/examples/rump/ttyserv: Makefile

Log Message:
tty support is in rumpkern_tty now


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/tipsy/Makefile
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/ttyserv/Makefile

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

Modified files:

Index: src/share/examples/rump/tipsy/Makefile
diff -u src/share/examples/rump/tipsy/Makefile:1.2 src/share/examples/rump/tipsy/Makefile:1.3
--- src/share/examples/rump/tipsy/Makefile:1.2	Wed Feb 10 02:31:00 2010
+++ src/share/examples/rump/tipsy/Makefile	Mon Jun 14 14:48:51 2010
@@ -1,10 +1,11 @@
-#	$NetBSD: Makefile,v 1.2 2010/02/10 02:31:00 pooka Exp $
+#	$NetBSD: Makefile,v 1.3 2010/06/14 14:48:51 pooka Exp $
 #
 
 PROG=	tipsy
 
 LDADD+=	-lrumpvfs
 LDADD+=	-lrumpdev_usb -lrumpdev_ugenhc -lrumpdev_ucom -lrumpdev
+LDADD+=	-lrumpkern_tty
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread
 

Index: src/share/examples/rump/ttyserv/Makefile
diff -u src/share/examples/rump/ttyserv/Makefile:1.1 src/share/examples/rump/ttyserv/Makefile:1.2
--- src/share/examples/rump/ttyserv/Makefile:1.1	Sun Mar  7 23:28:14 2010
+++ src/share/examples/rump/ttyserv/Makefile	Mon Jun 14 14:48:51 2010
@@ -1,6 +1,7 @@
 PROG=ttyserv
 NOMAN=
 LDADD+=-lrumpdev_ucom -lrumpdev_ugenhc -lrumpdev_usb -lrumpdev
+LDADD+=-lrumpkern_tty
 LDADD+=-lrumpvfs
 LDADD+=-lrump -lrumpuser -lpthread
 



CVS commit: src/share/examples/rump/virtual_ip_router

2010-03-29 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 29 11:01:17 UTC 2010

Modified Files:
src/share/examples/rump/virtual_ip_router: rumprouter.c

Log Message:
fix typo in, um, copyright.

spotted by a keen-eyed enthusiast ;)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/share/examples/rump/virtual_ip_router/rumprouter.c

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

Modified files:

Index: src/share/examples/rump/virtual_ip_router/rumprouter.c
diff -u src/share/examples/rump/virtual_ip_router/rumprouter.c:1.1 src/share/examples/rump/virtual_ip_router/rumprouter.c:1.2
--- src/share/examples/rump/virtual_ip_router/rumprouter.c:1.1	Mon Mar 29 02:01:47 2010
+++ src/share/examples/rump/virtual_ip_router/rumprouter.c	Mon Mar 29 11:01:16 2010
@@ -1,9 +1,9 @@
-/*	$NetBSD: rumprouter.c,v 1.1 2010/03/29 02:01:47 pooka Exp $	*/
+/*	$NetBSD: rumprouter.c,v 1.2 2010/03/29 11:01:16 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
  *
- * Development of this software was supported by then
+ * Development of this software was supported by the
  * Finnish Cultural Foundation.
  *
  * Redistribution and use in source and binary forms, with or without



CVS commit: src/share/examples/rump/virtual_ip_router

2010-03-28 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 29 02:11:15 UTC 2010

Modified Files:
src/share/examples/rump/virtual_ip_router: README.txt
Added Files:
src/share/examples/rump/virtual_ip_router: startrouters.sh

Log Message:
amazing grep, how sweet the find
that saved a hack like me
script once was lost but now it's found
was -x, but now I sh


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/virtual_ip_router/README.txt
cvs rdiff -u -r0 -r1.1 \
src/share/examples/rump/virtual_ip_router/startrouters.sh

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

Modified files:

Index: src/share/examples/rump/virtual_ip_router/README.txt
diff -u src/share/examples/rump/virtual_ip_router/README.txt:1.1 src/share/examples/rump/virtual_ip_router/README.txt:1.2
--- src/share/examples/rump/virtual_ip_router/README.txt:1.1	Mon Mar 29 02:01:47 2010
+++ src/share/examples/rump/virtual_ip_router/README.txt	Mon Mar 29 02:11:14 2010
@@ -1,4 +1,4 @@
-	$NetBSD: README.txt,v 1.1 2010/03/29 02:01:47 pooka Exp $
+	$NetBSD: README.txt,v 1.2 2010/03/29 02:11:14 pooka Exp $
 
 Using rump it is possible to build a router test setup consisting
 of thousands of NetBSD IP stacks within a single host OS, one
@@ -92,8 +92,7 @@
 ./a.out 10.0.253.1 10.0.253.255 /tmp/rumpshm_253 10.0.253.2 10.0.255.1 10.0.255.
 255 /tmp/rumpshm_255 0
 
-Unfortunately I lost script used to produce that, but the algorithm
-is quickly obvious.
+(see startrouters.sh for a script to produce that output)
 
 Easy but slightly more interesting setups, such as a M^N matrix
 (hyper-matrix?) are also possible, but left as an exercise to the

Added files:

Index: src/share/examples/rump/virtual_ip_router/startrouters.sh
diff -u /dev/null src/share/examples/rump/virtual_ip_router/startrouters.sh:1.1
--- /dev/null	Mon Mar 29 02:11:15 2010
+++ src/share/examples/rump/virtual_ip_router/startrouters.sh	Mon Mar 29 02:11:14 2010
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+#	$NetBSD: startrouters.sh,v 1.1 2010/03/29 02:11:14 pooka Exp $
+#
+
+dummy=
+amp="&"
+LIF="10.0.XXX.1"
+LBCAST="10.0.XXX.255"
+LFILE="/tmp/rumpshm_XXX"
+LROUTE="10.0.XXX.2"
+
+RIF="10.0.YYY.2"
+RBCAST="10.0.YYY.255"
+RFILE="/tmp/rumpshm_YYY"
+RROUTE="10.0.YYY.1"
+
+die ()
+{
+
+	echo $1
+	exit 1
+}
+
+[ $# != "1" ] && die "usage: script.sh nrouters"
+n=${1}
+
+[ "$n" -lt "1" ] && die "n must be between 1 and 254"
+[ "$n" -gt "254" ] && die "n must be between 1 and 254"
+
+pkill a.out
+rm /tmp/rumpshm_*
+rm -f cmds
+
+i=1
+ip=0
+while [ ${i} -le ${n} ]
+do
+	lif=`echo ${LIF} | sed "s/XXX/${ip}/"`
+	lbcast=`echo ${LBCAST} | sed "s/XXX/${ip}/"`
+	lfile=`echo ${LFILE} | sed "s/XXX/${ip}/"`
+	lroute=`echo ${LROUTE} | sed "s/XXX/${ip}/"`
+
+	rif=`echo ${RIF} | sed "s/YYY/${i}/"`
+	rbcast=`echo ${RBCAST} | sed "s/YYY/${i}/"`
+	rfile=`echo ${RFILE} | sed "s/YYY/${i}/"`
+	rroute=`echo ${RROUTE} | sed "s/YYY/${i}/"`
+
+	if [ $i = 1 ]
+	then
+		lroute="0"
+	fi
+
+	if [ $i = $n ]
+	then
+		rif="10.0.255.1"
+		rbcast="10.0.255.255"
+		rfile="/tmp/rumpshm_255"
+		rroute="0"
+	fi
+
+	echo ./a.out ${lif} ${lbcast} ${lfile} ${lroute} ${rif} ${rbcast} ${rfile} ${rroute} >> cmds
+
+	ip=${i}
+	i=$((i+1))
+done
+
+#echo ./specialpint send tcp 10.0.255.10 >> cmds



CVS commit: src/share/examples/rump/virtual_ip_router

2010-03-28 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 29 02:01:47 UTC 2010

Added Files:
src/share/examples/rump/virtual_ip_router: README.txt rumprouter.c

Log Message:
Add an example for a rump router cluster setup along with a README.

some contributions to the code from Martti Kuparinen


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/virtual_ip_router/README.txt \
src/share/examples/rump/virtual_ip_router/rumprouter.c

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

Added files:

Index: src/share/examples/rump/virtual_ip_router/README.txt
diff -u /dev/null src/share/examples/rump/virtual_ip_router/README.txt:1.1
--- /dev/null	Mon Mar 29 02:01:47 2010
+++ src/share/examples/rump/virtual_ip_router/README.txt	Mon Mar 29 02:01:47 2010
@@ -0,0 +1,107 @@
+	$NetBSD: README.txt,v 1.1 2010/03/29 02:01:47 pooka Exp $
+
+Using rump it is possible to build a router test setup consisting
+of thousands of NetBSD IP stacks within a single host OS, one
+networking stack per application process.  Each IP stack instance
+has its own set of interfaces, addresses and routing tables.  These
+instances may or may not share the same code, i.e. it is possible
+to do compatibility testing of new features.  The advantage over
+using full-fledged virtual OS setups (qemu, Xen, etc.) is scalability:
+the rump IP router base runtime takes less than 500kB of memory
+per instance.
+
+The code is _ONLY AN EXAMPLE_ as opposed a fully featured test kit.
+Some code tweaking is probably required to make this do what you
+want.  Usage examples follow.
+
+To use one single rump networking stack instance with access to
+two real networks, you need tap and bridge on the host system (yes,
+this involves some memory copies.  the resulting router setup can
+still saturate a GigE, though.  it should not be difficult to bring
+performance to be ~the same as an in-kernel stack, but haven't
+managed to implement that yet).
+
+Anyway, the following can be done with the current code:
+
+/*
+ * Usage:
+ *
+ * # ifconfig yourrealif0 up
+ * # ifconfig tap0 create
+ * # ifconfig tap0 up
+ * # ifconfig bridge0 create
+ * # brconfig bridge0 add tap0 add yourrealif0
+ * # brconfig bridge0 up
+ * #
+ * # ifconfig yourrealif1 up
+ * # ifconfig tap1 create
+ * # ifconfig tap1 up
+ * # ifconfig bridge1 create
+ * # brconfig bridge1 add tap1 add yourrealif1
+ * # brconfig bridge1 up
+ * #
+ * # ./router virt0 192.168.1.1 255.255.255.0 192.168.1.255 \
+ * #  virt1 192.168.2.1 255.255.255.0 192.168.2.255
+ *
+ * This will bind virtN to tapN and act as a router.
+ */
+
+As brilliant ascii art, it would look something like this:
+
+   network network
+  ^   ^
+  |   |
+ /v-\/v\
+ kernel  | realif0 <-> tap0 || tap1 -> realif1 |
+ \---^--/\---^-/
+-|---|
+/v---v\
+   user | virt0 <-> rump IP <-> virt1 |
+		\-/
+
+(ok, no more drawing)
+
+The addresses configured to the rump virt0 and virt1 interfaces
+will be visible on the physical network, and their traffic can be
+examined with e.g. wireshark.   You can also use wireshark on
+tap0/tap1.
+
+The alternate approach is to use purely internal simulation.  The
+shmif rump driver uses a memory-mapped file as an ethernet "bus"
+between multiple rump networking stack instances.  Just use
+rump_pub_shmif_create() in the code.  This can also of course be
+combined with the tap setup, and you can have setups where border
+nodes talk to an internal mesh of shmif's.  Semi-drawn, it looks
+like this:
+
+net1 <-> virt0, shm0 <-> shm1, shm2 <->  <-> shmN, virt1 <-> net1
+   (rump0) (rump1)    (rumpN)
+
+Linear setups (where router n talks to exactly router n-1 and n+1)
+can be easily autogenerated.  Here's a snippet of executed commands
+I used to start a few hundred routers (NOTE! the usage of the
+example code is different!):
+
+./a.out 10.0.0.1 10.0.0.255 /tmp/rumpshm_0 0 10.0.1.2 10.0.1.255 /tmp/rumpshm_1 10.0.1.1
+./a.out 10.0.1.1 10.0.1.255 /tmp/rumpshm_1 10.0.1.2 10.0.2.2 10.0.2.255 /tmp/rumpshm_2 10.0.2.1
+./a.out 10.0.2.1 10.0.2.255 /tmp/rumpshm_2 10.0.2.2 10.0.3.2 10.0.3.255 /tmp/rumpshm_3 10.0.3.1
+./a.out 10.0.3.1 10.0.3.255 /tmp/rumpshm_3 10.0.3.2 10.0.4.2 10.0.4.255 /tmp/rumpshm_4 10.0.4.1
+
+./a.out 10.0.252.1 10.0.252.255 /tmp/rumpshm_252 10.0.252.2 10.0.253.2 10.0.253.
+255 /tmp/rumpshm_253 10.0.253.1
+./a.out 10.0.253.1 10.0.253.255 /tmp/rumpshm_253 10.0.253.2 10.0.255.1 10.0.255.
+255 /tmp/rumpshm_255 0
+
+Unfortunately I lost script used to produce that, but the a

CVS commit: src/share/examples/rump/sdread

2010-03-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 25 15:00:20 UTC 2010

Modified Files:
src/share/examples/rump/sdread: sdread.c

Log Message:
Check open return value and close fd when we're done.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/examples/rump/sdread/sdread.c

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

Modified files:

Index: src/share/examples/rump/sdread/sdread.c
diff -u src/share/examples/rump/sdread/sdread.c:1.5 src/share/examples/rump/sdread/sdread.c:1.6
--- src/share/examples/rump/sdread/sdread.c:1.5	Mon Mar 22 20:37:26 2010
+++ src/share/examples/rump/sdread/sdread.c	Thu Mar 25 15:00:20 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdread.c,v 1.5 2010/03/22 20:37:26 pooka Exp $	*/
+/*	$NetBSD: sdread.c,v 1.6 2010/03/25 15:00:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -63,6 +63,9 @@
 	int fd, val = 0, rounds = 0;
 
 	fd = rump_sys_open("/dev/rcd0d", O_RDWR);
+	if (fd == -1)
+		return;
+
 	do {
 		if (rounds > 0) {
 			if (rounds == 1) {
@@ -82,6 +85,8 @@
 		printf(" giving up\n");
 	else
 		printf(" done!\n");
+
+	rump_sys_close(fd);
 }
 
 int



CVS commit: src/share/examples/rump/sdread

2010-03-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 22 20:37:26 UTC 2010

Modified Files:
src/share/examples/rump/sdread: sdread.c

Log Message:
Use DIOCTUR to test if a newly configured CD drive is ready instead
of playing a random waiting game.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/examples/rump/sdread/sdread.c

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

Modified files:

Index: src/share/examples/rump/sdread/sdread.c
diff -u src/share/examples/rump/sdread/sdread.c:1.4 src/share/examples/rump/sdread/sdread.c:1.5
--- src/share/examples/rump/sdread/sdread.c:1.4	Sun Mar  7 23:18:17 2010
+++ src/share/examples/rump/sdread/sdread.c	Mon Mar 22 20:37:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdread.c,v 1.4 2010/03/07 23:18:17 pooka Exp $	*/
+/*	$NetBSD: sdread.c,v 1.5 2010/03/22 20:37:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -51,6 +52,38 @@
  * rump kernel.  Optionally copy a file out of the mounted file system.
  */
 
+/* recent -current, appease 5.0 etc. userland */
+#ifndef DIOCTUR
+#define DIOCTUR _IOR('d', 128, int)
+#endif
+
+static void
+waitcd(void)
+{
+	int fd, val = 0, rounds = 0;
+
+	fd = rump_sys_open("/dev/rcd0d", O_RDWR);
+	do {
+		if (rounds > 0) {
+			if (rounds == 1) {
+printf("Waiting for CD device to settle ");
+			} else {
+printf(".");
+			}
+			fflush(stdout);
+			sleep(1);
+		} 
+		if (rump_sys_ioctl(fd, DIOCTUR, &val) == -1)
+			err(1, "DIOCTUR");
+		rounds++;
+	} while (val == 0 || rounds >= 30);
+
+	if (!val)
+		printf(" giving up\n");
+	else
+		printf(" done!\n");
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -96,13 +129,11 @@
 	&args, sizeof(args)) == -1) {
 		if (rump_sys_mount(MOUNT_FFS, "/mp", MNT_RDONLY,
 		&uargs, sizeof(uargs)) == -1) {
-			printf("Trying CD.  This might fail with "
-			"\"media not present\".\n");
-			printf("If that happens, wait a while without "
-			"unplugging the device and re-run.\n");
-			printf("Some devices apparently need a long time "
-			"to settle after they are initialized.\n\n");
-
+			/*
+			 * Wait for CD media to settle.  In the end,
+			 * just try to do it anyway and see if we fail.
+			 */
+			waitcd();
 			if (rump_sys_mount(MOUNT_CD9660, "/mp", MNT_RDONLY,
 			&iargs, sizeof(iargs)) == -1) {
 err(1, "mount");



CVS commit: src/share/examples/rump

2010-03-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 22 12:21:37 UTC 2010

Modified Files:
src/share/examples/rump: Makefile
Added Files:
src/share/examples/rump/btplay: Makefile btplay.c

Log Message:
Add an example/test program for rump bluetooth.  This does discovery
and prints the address and name of the first peer encountered (if any):

ubt0 at uhub0 port 1
ubt0: Cambridge Silicon Radio Bluetooth USB Adapter, rev 2.00/19.15, addr 2
device ubt0, addr xx:xx:xx:xx:xx:xx
my peer: yy:yy:yy:yy:yy:yy, major class: 2 (phone)
peer name: Mokia maailmalta


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/share/examples/rump/Makefile
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/btplay/Makefile \
src/share/examples/rump/btplay/btplay.c

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

Modified files:

Index: src/share/examples/rump/Makefile
diff -u src/share/examples/rump/Makefile:1.3 src/share/examples/rump/Makefile:1.4
--- src/share/examples/rump/Makefile:1.3	Sun Mar  7 23:28:14 2010
+++ src/share/examples/rump/Makefile	Mon Mar 22 12:21:37 2010
@@ -1,7 +1,7 @@
-#	$NetBSD: Makefile,v 1.3 2010/03/07 23:28:14 pooka Exp $
+#	$NetBSD: Makefile,v 1.4 2010/03/22 12:21:37 pooka Exp $
 #
 
-SUBDIR=	img2cgd sdread swwdog_arm tipsy ttyserv ulptprint umserv	\
+SUBDIR=	btplay img2cgd sdread swwdog_arm tipsy ttyserv ulptprint umserv	\
 	ukbd_read ums_draw wirelessconf
 
 .include 

Added files:

Index: src/share/examples/rump/btplay/Makefile
diff -u /dev/null src/share/examples/rump/btplay/Makefile:1.1
--- /dev/null	Mon Mar 22 12:21:37 2010
+++ src/share/examples/rump/btplay/Makefile	Mon Mar 22 12:21:37 2010
@@ -0,0 +1,16 @@
+#	$NetBSD: Makefile,v 1.1 2010/03/22 12:21:37 pooka Exp $
+#
+
+PROG=	btplay
+
+LDADD+=	-lrumpdev_ubt -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev
+LDADD+=	-lrumpnet_netbt -lrumpnet
+LDADD+=	-lrump
+LDADD+=	-lrumpuser -lpthread
+LDADD+=	-lbluetooth
+
+DBG=	-g
+NOMAN=	
+WARNS=	4
+
+.include 
Index: src/share/examples/rump/btplay/btplay.c
diff -u /dev/null src/share/examples/rump/btplay/btplay.c:1.1
--- /dev/null	Mon Mar 22 12:21:37 2010
+++ src/share/examples/rump/btplay/btplay.c	Mon Mar 22 12:21:37 2010
@@ -0,0 +1,191 @@
+/*  $NetBSD: btplay.c,v 1.1 2010/03/22 12:21:37 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 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.
+ */
+
+/*
+ * Little demo showing how to use bluetooth stack in rump.  Searches
+ * for a peer and prints a little info for it.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+const char *btclasses[] = {
+	"misc.",
+	"computer",
+	"phone",
+	"LAN",
+	"audio-video",
+	"peripheral",
+	"imaging",
+	"wearable",
+	"toy",
+};
+
+int
+main(int argc, char *argv[])
+{
+	struct sockaddr_bt sbt;
+	bdaddr_t peeraddr;
+	uint8_t msg[1024];
+	hci_inquiry_cp inq;
+	hci_cmd_hdr_t *cmd;
+	hci_event_hdr_t *evp;
+	struct hci_filter filt;
+	struct btreq btr;
+	int s, gotpeer = 0;
+
+	rump_boot_sethowto(RUMP_AB_VERBOSE);
+	rump_init();
+
+	s = rump_sys_socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
+	if (s == -1)
+		err(1, "socket");
+
+	/* enable first device, print name and address */
+	memset(&btr, 0, sizeof(btr));
+	if (rump_sys_ioctl(s, SIOCNBTINFO, &btr) == -1)
+		err(1, "no bt device?");
+
+	btr.btr_flags |= BTF_UP;
+	if (rump_sys_ioctl(s, SIOCSBTFLAGS, &btr) == -1)
+		err(1, "raise interface");
+	if (rump_sys_ioctl(s, SIOCGBTINFO, &btr) == -1)
+		err(1, "reget info");
+
+	memset(&sbt, 0, sizeof(sbt));
+	sbt.bt_len = sizeof(sbt);
+	sbt.bt_family = AF_BLUETOOTH;
+	bdaddr

CVS commit: src/share/examples/rump/tipsy

2010-02-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Feb 18 16:14:55 UTC 2010

Modified Files:
src/share/examples/rump/tipsy: tipsy.c

Log Message:
In "probeonly", pause after bootstrap to make "monkey plug and
unplug device, monkey see fancy dmesg info" possible.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/tipsy/tipsy.c

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

Modified files:

Index: src/share/examples/rump/tipsy/tipsy.c
diff -u src/share/examples/rump/tipsy/tipsy.c:1.1 src/share/examples/rump/tipsy/tipsy.c:1.2
--- src/share/examples/rump/tipsy/tipsy.c:1.1	Sun Dec 20 19:50:29 2009
+++ src/share/examples/rump/tipsy/tipsy.c	Thu Feb 18 16:14:55 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: tipsy.c,v 1.1 2009/12/20 19:50:29 pooka Exp $	*/
+/*	$NetBSD: tipsy.c,v 1.2 2010/02/18 16:14:55 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -100,8 +100,10 @@
 	if (probeonly)
 		rump_boot_sethowto(RUMP_AB_VERBOSE);
 	rump_init();
-	if (probeonly)
+	if (probeonly) {
+		pause();
 		exit(0);
+	}
 
 	com = rump_sys_open("/dev/dtyU0", O_RDWR);
 	if (com == -1)



CVS commit: src/share/examples/rump/sdread

2010-02-17 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Feb 17 20:43:35 UTC 2010

Modified Files:
src/share/examples/rump/sdread: Makefile sdread.c

Log Message:
* support cd devices (@scsibus & @atapibus, per libumass)
* support cd9660
* add "probe" keyword, which just prints the dmesg in verbose form


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/examples/rump/sdread/Makefile
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/sdread/sdread.c

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

Modified files:

Index: src/share/examples/rump/sdread/Makefile
diff -u src/share/examples/rump/sdread/Makefile:1.4 src/share/examples/rump/sdread/Makefile:1.5
--- src/share/examples/rump/sdread/Makefile:1.4	Wed Feb 10 02:31:00 2010
+++ src/share/examples/rump/sdread/Makefile	Wed Feb 17 20:43:35 2010
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.4 2010/02/10 02:31:00 pooka Exp $
+#	$NetBSD: Makefile,v 1.5 2010/02/17 20:43:35 pooka Exp $
 #
 
 PROG=	sdread
 
-LDADD+=	-lrumpfs_ffs -lrumpfs_msdos -lrumpvfs
+LDADD+=	-lrumpfs_cd9660 -lrumpfs_ffs -lrumpfs_msdos -lrumpvfs
 LDADD+=	-lrumpdev_disk -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev_umass -lrumpdev
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread

Index: src/share/examples/rump/sdread/sdread.c
diff -u src/share/examples/rump/sdread/sdread.c:1.2 src/share/examples/rump/sdread/sdread.c:1.3
--- src/share/examples/rump/sdread/sdread.c:1.2	Tue Oct 13 18:41:06 2009
+++ src/share/examples/rump/sdread/sdread.c	Wed Feb 17 20:43:35 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdread.c,v 1.2 2009/10/13 18:41:06 pooka Exp $	*/
+/*	$NetBSD: sdread.c,v 1.3 2010/02/17 20:43:35 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -31,6 +31,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -56,13 +57,19 @@
 	char buf[2048];
 	struct msdosfs_args args;
 	struct ufs_args uargs;
+	struct iso_args iargs;
 	struct dirent *dp;
 	const char *msg = NULL;
 	int fd, n, fd_h, sverrno;
+	int probeonly = 0;
 
-	if (argc > 1 && argc != 3) {
-		fprintf(stderr, "usage: a.out [src hostdest]\n");
-		exit(1);
+	if (argc > 1) {
+		if (argc == 2 && strcmp(argv[1], "probe") == 0) {
+			probeonly = 1;
+		} else if (argc != 3) {
+			fprintf(stderr, "usage: a.out [src hostdest]\n");
+			exit(1);
+		}
 	}
 
 	memset(&args, 0, sizeof(args));
@@ -72,7 +79,15 @@
 	memset(&uargs, 0, sizeof(uargs));
 	uargs.fspec = strdup("/dev/sd0e");
 
+	memset(&iargs, 0, sizeof(iargs));
+	iargs.fspec = strdup("/dev/cd0a");
+
+	if (probeonly)
+		rump_boot_sethowto(RUMP_AB_VERBOSE);
 	rump_init();
+	if (probeonly) {
+		exit(0);
+	}
 
 	if (rump_sys_mkdir("/mp", 0777) == -1)
 		err(1, "mkdir");
@@ -80,7 +95,17 @@
 	&args, sizeof(args)) == -1) {
 		if (rump_sys_mount(MOUNT_FFS, "/mp", MNT_RDONLY,
 		&uargs, sizeof(uargs)) == -1) {
-			err(1, "mount");
+			printf("Trying CD.  This might fail with "
+			"\"media not present\".\n");
+			printf("If that happens, wait a while without "
+			"unplugging the device and re-run.\n");
+			printf("Some devices apparently need a long time "
+			"to settle after they are initialized.\n\n");
+
+			if (rump_sys_mount(MOUNT_CD9660, "/mp", MNT_RDONLY,
+			&iargs, sizeof(iargs)) == -1) {
+err(1, "mount");
+			}
 		}
 	}
 



CVS commit: src/share/examples/rump

2010-02-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Feb 10 02:31:01 UTC 2010

Modified Files:
src/share/examples/rump/sdread: Makefile
src/share/examples/rump/tipsy: Makefile
src/share/examples/rump/ukbd_read: Makefile
src/share/examples/rump/ulptprint: Makefile
src/share/examples/rump/ums_draw: Makefile
src/share/examples/rump/umserv: Makefile
src/share/examples/rump/wirelessconf: Makefile

Log Message:
rumpusbhc is now ugenhc


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/share/examples/rump/sdread/Makefile
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/tipsy/Makefile
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/ukbd_read/Makefile
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/ulptprint/Makefile
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/ums_draw/Makefile
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/umserv/Makefile
cvs rdiff -u -r1.3 -r1.4 src/share/examples/rump/wirelessconf/Makefile

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

Modified files:

Index: src/share/examples/rump/sdread/Makefile
diff -u src/share/examples/rump/sdread/Makefile:1.3 src/share/examples/rump/sdread/Makefile:1.4
--- src/share/examples/rump/sdread/Makefile:1.3	Wed Oct 14 23:51:52 2009
+++ src/share/examples/rump/sdread/Makefile	Wed Feb 10 02:31:00 2010
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.3 2009/10/14 23:51:52 pooka Exp $
+#	$NetBSD: Makefile,v 1.4 2010/02/10 02:31:00 pooka Exp $
 #
 
 PROG=	sdread
 
 LDADD+=	-lrumpfs_ffs -lrumpfs_msdos -lrumpvfs
-LDADD+=	-lrumpdev_disk -lrumpdev_usb -lrumpdev_usbhc -lrumpdev_umass -lrumpdev
+LDADD+=	-lrumpdev_disk -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev_umass -lrumpdev
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread
 

Index: src/share/examples/rump/tipsy/Makefile
diff -u src/share/examples/rump/tipsy/Makefile:1.1 src/share/examples/rump/tipsy/Makefile:1.2
--- src/share/examples/rump/tipsy/Makefile:1.1	Sun Dec 20 19:50:29 2009
+++ src/share/examples/rump/tipsy/Makefile	Wed Feb 10 02:31:00 2010
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.1 2009/12/20 19:50:29 pooka Exp $
+#	$NetBSD: Makefile,v 1.2 2010/02/10 02:31:00 pooka Exp $
 #
 
 PROG=	tipsy
 
 LDADD+=	-lrumpvfs
-LDADD+=	-lrumpdev_usb -lrumpdev_usbhc -lrumpdev_ucom -lrumpdev
+LDADD+=	-lrumpdev_usb -lrumpdev_ugenhc -lrumpdev_ucom -lrumpdev
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread
 

Index: src/share/examples/rump/ukbd_read/Makefile
diff -u src/share/examples/rump/ukbd_read/Makefile:1.1 src/share/examples/rump/ukbd_read/Makefile:1.2
--- src/share/examples/rump/ukbd_read/Makefile:1.1	Mon Jan 11 02:16:51 2010
+++ src/share/examples/rump/ukbd_read/Makefile	Wed Feb 10 02:31:01 2010
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.1 2010/01/11 02:16:51 pooka Exp $
+#	$NetBSD: Makefile,v 1.2 2010/02/10 02:31:01 pooka Exp $
 #
 
 PROG=	kbd
 
-LDADD+=	-lrumpdev_ukbd -lrumpdev_wscons -lrumpdev_usb -lrumpdev_usbhc -lrumpdev
+LDADD+=	-lrumpdev_ukbd -lrumpdev_wscons -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev
 LDADD+=	-lrumpvfs
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread

Index: src/share/examples/rump/ulptprint/Makefile
diff -u src/share/examples/rump/ulptprint/Makefile:1.1 src/share/examples/rump/ulptprint/Makefile:1.2
--- src/share/examples/rump/ulptprint/Makefile:1.1	Tue Dec 15 16:01:50 2009
+++ src/share/examples/rump/ulptprint/Makefile	Wed Feb 10 02:31:01 2010
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.1 2009/12/15 16:01:50 pooka Exp $
+#	$NetBSD: Makefile,v 1.2 2010/02/10 02:31:01 pooka Exp $
 #
 
 PROG=	ulptprint
 
-LDADD+=	-lrumpvfs -lrumpdev_usb -lrumpdev_usbhc -lrumpdev_ulpt -lrumpdev
+LDADD+=	-lrumpvfs -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev_ulpt -lrumpdev
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread
 

Index: src/share/examples/rump/ums_draw/Makefile
diff -u src/share/examples/rump/ums_draw/Makefile:1.1 src/share/examples/rump/ums_draw/Makefile:1.2
--- src/share/examples/rump/ums_draw/Makefile:1.1	Mon Jan 11 02:18:45 2010
+++ src/share/examples/rump/ums_draw/Makefile	Wed Feb 10 02:31:01 2010
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.1 2010/01/11 02:18:45 pooka Exp $
+#	$NetBSD: Makefile,v 1.2 2010/02/10 02:31:01 pooka Exp $
 #
 
 PROG=	ms
 
-LDADD+=	-lrumpdev_ums -lrumpdev_wscons -lrumpdev_usb -lrumpdev_usbhc -lrumpdev
+LDADD+=	-lrumpdev_ums -lrumpdev_wscons -lrumpdev_usb -lrumpdev_ugenhc -lrumpdev
 LDADD+=	-lrumpvfs
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread

Index: src/share/examples/rump/umserv/Makefile
diff -u src/share/examples/rump/umserv/Makefile:1.1 src/share/examples/rump/umserv/Makefile:1.2
--- src/share/examples/rump/umserv/Makefile:1.1	Tue Dec 22 18:36:02 2009
+++ src/share/examples/rump/umserv/Makefile	Wed Feb 10 02:31:01 2010
@@ -1,6 +1,6 @@
 PROG=umserv
 NOMAN=
-LDADD+=-lrumpdev_usbhc -lrumpdev_umass -lrumpdev_usb -lrumpdev_disk -lrumpdev
+LDADD+=-lrumpdev_ugenhc -lrumpdev_umass -lrumpdev_usb -lrumpdev_disk -lrumpdev
 LDADD+=-lrumpvfs
 LDADD+=-lrump -lrumpuser

CVS commit: src/share/examples/rump/wirelessconf

2010-02-05 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Feb  5 22:07:51 UTC 2010

Modified Files:
src/share/examples/rump/wirelessconf: Makefile

Log Message:
The rumpdev_net80211 until-recently-wip component is now rumpnet_net80211.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/wirelessconf/Makefile

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

Modified files:

Index: src/share/examples/rump/wirelessconf/Makefile
diff -u src/share/examples/rump/wirelessconf/Makefile:1.2 src/share/examples/rump/wirelessconf/Makefile:1.3
--- src/share/examples/rump/wirelessconf/Makefile:1.2	Wed Oct 14 23:51:22 2009
+++ src/share/examples/rump/wirelessconf/Makefile	Fri Feb  5 22:07:51 2010
@@ -1,11 +1,11 @@
-#	$NetBSD: Makefile,v 1.2 2009/10/14 23:51:22 pooka Exp $
+#	$NetBSD: Makefile,v 1.3 2010/02/05 22:07:51 pooka Exp $
 #
 
 PROG=	wirelessconf
 
-LDADD+=	-lrumpdev_net80211 -lrumpdev_usbrum -lrumpdev_usbhc
+LDADD+=	-lrumpdev_usbrum -lrumpdev_usbhc
 LDADD+=	-lrumpdev_usb -lrumpdev
-LDADD+=	-lrumpnet_net -lrumpnet
+LDADD+=	-lrumpnet_net80211 -lrumpnet_netinet -lrumpnet_net -lrumpnet
 LDADD+= -lrumpvfs -lrumpcrypto -lrump 
 LDADD+=	-lrumpuser -lpthread
 



CVS commit: src/share/examples/rump/swwdog_arm

2010-01-30 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Jan 31 03:11:55 UTC 2010

Added Files:
src/share/examples/rump/swwdog_arm: Makefile swwdog_arm.c

Log Message:
Add an example on how to use sysmon watchdogs in rump.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/swwdog_arm/Makefile \
src/share/examples/rump/swwdog_arm/swwdog_arm.c

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

Added files:

Index: src/share/examples/rump/swwdog_arm/Makefile
diff -u /dev/null src/share/examples/rump/swwdog_arm/Makefile:1.1
--- /dev/null	Sun Jan 31 03:11:55 2010
+++ src/share/examples/rump/swwdog_arm/Makefile	Sun Jan 31 03:11:55 2010
@@ -0,0 +1,14 @@
+#	$NetBSD: Makefile,v 1.1 2010/01/31 03:11:55 pooka Exp $
+#
+
+PROG=	swwdog_arm
+
+LDADD+=	-lrumpdev_sysmon -lrumpdev
+LDADD+=	-lrumpvfs -lrump
+LDADD+=	-lrumpuser -lpthread
+
+DBG=	-g
+NOMAN=	
+WARNS=	4
+
+.include 
Index: src/share/examples/rump/swwdog_arm/swwdog_arm.c
diff -u /dev/null src/share/examples/rump/swwdog_arm/swwdog_arm.c:1.1
--- /dev/null	Sun Jan 31 03:11:55 2010
+++ src/share/examples/rump/swwdog_arm/swwdog_arm.c	Sun Jan 31 03:11:55 2010
@@ -0,0 +1,91 @@
+/*	$NetBSD: swwdog_arm.c,v 1.1 2010/01/31 03:11:55 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 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 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int
+main(void)
+{
+	char wname[WDOG_NAMESIZE];
+	struct wdog_conf wc;
+	struct wdog_mode wm;
+	int fd;
+	extern int rumpns_swwdog_reboot;
+
+	rumpns_swwdog_reboot = 1;
+	rump_init();
+
+	fd = rump_sys_open("/dev/watchdog", O_RDWR);
+	if (fd == -1)
+		err(1, "open watchdog");
+
+	wc.wc_count = 1;
+	wc.wc_names = wname;
+
+	if (rump_sys_ioctl(fd, WDOGIOC_GWDOGS, &wc) == -1)
+		err(1, "can't fetch watchdog names");
+
+	if (wc.wc_count) {
+		assert(wc.wc_count == 1);
+		printf("watchdog available: %s\n", wc.wc_names);
+
+		printf("enabling watchdog with 2s period\n");
+		strlcpy(wm.wm_name, wc.wc_names, sizeof(wm.wm_name));
+		wm.wm_mode = WDOG_MODE_ETICKLE;
+		wm.wm_period = 2;
+		if (rump_sys_ioctl(fd, WDOGIOC_SMODE, &wm) == -1)
+			err(1, "failed to set tickle\n");
+
+		printf("sleep 1s, then tickle tickle\n");
+		sleep(1);
+		rump_sys_ioctl(fd, WDOGIOC_TICKLE);
+
+		printf("sleep 1s, then tickle tickle\n");
+		sleep(1);
+		rump_sys_ioctl(fd, WDOGIOC_TICKLE);
+
+		printf("now, \"forgetting\" to tickle the doggie\n");
+		sleep(3);
+	} else {
+		printf("no puppies\n");
+	}
+
+	return 0;
+}



CVS commit: src/share/examples/rump

2010-01-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jan 11 02:20:06 UTC 2010

Modified Files:
src/share/examples/rump: Makefile

Log Message:
descend into new subdirs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/Makefile

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

Modified files:

Index: src/share/examples/rump/Makefile
diff -u src/share/examples/rump/Makefile:1.1 src/share/examples/rump/Makefile:1.2
--- src/share/examples/rump/Makefile:1.1	Sat Jan  9 16:19:17 2010
+++ src/share/examples/rump/Makefile	Mon Jan 11 02:20:06 2010
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.1 2010/01/09 16:19:17 pooka Exp $
+#	$NetBSD: Makefile,v 1.2 2010/01/11 02:20:06 pooka Exp $
 #
 
-SUBDIR=	img2cgd sdread tipsy ulptprint umserv wirelessconf
+SUBDIR=	img2cgd sdread tipsy ulptprint umserv ukbd_read ums_draw wirelessconf
 
 .include 



CVS commit: src/share/examples/rump/ums_draw

2010-01-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jan 11 02:18:45 UTC 2010

Added Files:
src/share/examples/rump/ums_draw: Makefile ms.c

Log Message:
Read mouse events from wsmouse and move a silly curses cursor around
the screen (quite poorly, i might add ;).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/ums_draw/Makefile \
src/share/examples/rump/ums_draw/ms.c

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

Added files:

Index: src/share/examples/rump/ums_draw/Makefile
diff -u /dev/null src/share/examples/rump/ums_draw/Makefile:1.1
--- /dev/null	Mon Jan 11 02:18:45 2010
+++ src/share/examples/rump/ums_draw/Makefile	Mon Jan 11 02:18:45 2010
@@ -0,0 +1,17 @@
+#	$NetBSD: Makefile,v 1.1 2010/01/11 02:18:45 pooka Exp $
+#
+
+PROG=	ms
+
+LDADD+=	-lrumpdev_ums -lrumpdev_wscons -lrumpdev_usb -lrumpdev_usbhc -lrumpdev
+LDADD+=	-lrumpvfs
+LDADD+=	-lrump
+LDADD+=	-lrumpuser -lpthread
+
+LDADD+=	-lcurses
+
+DBG=	-g
+NOMAN=	
+WARNS=	4
+
+.include 
Index: src/share/examples/rump/ums_draw/ms.c
diff -u /dev/null src/share/examples/rump/ums_draw/ms.c:1.1
--- /dev/null	Mon Jan 11 02:18:45 2010
+++ src/share/examples/rump/ums_draw/ms.c	Mon Jan 11 02:18:45 2010
@@ -0,0 +1,98 @@
+/*  $NetBSD: ms.c,v 1.1 2010/01/11 02:18:45 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 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.
+ */
+
+/*
+ * Experimental proof-of-concept program:
+ *
+ * Read mouse events and draw silly cursor on screen.
+ */
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int
+main(int argc, char *argv[])
+{
+	struct wscons_event *wev;
+	char buf[128];
+	int fd, x = 0, y = 0;
+
+	rump_boot_sethowto(RUMP_AB_VERBOSE);
+	rump_init();
+
+	fd = rump_sys_open("/dev/wsmouse", 0);
+	if (fd == -1)
+		err(1, "open");
+
+	initscr();
+
+	while (rump_sys_read(fd, buf, sizeof(buf)) > 0) {
+		/* XXX: timespec in 5.0 vs. -current */
+		wev = (void *)buf;
+
+		switch (wev->type) {
+		case WSCONS_EVENT_MOUSE_DELTA_X:
+			if (wev->value > 1)
+x++;
+			else if (wev->value < 1)
+x--;
+			if (x < 0)
+x = 0;
+			break;
+		case WSCONS_EVENT_MOUSE_DELTA_Y:
+			if (wev->value > 1)
+y--;
+			else if (wev->value < 1)
+y++;
+			if (y < 0)
+y = 0;
+			break;
+		case WSCONS_EVENT_MOUSE_DOWN:
+			mvprintw(0, 0, "button %d pressed", wev->value);
+			break;
+		case WSCONS_EVENT_MOUSE_UP:
+			clear();
+			break;
+		default:
+			break;
+		}
+		move(y, x);
+		refresh();
+	}
+}



CVS commit: src/share/examples/rump/ukbd_read

2010-01-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jan 11 02:16:51 UTC 2010

Added Files:
src/share/examples/rump/ukbd_read: Makefile kbd.c

Log Message:
Add an example program which reads keypresses from the ukbd driver
(via wscons) and simply prints them on screen.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/ukbd_read/Makefile \
src/share/examples/rump/ukbd_read/kbd.c

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

Added files:

Index: src/share/examples/rump/ukbd_read/Makefile
diff -u /dev/null src/share/examples/rump/ukbd_read/Makefile:1.1
--- /dev/null	Mon Jan 11 02:16:51 2010
+++ src/share/examples/rump/ukbd_read/Makefile	Mon Jan 11 02:16:51 2010
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1 2010/01/11 02:16:51 pooka Exp $
+#
+
+PROG=	kbd
+
+LDADD+=	-lrumpdev_ukbd -lrumpdev_wscons -lrumpdev_usb -lrumpdev_usbhc -lrumpdev
+LDADD+=	-lrumpvfs
+LDADD+=	-lrump
+LDADD+=	-lrumpuser -lpthread
+
+DBG=	-g
+NOMAN=	
+WARNS=	4
+
+.include 
Index: src/share/examples/rump/ukbd_read/kbd.c
diff -u /dev/null src/share/examples/rump/ukbd_read/kbd.c:1.1
--- /dev/null	Mon Jan 11 02:16:51 2010
+++ src/share/examples/rump/ukbd_read/kbd.c	Mon Jan 11 02:16:51 2010
@@ -0,0 +1,97 @@
+/*  $NetBSD: kbd.c,v 1.1 2010/01/11 02:16:51 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 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.
+ */
+
+/*
+ * Experimental proof-of-concept program:
+ *
+ * Read keyboard events from a USB keyboard using rump drivers.
+ */
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SHIFT (-0x20)
+
+int
+main(int argc, char *argv[])
+{
+	struct wscons_event *wev;
+	int shift = 0;
+	char buf[128];
+	int fd;
+
+	rump_boot_sethowto(RUMP_AB_VERBOSE);
+	rump_init();
+
+	fd = rump_sys_open("/dev/wskbd", 0);
+	if (fd == -1)
+		err(1, "open");
+
+	while (rump_sys_read(fd, buf, sizeof(buf)) > 0) {
+		const char *typestr;
+
+		/* XXX: timespec in 5.0 vs. -current */
+		wev = (void *)buf;
+
+		switch (wev->type) {
+		case WSCONS_EVENT_KEY_UP:
+			typestr = "up";
+			if (wev->value == 0xe1 || wev->value == 0xe5)
+shift = 0;
+			break;
+		case WSCONS_EVENT_KEY_DOWN:
+			typestr = "down";
+			if (wev->value == 0xe1 || wev->value == 0xe5)
+shift = SHIFT;
+			break;
+		default:
+			typestr = "unknown";
+			break;
+		}
+		printf("event type: %d (%s)\n", wev->type, typestr);
+		printf("value 0x%x", wev->value);
+		/*
+		 * There's probably a value-to-readable tool somewhere
+		 * in the tree, but i'm not sure where or how to use it,
+		 * so I'll just punt with the supersimple version for now.
+		 */
+		if (wev->value >= 0x04 && wev->value <= 0x1d)
+			printf(" (%c)", wev->value - 0x04 + 'a' + shift);
+		printf("\n");
+	}
+}



CVS commit: src/share/examples/rump

2010-01-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sat Jan  9 16:19:17 UTC 2010

Added Files:
src/share/examples/rump: Makefile

Log Message:
Stick a top-level subdir-makefile here for easy build-testing.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/Makefile

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

Added files:

Index: src/share/examples/rump/Makefile
diff -u /dev/null src/share/examples/rump/Makefile:1.1
--- /dev/null	Sat Jan  9 16:19:17 2010
+++ src/share/examples/rump/Makefile	Sat Jan  9 16:19:17 2010
@@ -0,0 +1,6 @@
+#	$NetBSD: Makefile,v 1.1 2010/01/09 16:19:17 pooka Exp $
+#
+
+SUBDIR=	img2cgd sdread tipsy ulptprint umserv wirelessconf
+
+.include 



CVS commit: src/share/examples/rump/umserv

2009-12-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Dec 22 18:36:02 UTC 2009

Added Files:
src/share/examples/rump/umserv: Makefile umserv.c

Log Message:
Add a simple example of how to run the kernel umass/USB in userspace
and attach it back to the host kernel using pud(4).  The result is
pretty much indistinguisable from if kernel drivers were used.

It's possible to e.g. mount a file system backed by the userspace
block device driver:

golem> disklabel ./rumpsd0d
[...]
5 partitions:
#sizeoffset fstype [fsize bsize cpg/sgs]
 d:   1994752 0 unused  0 0# (Cyl.  0 -   3895)
 e:   1994512   240  MSDOS # (Cyl.  0*-   3895)

golem> s mount_msdos ./rumpsd0a /mnt
mount_msdos: "./rumpsd0a" is a non-resolved or relative path.
mount_msdos: using "/usr/home/pooka/src/umserv/rumpsd0a" instead.
mount_msdos: /usr/home/pooka/src/umserv/rumpsd0a on /mnt: Device not configured

golem> s mount_msdos ./rumpsd0e /mnt
mount_msdos: "./rumpsd0e" is a non-resolved or relative path.
mount_msdos: using "/usr/home/pooka/src/umserv/rumpsd0e" instead.
golem> df -h /mnt
Filesystem   Size   Used  Avail %Cap 
Mounted on
/usr/home/pooka/src/umserv/rumpsd0e  974M   5.2M   968M   0% /mnt

etcetc.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/umserv/Makefile \
src/share/examples/rump/umserv/umserv.c

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

Added files:

Index: src/share/examples/rump/umserv/Makefile
diff -u /dev/null src/share/examples/rump/umserv/Makefile:1.1
--- /dev/null	Tue Dec 22 18:36:02 2009
+++ src/share/examples/rump/umserv/Makefile	Tue Dec 22 18:36:02 2009
@@ -0,0 +1,10 @@
+PROG=umserv
+NOMAN=
+LDADD+=-lrumpdev_usbhc -lrumpdev_umass -lrumpdev_usb -lrumpdev_disk -lrumpdev
+LDADD+=-lrumpvfs
+LDADD+=-lrump -lrumpuser -lpthread
+
+WARNS=4
+DBG=-g
+
+.include 
Index: src/share/examples/rump/umserv/umserv.c
diff -u /dev/null src/share/examples/rump/umserv/umserv.c:1.1
--- /dev/null	Tue Dec 22 18:36:02 2009
+++ src/share/examples/rump/umserv/umserv.c	Tue Dec 22 18:36:02 2009
@@ -0,0 +1,224 @@
+/*	$NetBSD: umserv.c,v 1.1 2009/12/22 18:36:02 pooka 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.
+ */
+
+/*
+ * This is a [quick, simple & dirty] userspace s...@umass server.
+ * We probe USB devices using rump and attach them to the host kernel
+ * using pud(4).  The resulting block devices can be e.g. read
+ * and/or mounted.
+ *
+ * Since there is no devfs support in NetBSD, we create crudo & cotto
+ * device nodes in the current directory.  Operating on these in the
+ * host OS will direct operations to this userspace server, e.g.:
+ *   golem> disklabel ./rumpsd0d
+ *   golem> mount_msdos ./rumpsd0e /mnt
+ * will cause file system access to /mnt be backed by the umass server
+ * in userspace.  Due to the relatively experimental nature of this
+ * server, rump file servers are recommended for mounting experiments.
+ */
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * No devfs?  No problem.  We just hack a bit & wait for the dust to settle.
+ */
+#define NODEBASE "rumpsd0"
+#define MYMAJOR 411
+static int
+makenodes(void)
+{
+	char path[PATH_MAX];
+	struct stat sb;
+	int i, j, rv;
+
+	for (i = 0; i < 2; i++) {
+		int minnum = 0;
+
+		for (j = 0; j < 8; j++, minnum++) {
+			sprintf(path, "%s%s%c",
+			i == 0 ? "" : "r", NODEBASE, minnum + 'a');
+			if (stat(path, &sb) == 0)
+cont

CVS commit: src/share/examples/rump/tipsy

2009-12-20 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Dec 20 19:50:29 UTC 2009

Added Files:
src/share/examples/rump/tipsy: Makefile tipsy.c

Log Message:
Add a simple terminal program which uses a rump kernel for a u...@usb
terminal and host terminal stdin/stdout for human interaction.
Tipsy just simply shovels bits between the two.  I can use my
JavaStation Krups (*) serial console with this ... without having
to worry abort those pesky usb drivers crashing my desktop kernel.

*) strictly speaking it's uwe's ;)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/tipsy/Makefile \
src/share/examples/rump/tipsy/tipsy.c

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

Added files:

Index: src/share/examples/rump/tipsy/Makefile
diff -u /dev/null src/share/examples/rump/tipsy/Makefile:1.1
--- /dev/null	Sun Dec 20 19:50:29 2009
+++ src/share/examples/rump/tipsy/Makefile	Sun Dec 20 19:50:29 2009
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1 2009/12/20 19:50:29 pooka Exp $
+#
+
+PROG=	tipsy
+
+LDADD+=	-lrumpvfs
+LDADD+=	-lrumpdev_usb -lrumpdev_usbhc -lrumpdev_ucom -lrumpdev
+LDADD+=	-lrump
+LDADD+=	-lrumpuser -lpthread
+
+DBG=	-g
+NOMAN=	
+WARNS=	4
+
+.include 
Index: src/share/examples/rump/tipsy/tipsy.c
diff -u /dev/null src/share/examples/rump/tipsy/tipsy.c:1.1
--- /dev/null	Sun Dec 20 19:50:29 2009
+++ src/share/examples/rump/tipsy/tipsy.c	Sun Dec 20 19:50:29 2009
@@ -0,0 +1,151 @@
+/*	$NetBSD: tipsy.c,v 1.1 2009/12/20 19:50:29 pooka 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.
+ */
+
+/*
+ * Experimental proof-of-concept program:
+ *
+ * tip-on-booze.  Uses rump kernel for ucom driver + underlying
+ * hardware.  Just shovels bits back and forth between the user
+ * terminal and the ucom device.
+ *
+ * Seems to drop an occasional character for output here and there.
+ * Haven't pinpointed the problem yet.  It happens commonly for certain
+ * patterns such as ctrl-U followed by immediate typing.  Tipsy is quite
+ * sober despite this "feature".
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * We use a shovel thread to get the bits from the rump kernel and
+ * print them on the terminal.  The reason for a thread instead of
+ * polling is that we currently have no way to poll two fd's when
+ * they are in different kernels (stdin in the host, ucom in rump).
+ */
+static void *
+shovel(void *arg)
+{
+	char buf[64];
+	ssize_t n;
+	int fd = (int)(intptr_t)arg;
+
+	for (;;) {
+		n = rump_sys_read(fd, buf, sizeof(buf));
+		if (__predict_false(n <= 0)) {
+			if (n == 0)
+errx(1, "ucom EOF");
+			if (n == -1)
+err(1, "ucom read");
+		}
+		if (write(STDOUT_FILENO, buf, n) != n)
+			err(1, "write to console");
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	pthread_t pt;
+struct termios tios;
+	int probeonly = 0;
+	int com;
+
+	if (argc > 1) {
+		if (argc == 2 && strcmp(argv[1], "probe") == 0) {
+			probeonly = 1;
+		} else {
+			fprintf(stderr, "mind the usage\n");
+			exit(1);
+		}
+	}
+
+	if (probeonly)
+		rump_boot_sethowto(RUMP_AB_VERBOSE);
+	rump_init();
+	if (probeonly)
+		exit(0);
+
+	com = rump_sys_open("/dev/dtyU0", O_RDWR);
+	if (com == -1)
+		err(1, "rump ucom open failed");
+
+	/*
+	 * Setup the com port.  You might need to tweak this.
+	 */
+	if (rump_sys_ioctl(com, TIOCGETA, &tios) == -1)
+		err(1, "rump get term");
+	tios.c_cflag &= ~(CSIZE|PARENB);
+	tios.c_cflag |= CS8;
+	tios.c_cflag |= CLOCAL;
+	tios.c_iflag &= ~(ISTRIP|ICRNL);
+	tios.c_oflag &= ~OPOST;
+	tios.c_lfl

CVS commit: src/share/examples/rump/ulptprint

2009-12-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Dec 15 16:01:51 UTC 2009

Added Files:
src/share/examples/rump/ulptprint: Makefile ulptprint.c

Log Message:
Add an example to show how to print with a rump ulpt driver.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/ulptprint/Makefile \
src/share/examples/rump/ulptprint/ulptprint.c

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

Added files:

Index: src/share/examples/rump/ulptprint/Makefile
diff -u /dev/null src/share/examples/rump/ulptprint/Makefile:1.1
--- /dev/null	Tue Dec 15 16:01:51 2009
+++ src/share/examples/rump/ulptprint/Makefile	Tue Dec 15 16:01:50 2009
@@ -0,0 +1,14 @@
+#	$NetBSD: Makefile,v 1.1 2009/12/15 16:01:50 pooka Exp $
+#
+
+PROG=	ulptprint
+
+LDADD+=	-lrumpvfs -lrumpdev_usb -lrumpdev_usbhc -lrumpdev_ulpt -lrumpdev
+LDADD+=	-lrump
+LDADD+=	-lrumpuser -lpthread
+
+DBG=	-g
+NOMAN=	
+WARNS=	4
+
+.include 
Index: src/share/examples/rump/ulptprint/ulptprint.c
diff -u /dev/null src/share/examples/rump/ulptprint/ulptprint.c:1.1
--- /dev/null	Tue Dec 15 16:01:51 2009
+++ src/share/examples/rump/ulptprint/ulptprint.c	Tue Dec 15 16:01:50 2009
@@ -0,0 +1,90 @@
+/*	$NetBSD: ulptprint.c,v 1.1 2009/12/15 16:01:50 pooka 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 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Proof-of-concept program:
+ *
+ * Prints given (postscript) file by "catting" into the printer.
+ */
+
+int
+main(int argc, char *argv[])
+{
+	char buf[8192];
+	ssize_t n;
+	int probeonly = 0;
+	int fd_src, fd_dst;
+
+	if (argc != 2)
+		errx(1, "need 2 args");
+
+	if (strcmp(argv[1], "probe") == 0)
+		probeonly = 1;
+
+	if (probeonly)
+		rump_boot_sethowto(RUMP_AB_VERBOSE);
+	rump_init();
+	if (probeonly)
+		exit(0);
+
+	fd_dst = rump_sys_open("/dev/ulpt0", O_RDWR);
+	if (fd_dst == -1)
+		err(1, "printer open");
+
+	fd_src = open(argv[1], O_RDONLY);
+	if (fd_src == -1)
+		err(1, "open source");
+
+	for (;;) {
+		n = read(fd_src, buf, sizeof(buf));
+		if (n == 0)
+			break;
+		if (n == -1)
+			err(1, "read");
+
+		if (rump_sys_write(fd_dst, buf, n) != n)
+			err(1, "write to printer");
+	}
+	rump_sys_close(fd_dst);
+
+	printf("done\n");
+}



CVS commit: src/share/examples/rump/dmtest

2009-12-05 Thread Adam Hamsik
Module Name:src
Committed By:   haad
Date:   Sat Dec  5 11:44:56 UTC 2009

Modified Files:
src/share/examples/rump/dmtest: dmt.c

Log Message:
Include public interface describing user-kernel interface from include/dev/dm.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/dmtest/dmt.c

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

Modified files:

Index: src/share/examples/rump/dmtest/dmt.c
diff -u src/share/examples/rump/dmtest/dmt.c:1.2 src/share/examples/rump/dmtest/dmt.c:1.3
--- src/share/examples/rump/dmtest/dmt.c:1.2	Sat Dec  5 10:38:27 2009
+++ src/share/examples/rump/dmtest/dmt.c	Sat Dec  5 11:44:56 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmt.c,v 1.2 2009/12/05 10:38:27 haad Exp $
+/*	$NetBSD: dmt.c,v 1.3 2009/12/05 11:44:56 haad Exp $
 
 /*
  * Copyright (c) 2009 Adam Hamsik.  All Rights Reserved.
@@ -46,14 +46,7 @@
 #include 
 #include 
 
-/* NetBSD-dm.h part */
-#include 
-
-#define DM_CMD_LEN 16
-#define DM_IOCTL 0xfd
-#define DM_IOCTL_CMD 0
-#define NETBSD_DM_IOCTL   _IOWR(DM_IOCTL, DM_IOCTL_CMD, struct plistref)
-
+#include 
 
 int
 main(int argc, char *argv[])



CVS commit: src/share/examples/rump/dmtest

2009-12-05 Thread Adam Hamsik
Module Name:src
Committed By:   haad
Date:   Sat Dec  5 10:38:27 UTC 2009

Modified Files:
src/share/examples/rump/dmtest: Makefile dmt.c

Log Message:
Fix some small bugs pointed out byt po...@. Remove not needed -D defines and
do not include private kernel header files. Instead copy part of it to test
program.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/dmtest/Makefile \
src/share/examples/rump/dmtest/dmt.c

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

Modified files:

Index: src/share/examples/rump/dmtest/Makefile
diff -u src/share/examples/rump/dmtest/Makefile:1.1 src/share/examples/rump/dmtest/Makefile:1.2
--- src/share/examples/rump/dmtest/Makefile:1.1	Fri Dec  4 22:18:30 2009
+++ src/share/examples/rump/dmtest/Makefile	Sat Dec  5 10:38:27 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2009/12/04 22:18:30 haad Exp $
+#	$NetBSD: Makefile,v 1.2 2009/12/05 10:38:27 haad Exp $
 PROG=   dmt
 SRCS=   dmt.c
 
@@ -8,7 +8,6 @@
 
 CFLAGS+= -g -fno-inline
 
-CPPFLAGS+=  -DRUMP_ACTION -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE -I${NETBSDSRCDIR}/sys/dev/dm
 LDADD+= -lrumpdev_disk -lrumpdev_dm -lrumpdev -lprop
 LDADD+= -lrumpvfs -lrump -lrumpuser -lpthread
 DBG=-g
Index: src/share/examples/rump/dmtest/dmt.c
diff -u src/share/examples/rump/dmtest/dmt.c:1.1 src/share/examples/rump/dmtest/dmt.c:1.2
--- src/share/examples/rump/dmtest/dmt.c:1.1	Fri Dec  4 22:18:30 2009
+++ src/share/examples/rump/dmtest/dmt.c	Sat Dec  5 10:38:27 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmt.c,v 1.1 2009/12/04 22:18:30 haad Exp $
+/*	$NetBSD: dmt.c,v 1.2 2009/12/05 10:38:27 haad Exp $
 
 /*
  * Copyright (c) 2009 Adam Hamsik.  All Rights Reserved.
@@ -43,14 +43,20 @@
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
-#include 
+
+/* NetBSD-dm.h part */
+#include 
+
+#define DM_CMD_LEN 16
+#define DM_IOCTL 0xfd
+#define DM_IOCTL_CMD 0
+#define NETBSD_DM_IOCTL   _IOWR(DM_IOCTL, DM_IOCTL_CMD, struct plistref)
+
 
 int
-main(int argc,char *argv[])
+main(int argc, char *argv[])
 {
 	int fd;
 	int err;
@@ -60,7 +66,6 @@
 	char *xml;
 	
 	err = rump_init();
-
 	if (err != 0)
 		printf("rump_init failed with %s\n", strerror(err));
 	
@@ -74,7 +79,7 @@
 	prop_dictionary_externalize_to_pref(dict_in, &prefp);
 	
 	err = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp);
-	if ( err != 0)
+	if ( err < 0)
 		printf("ioctl failed %d\n", err);
 
 	dict_out = prop_dictionary_internalize(prefp.pref_plist);
@@ -82,5 +87,5 @@
 	xml = prop_dictionary_externalize(dict_out);
 	printf("%s\n",xml);
 	
-	close(fd);
+	rump_sys_close(fd);
 }



CVS commit: src/share/examples/rump/dmtest

2009-12-04 Thread Adam Hamsik
Module Name:src
Committed By:   haad
Date:   Fri Dec  4 22:18:30 UTC 2009

Added Files:
src/share/examples/rump/dmtest: Makefile dmt.c prop1.plist prop2.plist

Log Message:
Add small testing program which uses RUMP libdm to test device-mapper
functionality in userspace.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/dmtest/Makefile \
src/share/examples/rump/dmtest/dmt.c \
src/share/examples/rump/dmtest/prop1.plist \
src/share/examples/rump/dmtest/prop2.plist

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

Added files:

Index: src/share/examples/rump/dmtest/Makefile
diff -u /dev/null src/share/examples/rump/dmtest/Makefile:1.1
--- /dev/null	Fri Dec  4 22:18:30 2009
+++ src/share/examples/rump/dmtest/Makefile	Fri Dec  4 22:18:30 2009
@@ -0,0 +1,16 @@
+#	$NetBSD: Makefile,v 1.1 2009/12/04 22:18:30 haad Exp $
+PROG=   dmt
+SRCS=   dmt.c
+
+DPADD=  ${LIBUTIL}
+LDADD=  -lutil
+MKMAN=  no
+
+CFLAGS+= -g -fno-inline
+
+CPPFLAGS+=  -DRUMP_ACTION -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE -I${NETBSDSRCDIR}/sys/dev/dm
+LDADD+= -lrumpdev_disk -lrumpdev_dm -lrumpdev -lprop
+LDADD+= -lrumpvfs -lrump -lrumpuser -lpthread
+DBG=-g
+
+.include 
Index: src/share/examples/rump/dmtest/dmt.c
diff -u /dev/null src/share/examples/rump/dmtest/dmt.c:1.1
--- /dev/null	Fri Dec  4 22:18:30 2009
+++ src/share/examples/rump/dmtest/dmt.c	Fri Dec  4 22:18:30 2009
@@ -0,0 +1,86 @@
+/*	$NetBSD: dmt.c,v 1.1 2009/12/04 22:18:30 haad Exp $
+
+/*
+ * Copyright (c) 2009 Adam Hamsik.  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 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+int
+main(int argc,char *argv[])
+{
+	int fd;
+	int err;
+
+	prop_dictionary_t dict_in, dict_out;
+	struct plistref prefp;
+	char *xml;
+	
+	err = rump_init();
+
+	if (err != 0)
+		printf("rump_init failed with %s\n", strerror(err));
+	
+	fd = rump_sys_open("/dev/mapper/control", O_RDWR, 0);
+	if (fd == -1)
+		printf("Cannot open control device.\n");
+
+	dict_in  = prop_dictionary_internalize_from_file("prop2.plist");
+	dict_out = prop_dictionary_create();
+	
+	prop_dictionary_externalize_to_pref(dict_in, &prefp);
+	
+	err = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp);
+	if ( err != 0)
+		printf("ioctl failed %d\n", err);
+
+	dict_out = prop_dictionary_internalize(prefp.pref_plist);
+	
+	xml = prop_dictionary_externalize(dict_out);
+	printf("%s\n",xml);
+	
+	close(fd);
+}
Index: src/share/examples/rump/dmtest/prop1.plist
diff -u /dev/null src/share/examples/rump/dmtest/prop1.plist:1.1
--- /dev/null	Fri Dec  4 22:18:30 2009
+++ src/share/examples/rump/dmtest/prop1.plist	Fri Dec  4 22:18:30 2009
@@ -0,0 +1,20 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+cmd_data
+
+command
+version
+event_nr
+0x0
+flags
+0x4
+version
+
+0x4
+0x0
+0x0
+
+
+
\ No newline at end of file
Index: src/share/examples/rump/dmtest/prop2.plist
diff -u /dev/null src/share/examples/rump/dmtest/prop2.plist:1.1
--- /dev/null	Fri Dec  4 22:18:30 2009
+++ src/share/examples/rump/dmtest/prop2.plist	Fri Dec  4 22:18:30 2009
@@ -0,0 +1,20 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+cmd_data
+
+command
+targets
+event_nr
+0x0
+flags
+0x4
+version
+
+0x4
+0x1
+0

CVS commit: src/share/examples/rump/wirelessconf

2009-11-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Nov  3 18:24:21 UTC 2009

Modified Files:
src/share/examples/rump/wirelessconf: wirelessconf.c

Log Message:
* use rump_boot_sethowto()
* fail in a nicer way if interface device is not probed


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/wirelessconf/wirelessconf.c

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

Modified files:

Index: src/share/examples/rump/wirelessconf/wirelessconf.c
diff -u src/share/examples/rump/wirelessconf/wirelessconf.c:1.2 src/share/examples/rump/wirelessconf/wirelessconf.c:1.3
--- src/share/examples/rump/wirelessconf/wirelessconf.c:1.2	Wed Oct 14 23:51:22 2009
+++ src/share/examples/rump/wirelessconf/wirelessconf.c	Tue Nov  3 18:24:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: wirelessconf.c,v 1.2 2009/10/14 23:51:22 pooka Exp $	*/
+/*	$NetBSD: wirelessconf.c,v 1.3 2009/11/03 18:24:21 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -36,7 +36,9 @@
 #include 
 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 /*
@@ -48,25 +50,32 @@
 int
 main(void)
 {
-	extern int rumpns_boothowto;
 	struct ifreq ifr;
 	int s;
 
-	rumpns_boothowto = AB_VERBOSE;
+	rump_boot_sethowto(RUMP_AB_VERBOSE);
 	rump_init();
+
+	/* rum?  shouldn't that be marsala? */
+	s = rump_sys_socket(AF_INET, SOCK_DGRAM, 0);
+	if (s == -1)
+		err(1, "socket");
+	strcpy(ifr.ifr_name, "rum0");
+	if (rump_sys_ioctl(s, SIOCGIFFLAGS, &ifr) == -1) {
+		if (errno == ENXIO) {
+			printf("r...@usb not found!\n");
+			exit(0);
+		}
+		err(1, "get if flags");
+	}
 	printf("\ndevice autoconfiguration finished\n");
 
 	printf("tira-if-su ...\n");
 	if (rump_pub_etfs_register(RUMFW, RUMFW, RUMP_ETFS_REG) != 0)
 		errx(1, "firmware etfs registration failed");
 
-	/* rum?  shouldn't that be marsala? */
 	strcpy(ifr.ifr_name, "rum0");
 	ifr.ifr_flags = IFF_UP;
-	s = rump_sys_socket(AF_INET, SOCK_DGRAM, 0);
-	if (s == -1)
-		err(1, "socket");
-
 	if (rump_sys_ioctl(s, SIOCSIFFLAGS, &ifr) == -1)
 		err(1, "ioctl");
 	printf("... done\n");



CVS commit: src/share/examples/rump/img2cgd

2009-10-19 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Oct 20 02:05:45 UTC 2009

Modified Files:
src/share/examples/rump/img2cgd: img2cgd.c

Log Message:
fix warnings, update interface to use rump_pub


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/img2cgd/img2cgd.c

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

Modified files:

Index: src/share/examples/rump/img2cgd/img2cgd.c
diff -u src/share/examples/rump/img2cgd/img2cgd.c:1.2 src/share/examples/rump/img2cgd/img2cgd.c:1.3
--- src/share/examples/rump/img2cgd/img2cgd.c:1.2	Tue Sep  8 21:51:33 2009
+++ src/share/examples/rump/img2cgd/img2cgd.c	Tue Oct 20 02:05:45 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: img2cgd.c,v 1.2 2009/09/08 21:51:33 pooka Exp $	*/
+/*	$NetBSD: img2cgd.c,v 1.3 2009/10/20 02:05:45 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -29,6 +29,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -38,6 +39,8 @@
 #include 
 #include 
 
+#include "cgdconfig.h"
+
 /*
  * We really should use disklabel.  However, for the time being,
  * use a endian independent magic number at offset == 0 and a
@@ -96,7 +99,7 @@
 int
 main(int argc, char *argv[])
 {
-	const char *the_argv[10];
+	char *the_argv[10];
 	const char *cgd_file, *img_file;
 	struct stat sb_cgd, sb_file;
 	off_t nbytes;
@@ -179,16 +182,16 @@
 	}
 
 	rump_init();
-	if ((error = rump_etfs_register("/cryptfile", cgd_file,
+	if ((error = rump_pub_etfs_register("/cryptfile", cgd_file,
 	RUMP_ETFS_BLK)) != 0) {
 		printf("etfs: %d\n", error);
 		exit(1);
 	}
 
-	the_argv[0] = "cgdconfig";
-	the_argv[1] = "cgd0";
-	the_argv[2] = "/cryptfile";
-	the_argv[3] = "./cgd.conf";
+	the_argv[0] = strdup("cgdconfig");
+	the_argv[1] = strdup("cgd0");
+	the_argv[2] = strdup("/cryptfile");
+	the_argv[3] = strdup("./cgd.conf");
 	the_argv[4] = NULL;
 	error = cgdconfig(4, the_argv);
 	if (error) {



CVS commit: src/share/examples/rump/sdread

2009-10-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Oct 14 23:51:52 UTC 2009

Modified Files:
src/share/examples/rump/sdread: Makefile

Log Message:
WARNS


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/examples/rump/sdread/Makefile

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

Modified files:

Index: src/share/examples/rump/sdread/Makefile
diff -u src/share/examples/rump/sdread/Makefile:1.2 src/share/examples/rump/sdread/Makefile:1.3
--- src/share/examples/rump/sdread/Makefile:1.2	Tue Oct 13 18:41:06 2009
+++ src/share/examples/rump/sdread/Makefile	Wed Oct 14 23:51:52 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2009/10/13 18:41:06 pooka Exp $
+#	$NetBSD: Makefile,v 1.3 2009/10/14 23:51:52 pooka Exp $
 #
 
 PROG=	sdread
@@ -10,5 +10,6 @@
 
 DBG=	-g
 NOMAN=	
+WARNS=	4
 
 .include 



CVS commit: src/share/examples/rump/wirelessconf

2009-10-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Oct 14 23:51:22 UTC 2009

Modified Files:
src/share/examples/rump/wirelessconf: Makefile wirelessconf.c

Log Message:
WARNS + make compile


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/wirelessconf/Makefile \
src/share/examples/rump/wirelessconf/wirelessconf.c

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

Modified files:

Index: src/share/examples/rump/wirelessconf/Makefile
diff -u src/share/examples/rump/wirelessconf/Makefile:1.1 src/share/examples/rump/wirelessconf/Makefile:1.2
--- src/share/examples/rump/wirelessconf/Makefile:1.1	Mon Oct  5 13:07:28 2009
+++ src/share/examples/rump/wirelessconf/Makefile	Wed Oct 14 23:51:22 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2009/10/05 13:07:28 pooka Exp $
+#	$NetBSD: Makefile,v 1.2 2009/10/14 23:51:22 pooka Exp $
 #
 
 PROG=	wirelessconf
@@ -11,5 +11,6 @@
 
 DBG=	-g
 NOMAN=	
+WARNS=	4
 
 .include 
Index: src/share/examples/rump/wirelessconf/wirelessconf.c
diff -u src/share/examples/rump/wirelessconf/wirelessconf.c:1.1 src/share/examples/rump/wirelessconf/wirelessconf.c:1.2
--- src/share/examples/rump/wirelessconf/wirelessconf.c:1.1	Mon Oct  5 13:07:28 2009
+++ src/share/examples/rump/wirelessconf/wirelessconf.c	Wed Oct 14 23:51:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: wirelessconf.c,v 1.1 2009/10/05 13:07:28 pooka Exp $	*/
+/*	$NetBSD: wirelessconf.c,v 1.2 2009/10/14 23:51:22 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -46,7 +46,7 @@
 
 #define RUMFW "/libdata/firmware/rum/rum-rt2573"
 int
-main()
+main(void)
 {
 	extern int rumpns_boothowto;
 	struct ifreq ifr;
@@ -57,7 +57,7 @@
 	printf("\ndevice autoconfiguration finished\n");
 
 	printf("tira-if-su ...\n");
-	if (rump_etfs_register(RUMFW, RUMFW, RUMP_ETFS_REG) != 0)
+	if (rump_pub_etfs_register(RUMFW, RUMFW, RUMP_ETFS_REG) != 0)
 		errx(1, "firmware etfs registration failed");
 
 	/* rum?  shouldn't that be marsala? */



CVS commit: src/share/examples/rump/sdread

2009-10-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Oct 13 18:41:06 UTC 2009

Modified Files:
src/share/examples/rump/sdread: Makefile sdread.c

Log Message:
Try ffs is msdosfs mount fails -- I happened to have one USB stick
where the file system is ffs.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/sdread/Makefile \
src/share/examples/rump/sdread/sdread.c

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

Modified files:

Index: src/share/examples/rump/sdread/Makefile
diff -u src/share/examples/rump/sdread/Makefile:1.1 src/share/examples/rump/sdread/Makefile:1.2
--- src/share/examples/rump/sdread/Makefile:1.1	Mon Oct  5 13:05:31 2009
+++ src/share/examples/rump/sdread/Makefile	Tue Oct 13 18:41:06 2009
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.1 2009/10/05 13:05:31 pooka Exp $
+#	$NetBSD: Makefile,v 1.2 2009/10/13 18:41:06 pooka Exp $
 #
 
 PROG=	sdread
 
-LDADD+=	-lrumpfs_msdos -lrumpvfs
+LDADD+=	-lrumpfs_ffs -lrumpfs_msdos -lrumpvfs
 LDADD+=	-lrumpdev_disk -lrumpdev_usb -lrumpdev_usbhc -lrumpdev_umass -lrumpdev
 LDADD+=	-lrump
 LDADD+=	-lrumpuser -lpthread
Index: src/share/examples/rump/sdread/sdread.c
diff -u src/share/examples/rump/sdread/sdread.c:1.1 src/share/examples/rump/sdread/sdread.c:1.2
--- src/share/examples/rump/sdread/sdread.c:1.1	Mon Oct  5 13:05:31 2009
+++ src/share/examples/rump/sdread/sdread.c	Tue Oct 13 18:41:06 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdread.c,v 1.1 2009/10/05 13:05:31 pooka Exp $	*/
+/*	$NetBSD: sdread.c,v 1.2 2009/10/13 18:41:06 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -29,6 +29,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -54,6 +55,7 @@
 {
 	char buf[2048];
 	struct msdosfs_args args;
+	struct ufs_args uargs;
 	struct dirent *dp;
 	const char *msg = NULL;
 	int fd, n, fd_h, sverrno;
@@ -67,13 +69,20 @@
 	args.fspec = strdup("/dev/sd0e");
 	args.version = MSDOSFSMNT_VERSION;
 
+	memset(&uargs, 0, sizeof(uargs));
+	uargs.fspec = strdup("/dev/sd0e");
+
 	rump_init();
 
 	if (rump_sys_mkdir("/mp", 0777) == -1)
 		err(1, "mkdir");
 	if (rump_sys_mount(MOUNT_MSDOS, "/mp", MNT_RDONLY,
-	&args, sizeof(args)) == -1)
-		err(1, "mount");
+	&args, sizeof(args)) == -1) {
+		if (rump_sys_mount(MOUNT_FFS, "/mp", MNT_RDONLY,
+		&uargs, sizeof(uargs)) == -1) {
+			err(1, "mount");
+		}
+	}
 
 	fd = rump_sys_open("/mp", O_RDONLY, 0);
 	if (fd == -1) {



CVS commit: src/share/examples/rump/wirelessconf

2009-10-05 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Oct  5 13:07:28 UTC 2009

Added Files:
src/share/examples/rump/wirelessconf: Makefile wirelessconf.c

Log Message:
Add an example program which shows how to do "ifconfig rum0 up".
What makes this special is that the USB driver stack, the rum
driver, network subroutines and net80211 are running in userspace
in a rump kernel instead of in the host kernel.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/wirelessconf/Makefile \
src/share/examples/rump/wirelessconf/wirelessconf.c

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

Added files:

Index: src/share/examples/rump/wirelessconf/Makefile
diff -u /dev/null src/share/examples/rump/wirelessconf/Makefile:1.1
--- /dev/null	Mon Oct  5 13:07:28 2009
+++ src/share/examples/rump/wirelessconf/Makefile	Mon Oct  5 13:07:28 2009
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1 2009/10/05 13:07:28 pooka Exp $
+#
+
+PROG=	wirelessconf
+
+LDADD+=	-lrumpdev_net80211 -lrumpdev_usbrum -lrumpdev_usbhc
+LDADD+=	-lrumpdev_usb -lrumpdev
+LDADD+=	-lrumpnet_net -lrumpnet
+LDADD+= -lrumpvfs -lrumpcrypto -lrump 
+LDADD+=	-lrumpuser -lpthread
+
+DBG=	-g
+NOMAN=	
+
+.include 
Index: src/share/examples/rump/wirelessconf/wirelessconf.c
diff -u /dev/null src/share/examples/rump/wirelessconf/wirelessconf.c:1.1
--- /dev/null	Mon Oct  5 13:07:28 2009
+++ src/share/examples/rump/wirelessconf/wirelessconf.c	Mon Oct  5 13:07:28 2009
@@ -0,0 +1,75 @@
+/*	$NetBSD: wirelessconf.c,v 1.1 2009/10/05 13:07:28 pooka 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 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/*
+ * Example program for raising rum0 interface under rump.  This
+ * requires a rum-compatible usb device attached as ugen.
+ */
+
+#define RUMFW "/libdata/firmware/rum/rum-rt2573"
+int
+main()
+{
+	extern int rumpns_boothowto;
+	struct ifreq ifr;
+	int s;
+
+	rumpns_boothowto = AB_VERBOSE;
+	rump_init();
+	printf("\ndevice autoconfiguration finished\n");
+
+	printf("tira-if-su ...\n");
+	if (rump_etfs_register(RUMFW, RUMFW, RUMP_ETFS_REG) != 0)
+		errx(1, "firmware etfs registration failed");
+
+	/* rum?  shouldn't that be marsala? */
+	strcpy(ifr.ifr_name, "rum0");
+	ifr.ifr_flags = IFF_UP;
+	s = rump_sys_socket(AF_INET, SOCK_DGRAM, 0);
+	if (s == -1)
+		err(1, "socket");
+
+	if (rump_sys_ioctl(s, SIOCSIFFLAGS, &ifr) == -1)
+		err(1, "ioctl");
+	printf("... done\n");
+
+	return 0;
+}



CVS commit: src/share/examples/rump/sdread

2009-10-05 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Oct  5 13:05:31 UTC 2009

Added Files:
src/share/examples/rump/sdread: Makefile sdread.c

Log Message:
Add an example program which shows how to mount and read files from
an msdos file system which is located on a usb stick.  What makes
this special is that the USB driver stack (and the file system
driver, of course) is run in rump instead of in the host kernel.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/sdread/Makefile \
src/share/examples/rump/sdread/sdread.c

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

Added files:

Index: src/share/examples/rump/sdread/Makefile
diff -u /dev/null src/share/examples/rump/sdread/Makefile:1.1
--- /dev/null	Mon Oct  5 13:05:31 2009
+++ src/share/examples/rump/sdread/Makefile	Mon Oct  5 13:05:31 2009
@@ -0,0 +1,14 @@
+#	$NetBSD: Makefile,v 1.1 2009/10/05 13:05:31 pooka Exp $
+#
+
+PROG=	sdread
+
+LDADD+=	-lrumpfs_msdos -lrumpvfs
+LDADD+=	-lrumpdev_disk -lrumpdev_usb -lrumpdev_usbhc -lrumpdev_umass -lrumpdev
+LDADD+=	-lrump
+LDADD+=	-lrumpuser -lpthread
+
+DBG=	-g
+NOMAN=	
+
+.include 
Index: src/share/examples/rump/sdread/sdread.c
diff -u /dev/null src/share/examples/rump/sdread/sdread.c:1.1
--- /dev/null	Mon Oct  5 13:05:31 2009
+++ src/share/examples/rump/sdread/sdread.c	Mon Oct  5 13:05:31 2009
@@ -0,0 +1,138 @@
+/*	$NetBSD: sdread.c,v 1.1 2009/10/05 13:05:31 pooka 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 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Proof-of-concept program:
+ *
+ * Mount rump file system from device driver stack included in the
+ * rump kernel.  Optionally copy a file out of the mounted file system.
+ */
+
+int
+main(int argc, char *argv[])
+{
+	char buf[2048];
+	struct msdosfs_args args;
+	struct dirent *dp;
+	const char *msg = NULL;
+	int fd, n, fd_h, sverrno;
+
+	if (argc > 1 && argc != 3) {
+		fprintf(stderr, "usage: a.out [src hostdest]\n");
+		exit(1);
+	}
+
+	memset(&args, 0, sizeof(args));
+	args.fspec = strdup("/dev/sd0e");
+	args.version = MSDOSFSMNT_VERSION;
+
+	rump_init();
+
+	if (rump_sys_mkdir("/mp", 0777) == -1)
+		err(1, "mkdir");
+	if (rump_sys_mount(MOUNT_MSDOS, "/mp", MNT_RDONLY,
+	&args, sizeof(args)) == -1)
+		err(1, "mount");
+
+	fd = rump_sys_open("/mp", O_RDONLY, 0);
+	if (fd == -1) {
+		msg = "open dir";
+		goto out;
+	}
+
+	while ((n = rump_sys_getdents(fd, buf, sizeof(buf))) > 0) {
+		for (dp = (struct dirent *)buf;
+		(char *)dp - buf < n;
+		dp = _DIRENT_NEXT(dp)) {
+			printf("%" PRIu64 ": %s\n", dp->d_fileno, dp->d_name);
+		}
+	}
+	rump_sys_close(fd);
+	if (argc == 1)
+		goto out;
+
+	rump_sys_chdir("/mp");
+	fd = rump_sys_open(argv[1], O_RDONLY, 0);
+	if (fd == -1) {
+		msg = "open fs file";
+		goto out;
+	}
+
+	fd_h = open(argv[2], O_RDWR | O_CREAT, 0777);
+	if (fd_h == -1) {
+		msg = "open host file";
+		goto out;
+	}
+
+	while ((n = rump_sys_read(fd, buf, sizeof(buf))) == sizeof(buf)) {
+		if (write(fd_h, buf, sizeof(buf)) != sizeof(buf)) {
+			msg = "write host file";
+			goto out;
+		}
+	}
+	if (n == -1) {
+		msg = "read fs file";
+		goto out;
+	}
+
+	if (n > 0) {
+		if (write(fd_h, buf, n) == -1)
+			msg = "write tail";
+	}
+
+ out:
+	sverrno = errno;
+	rump_sys_chdir("/");
+	rump_sys_close(fd);
+	close(fd_h);
+	if (rump_sys_unmount("/mp", 0) == -1)
+		err(1, "unmount");
+
+	if (msg) {
+		errno = sverrno;
+		err(1, "%s", msg);
+	}
+
+	return 0;
+}



CVS commit: src/share/examples/rump/img2cgd

2009-09-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Sep  8 21:51:33 UTC 2009

Modified Files:
src/share/examples/rump/img2cgd: img2cgd.c

Log Message:
* fix error print
* adjust resulting image minsize


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/rump/img2cgd/img2cgd.c

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

Modified files:

Index: src/share/examples/rump/img2cgd/img2cgd.c
diff -u src/share/examples/rump/img2cgd/img2cgd.c:1.1 src/share/examples/rump/img2cgd/img2cgd.c:1.2
--- src/share/examples/rump/img2cgd/img2cgd.c:1.1	Tue Sep  8 21:48:25 2009
+++ src/share/examples/rump/img2cgd/img2cgd.c	Tue Sep  8 21:51:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: img2cgd.c,v 1.1 2009/09/08 21:48:25 pooka Exp $	*/
+/*	$NetBSD: img2cgd.c,v 1.2 2009/09/08 21:51:33 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -48,7 +48,7 @@
 #define SIZEOFF	8
 
 #define SKIPLABEL 8192
-#define IMG_MINSIZE (128*1024) /* label/mbr/etc search looks here and there */
+#define IMG_MINSIZE (120*1024) /* label/mbr/etc search looks here and there */
 
 static void
 usage(void)
@@ -170,7 +170,7 @@
 		if (pread(fd, &tmpval, 8, MAGOFF) != 8)
 			err(1, "magic read failed");
 		if (tmpval != MYMAGIC)
-			errx(1, "%s is not a valid image", img_file);
+			errx(1, "%s is not a valid image", cgd_file);
 		if (pread(fd, &tmpval, 8, SIZEOFF) != 8)
 			errx(1, "size read failed");
 		close(fd);



CVS commit: src/share/examples/rump/img2cgd

2009-09-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Sep  8 21:48:25 UTC 2009

Added Files:
src/share/examples/rump/img2cgd: Makefile cgd.conf cgd_rumpops.c
img2cgd.c

Log Message:
Add a simple proof-of-concept program which shows how to use the
kernel cgd driver in an application which encrypts and decrypts
files.  The cgd driver is running completely in userspace and
requires no special access privileges.

For example:

golem> dmesg > dmesg.txt

# write encrypted dmesg.txt to encrypted.img
golem> ./img2cgd write encrypted.img dmesg.txt
/cryptfile's passphrase:

# read encrypted.img and output decrypted contents to decrypted.txt
golem> ./img2cgd read encrypted.img decypted.txt
/cryptfile's passphrase:
golem> diff dmesg.txt decypted.txt

# but when entering a different password:
golem> ./img2cgd read encrypted.img decypted.txt
/cryptfile's passphrase:
golem> diff dmesg.txt decypted.txt
Binary files dmesg.txt and decypted.txt differ

Currently the utility writes the data length in a proprietary
format, but I'll convert it to use a real disklabel RSN.  Then it
can be used to create cgd-encrypted disk images.

This program can later be used as a base for a utility to create
cgd-encrypted images of a standard NetBSD build.  Idea for such a
tool and hence the inspiration for this simple example program from
Roland Dowdeswell.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/examples/rump/img2cgd/Makefile \
src/share/examples/rump/img2cgd/cgd.conf \
src/share/examples/rump/img2cgd/cgd_rumpops.c \
src/share/examples/rump/img2cgd/img2cgd.c

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

Added files:

Index: src/share/examples/rump/img2cgd/Makefile
diff -u /dev/null src/share/examples/rump/img2cgd/Makefile:1.1
--- /dev/null	Tue Sep  8 21:48:25 2009
+++ src/share/examples/rump/img2cgd/Makefile	Tue Sep  8 21:48:25 2009
@@ -0,0 +1,16 @@
+PROG=	img2cgd
+SRCS=	img2cgd.c cgd_rumpops.c
+NOMAN=
+
+.include 
+
+.include "${NETBSDSRCDIR}/sbin/cgdconfig/Makefile.cgdconfig"
+
+LDADD+=	-lrumpdev_cgd -lrumpdev_disk -lrumpdev -lrumpcrypto
+LDADD+=	-lrumpvfs -lrump -lrumpuser -lpthread
+
+CPPFLAGS+=	-DCGDCONFIG_AS_LIB
+
+DBG=-g -O0
+
+.include 
Index: src/share/examples/rump/img2cgd/cgd.conf
diff -u /dev/null src/share/examples/rump/img2cgd/cgd.conf:1.1
--- /dev/null	Tue Sep  8 21:48:25 2009
+++ src/share/examples/rump/img2cgd/cgd.conf	Tue Sep  8 21:48:25 2009
@@ -0,0 +1,8 @@
+algorithm aes-cbc;
+iv-method encblkno1;
+keylength 128;
+verify_method none;
+keygen pkcs5_pbkdf2/sha1 {
+iterations 42;
+salt gGP2NZIYEnyKYALLRmdZdZc=;
+};
Index: src/share/examples/rump/img2cgd/cgd_rumpops.c
diff -u /dev/null src/share/examples/rump/img2cgd/cgd_rumpops.c:1.1
--- /dev/null	Tue Sep  8 21:48:25 2009
+++ src/share/examples/rump/img2cgd/cgd_rumpops.c	Tue Sep  8 21:48:25 2009
@@ -0,0 +1,49 @@
+/*	$NetBSD: cgd_rumpops.c,v 1.1 2009/09/08 21:48:25 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 
+#ifndef lint
+__RCSID("$NetBSD: cgd_rumpops.c,v 1.1 2009/09/08 21:48:25 pooka Exp $");
+#endif /* !lint */
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#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,
+};
Index: src/share/examples/rump/img2cgd/img2cgd.c
diff -u /dev/null src/share/examples/rump/img2cgd/img2cgd.c:1.1
--- /dev/null	Tue Sep  8 21:48:25 2009
+++ src/share/examples/rump/img2cg