Module Name:    src
Committed By:   pooka
Date:           Tue Apr 30 12:39:21 UTC 2013

Modified Files:
        src/lib/librumpuser: Makefile rumpuser.c rumpuser_component.c
            rumpuser_component.h rumpuser_daemonize.c rumpuser_int.h
            rumpuser_pth.c rumpuser_sp.c
        src/sys/rump/dev/lib/libugenhc: rumpcomp_user.c
        src/sys/rump/include/rump: rumpdefs.h
        src/sys/rump/net/lib/libshmif: rumpcomp_user.c
        src/sys/rump/net/lib/libsockin: rumpcomp_user.c
        src/sys/rump/net/lib/libvirtif: rumpcomp_user.c
Added Files:
        src/lib/librumpuser: rumpuser_errtrans.c

Log Message:
Translate error codes between the hypervisor and rump kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/librumpuser/Makefile
cvs rdiff -u -r1.46 -r1.47 src/lib/librumpuser/rumpuser.c
cvs rdiff -u -r1.4 -r1.5 src/lib/librumpuser/rumpuser_component.c \
    src/lib/librumpuser/rumpuser_daemonize.c
cvs rdiff -u -r1.2 -r1.3 src/lib/librumpuser/rumpuser_component.h
cvs rdiff -u -r0 -r1.1 src/lib/librumpuser/rumpuser_errtrans.c
cvs rdiff -u -r1.7 -r1.8 src/lib/librumpuser/rumpuser_int.h
cvs rdiff -u -r1.19 -r1.20 src/lib/librumpuser/rumpuser_pth.c
cvs rdiff -u -r1.57 -r1.58 src/lib/librumpuser/rumpuser_sp.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c
cvs rdiff -u -r1.17 -r1.18 src/sys/rump/include/rump/rumpdefs.h
cvs rdiff -u -r1.9 -r1.10 src/sys/rump/net/lib/libshmif/rumpcomp_user.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libsockin/rumpcomp_user.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c

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

Modified files:

Index: src/lib/librumpuser/Makefile
diff -u src/lib/librumpuser/Makefile:1.10 src/lib/librumpuser/Makefile:1.11
--- src/lib/librumpuser/Makefile:1.10	Mon Apr 29 12:56:04 2013
+++ src/lib/librumpuser/Makefile	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.10 2013/04/29 12:56:04 pooka Exp $
+#	$NetBSD: Makefile,v 1.11 2013/04/30 12:39:20 pooka Exp $
 #
 
 WARNS?=		5
@@ -14,7 +14,7 @@ CPPFLAGS+=	-DLIBRUMPUSER
 SRCS=		rumpuser.c
 SRCS+=		rumpuser_pth.c
 SRCS+=		rumpuser_dl.c rumpuser_sp.c rumpuser_daemonize.c rumpuser_bio.c
-SRCS+=		rumpuser_component.c
+SRCS+=		rumpuser_component.c rumpuser_errtrans.c
 
 INCSDIR=	/usr/include/rump
 INCS=		rumpuser.h rumpuser_component.h

Index: src/lib/librumpuser/rumpuser.c
diff -u src/lib/librumpuser/rumpuser.c:1.46 src/lib/librumpuser/rumpuser.c:1.47
--- src/lib/librumpuser/rumpuser.c:1.46	Tue Apr 30 11:26:26 2013
+++ src/lib/librumpuser/rumpuser.c	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.46 2013/04/30 11:26:26 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.47 2013/04/30 12:39:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.46 2013/04/30 11:26:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.47 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/ioctl.h>
@@ -206,7 +206,7 @@ rumpuser_getfileinfo(const char *path, u
 	if (fd != -1)
 		close(fd);
 
-	return rv;
+	ET(rv);
 }
 
 int
@@ -228,7 +228,7 @@ rumpuser_malloc(size_t howmuch, int alig
 	}
 
 	*memp = mem;
-	return rv;
+	ET(rv);
 }
 
 /*ARGSUSED1*/
@@ -265,16 +265,14 @@ rumpuser_anonmmap(void *prefaddr, size_t
 		rv = 0;
 	}
 
-	return rv;
+	ET(rv);
 }
 
 void
 rumpuser_unmap(void *addr, size_t len)
 {
-	int rv;
 
-	rv = munmap(addr, len);
-	assert(rv == 0);
+	munmap(addr, len);
 }
 
 int
@@ -311,7 +309,7 @@ rumpuser_open(const char *path, int rufl
 	}
 
  out:
-	return rv;
+	ET(rv);
 }
 
 int
@@ -324,7 +322,7 @@ rumpuser_close(int fd)
 	close(fd);
 	rumpkern_sched(nlocks, NULL);
 
-	return 0;
+	ET(0);
 }
 
 /*
@@ -361,7 +359,7 @@ rumpuser_iovread(int fd, struct rumpuser
 		rv = 0;
 	}
 
-	return rv;
+	ET(rv);
 }
 
 int
@@ -393,7 +391,7 @@ rumpuser_iovwrite(int fd, const struct r
 		rv = 0;
 	}
 
-	return rv;
+	ET(rv);
 }
 
 int
@@ -418,8 +416,7 @@ rumpuser_clock_gettime(uint64_t *sec, ui
 		abort();
 	}
 
-	rv = clock_gettime(clk, &ts);
-	if (rv == -1) {
+	if (clock_gettime(clk, &ts) == -1) {
 		rv = errno;
 	} else {
 		*sec = ts.tv_sec;
@@ -427,7 +424,7 @@ rumpuser_clock_gettime(uint64_t *sec, ui
 		rv = 0;
 	}
 
-	return rv;
+	ET(rv);
 }
 
 int
@@ -486,7 +483,8 @@ rumpuser_clock_sleep(uint64_t sec, uint6
 	}
 
 	rumpkern_sched(nlocks, NULL);
-	return rv;
+
+	ET(rv);
 }
 
 static int
@@ -556,7 +554,7 @@ rumpuser_getparam(const char *name, void
 			rv = 0;
 	}
 
-	return rv;
+	ET(rv);
 }
 
 void
@@ -616,7 +614,7 @@ rumpuser_kill(int64_t pid, int sig)
 	rv = EOPNOTSUPP;
 #endif
 
-	return rv;
+	ET(rv);
 }
 
 int
@@ -636,5 +634,5 @@ rumpuser_getrandom(void *buf, size_t buf
 	} while (chunk);
 
 	*retp = origlen;
-	return 0;
+	ET(0);
 }

Index: src/lib/librumpuser/rumpuser_component.c
diff -u src/lib/librumpuser/rumpuser_component.c:1.4 src/lib/librumpuser/rumpuser_component.c:1.5
--- src/lib/librumpuser/rumpuser_component.c:1.4	Mon Apr 29 15:20:05 2013
+++ src/lib/librumpuser/rumpuser_component.c	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_component.c,v 1.4 2013/04/29 15:20:05 pooka Exp $	*/
+/*	$NetBSD: rumpuser_component.c,v 1.5 2013/04/30 12:39:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_component.c,v 1.4 2013/04/29 15:20:05 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_component.c,v 1.5 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 /*
@@ -97,3 +97,10 @@ rumpuser_component_kthread_release(void)
 	rumpuser__hyp.hyp_lwproc_release();
 	rumpuser__hyp.hyp_unschedule();
 }
+
+int
+rumpuser_component_errtrans(int hosterr)
+{
+
+	return rumpuser__errtrans(hosterr);
+}
Index: src/lib/librumpuser/rumpuser_daemonize.c
diff -u src/lib/librumpuser/rumpuser_daemonize.c:1.4 src/lib/librumpuser/rumpuser_daemonize.c:1.5
--- src/lib/librumpuser/rumpuser_daemonize.c:1.4	Sun Nov 18 19:29:40 2012
+++ src/lib/librumpuser/rumpuser_daemonize.c	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_daemonize.c,v 1.4 2012/11/18 19:29:40 pooka Exp $	*/
+/*	$NetBSD: rumpuser_daemonize.c,v 1.5 2013/04/30 12:39:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_daemonize.c,v 1.4 2012/11/18 19:29:40 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_daemonize.c,v 1.5 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -39,6 +39,8 @@ __RCSID("$NetBSD: rumpuser_daemonize.c,v
 #include <stdio.h>
 #include <unistd.h>
 
+#include "rumpuser_int.h"
+
 #ifdef __sun__
 #define _PATH_DEVNULL "/dev/null"
 #else
@@ -55,9 +57,12 @@ rumpuser_daemonize_begin(void)
 {
 	ssize_t n;
 	int error;
+	int rv;
 
-	if (isdaemonizing)
-		return EINPROGRESS;
+	if (isdaemonizing) {
+		rv = EINPROGRESS;
+		goto out;
+	}
 	isdaemonizing = 1;
 
 	/*
@@ -72,7 +77,8 @@ rumpuser_daemonize_begin(void)
 	 * take care of that or not.
 	 */
 	if (socketpair(PF_LOCAL, SOCK_STREAM, 0, daemonpipe) == -1) {
-		return errno;
+		rv = errno;
+		goto out;
 	}
 
 	switch (fork()) {
@@ -80,9 +86,11 @@ rumpuser_daemonize_begin(void)
 		if (setsid() == -1) {
 			rumpuser_daemonize_done(errno);
 		}
-		return 0;
+		rv = 0;
+		break;
 	case -1:
-		return errno;
+		rv = errno;
+		break;
 	default:
 		close(daemonpipe[1]);
 		n = recv(daemonpipe[0], &error, sizeof(error), MSG_NOSIGNAL);
@@ -93,16 +101,21 @@ rumpuser_daemonize_begin(void)
 		_exit(error);
 		/*NOTREACHED*/
 	}
+
+ out:
+	ET(rv);
 }
 
 int
 rumpuser_daemonize_done(int error)
 {
 	ssize_t n;
-	int fd;
+	int fd, rv = 0;
 
-	if (!isdaemonizing)
-		return ENOENT;
+	if (!isdaemonizing) {
+		rv = ENOENT;
+		goto outout;
+	}
 
 	if (error == 0) {
 		fd = open(_PATH_DEVNULL, O_RDWR);
@@ -119,12 +132,15 @@ rumpuser_daemonize_done(int error)
 
  out:
 	n = send(daemonpipe[1], &error, sizeof(error), MSG_NOSIGNAL);
-	if (n != sizeof(error))
-		return EPIPE;
-	else if (n == -1)
-		return errno;
-	close(daemonpipe[0]);
-	close(daemonpipe[1]);
+	if (n != sizeof(error)) {
+		rv = EPIPE;
+	} else if (n == -1) {
+		rv = errno;
+	} else {
+		close(daemonpipe[0]);
+		close(daemonpipe[1]);
+	}
 
-	return 0;
+ outout:
+	ET(rv);
 }

Index: src/lib/librumpuser/rumpuser_component.h
diff -u src/lib/librumpuser/rumpuser_component.h:1.2 src/lib/librumpuser/rumpuser_component.h:1.3
--- src/lib/librumpuser/rumpuser_component.h:1.2	Mon Apr 29 15:20:05 2013
+++ src/lib/librumpuser/rumpuser_component.h	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_component.h,v 1.2 2013/04/29 15:20:05 pooka Exp $	*/
+/*	$NetBSD: rumpuser_component.h,v 1.3 2013/04/30 12:39:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -30,6 +30,7 @@
 
 void *	rumpuser_component_unschedule(void);
 void	rumpuser_component_schedule(void *);
+int	rumpuser_component_errtrans(int);
 
 void	rumpuser_component_kthread(void);
 struct lwp *rumpuser_component_curlwp(void);

Index: src/lib/librumpuser/rumpuser_int.h
diff -u src/lib/librumpuser/rumpuser_int.h:1.7 src/lib/librumpuser/rumpuser_int.h:1.8
--- src/lib/librumpuser/rumpuser_int.h:1.7	Mon Apr 29 14:51:39 2013
+++ src/lib/librumpuser/rumpuser_int.h	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_int.h,v 1.7 2013/04/29 14:51:39 pooka Exp $	*/
+/*	$NetBSD: rumpuser_int.h,v 1.8 2013/04/30 12:39:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -93,3 +93,10 @@ do {									\
 		abort();						\
 	}								\
 } while (/*CONSTCOND*/0)
+
+int  rumpuser__errtrans(int);
+#ifdef __NetBSD__
+#define ET(_v_) return (_v_);
+#else
+#define ET(_v_) return (_v_) ? rumpuser__errtrans(_v_) : 0;
+#endif

Index: src/lib/librumpuser/rumpuser_pth.c
diff -u src/lib/librumpuser/rumpuser_pth.c:1.19 src/lib/librumpuser/rumpuser_pth.c:1.20
--- src/lib/librumpuser/rumpuser_pth.c:1.19	Tue Apr 30 00:03:52 2013
+++ src/lib/librumpuser/rumpuser_pth.c	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser_pth.c,v 1.19 2013/04/30 00:03:52 pooka Exp $	*/
+/*	$NetBSD: rumpuser_pth.c,v 1.20 2013/04/30 12:39:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.19 2013/04/30 00:03:52 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.20 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 #include <assert.h>
@@ -144,7 +144,7 @@ rumpuser_thread_create(void *(*f)(void *
 
 	pthread_attr_destroy(&pattr);
 
-	return rv;
+	ET(rv);
 }
 
 __dead void
@@ -164,7 +164,7 @@ rumpuser_thread_join(void *ptcookie)
 	if (rv == 0)
 		free(pt);
 
-	return rv;
+	ET(rv);
 }
 
 void
@@ -240,7 +240,7 @@ rumpuser_mutex_tryenter(struct rumpuser_
 		mtxenter(mtx);
 	}
 
-	return rv;
+	ET(rv);
 }
 
 void
@@ -314,7 +314,7 @@ rumpuser_rw_tryenter(struct rumpuser_rw 
 			RURW_INCREAD(rw);
 	}
 
-	return rv;
+	ET(rv);
 }
 
 void
@@ -431,7 +431,7 @@ rumpuser_cv_timedwait(struct rumpuser_cv
 	rumpkern_sched(nlocks, mtx);
 	cv->nwaiters--;
 
-	return rv;
+	ET(rv);
 }
 
 void

Index: src/lib/librumpuser/rumpuser_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.57 src/lib/librumpuser/rumpuser_sp.c:1.58
--- src/lib/librumpuser/rumpuser_sp.c:1.57	Tue Apr 30 00:03:52 2013
+++ src/lib/librumpuser/rumpuser_sp.c	Tue Apr 30 12:39:20 2013
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpuser_sp.c,v 1.57 2013/04/30 00:03:52 pooka Exp $	*/
+/*      $NetBSD: rumpuser_sp.c,v 1.58 2013/04/30 12:39:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.57 2013/04/30 00:03:52 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.58 2013/04/30 12:39:20 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -795,21 +795,25 @@ sp_copyin(void *arg, const void *raddr, 
 	rumpkern_sched(nlocks, NULL);
 	if (rv)
 		rv = EFAULT;
-	return rv;
+	ET(rv);
 }
 
 int
 rumpuser_sp_copyin(void *arg, const void *raddr, void *laddr, size_t len)
 {
+	int rv;
 
-	return sp_copyin(arg, raddr, laddr, &len, 0);
+	rv = sp_copyin(arg, raddr, laddr, &len, 0);
+	ET(rv);
 }
 
 int
 rumpuser_sp_copyinstr(void *arg, const void *raddr, void *laddr, size_t *len)
 {
+	int rv;
 
-	return sp_copyin(arg, raddr, laddr, len, 1);
+	rv = sp_copyin(arg, raddr, laddr, len, 1);
+	ET(rv);
 }
 
 static int
@@ -824,21 +828,25 @@ sp_copyout(void *arg, const void *laddr,
 
 	if (rv)
 		rv = EFAULT;
-	return 0;
+	ET(rv);
 }
 
 int
 rumpuser_sp_copyout(void *arg, const void *laddr, void *raddr, size_t dlen)
 {
+	int rv;
 
-	return sp_copyout(arg, laddr, raddr, dlen);
+	rv = sp_copyout(arg, laddr, raddr, dlen);
+	ET(rv);
 }
 
 int
 rumpuser_sp_copyoutstr(void *arg, const void *laddr, void *raddr, size_t *dlen)
 {
+	int rv;
 
-	return sp_copyout(arg, laddr, raddr, *dlen);
+	rv = sp_copyout(arg, laddr, raddr, *dlen);
+	ET(rv);
 }
 
 int
@@ -867,7 +875,7 @@ rumpuser_sp_anonmmap(void *arg, size_t h
 
  out:
 	rumpkern_sched(nlocks, NULL);
-	return rv;
+	ET(rv);
 }
 
 int
@@ -1358,7 +1366,7 @@ rumpuser_sp_init(const char *url,
 	pthread_detach(pt);
 
  out:
-	return error;
+	ET(error);
 }
 
 void

Index: src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c
diff -u src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.4 src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.5
--- src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c:1.4	Tue Apr 30 00:03:52 2013
+++ src/sys/rump/dev/lib/libugenhc/rumpcomp_user.c	Tue Apr 30 12:39:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.4 2013/04/30 00:03:52 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.5 2013/04/30 12:39:21 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -48,6 +48,6 @@ rumpcomp_ugenhc_ioctl(int fd, u_long cmd
 		rv = 0;
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 #endif

Index: src/sys/rump/include/rump/rumpdefs.h
diff -u src/sys/rump/include/rump/rumpdefs.h:1.17 src/sys/rump/include/rump/rumpdefs.h:1.18
--- src/sys/rump/include/rump/rumpdefs.h:1.17	Thu Dec 13 17:17:21 2012
+++ src/sys/rump/include/rump/rumpdefs.h	Tue Apr 30 12:39:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpdefs.h,v 1.17 2012/12/13 17:17:21 pooka Exp $	*/
+/*	$NetBSD: rumpdefs.h,v 1.18 2013/04/30 12:39:21 pooka Exp $	*/
 
 /*
  *	AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -9,7 +9,7 @@
 
 #include <rump/rump_namei.h>
 
-/*	NetBSD: fcntl.h,v 1.43 2012/11/18 17:41:54 manu Exp 	*/
+/*	NetBSD: fcntl.h,v 1.45 2013/01/13 08:15:03 dholland Exp 	*/
 #define	RUMP_O_RDONLY	0x00000000	/* open for reading only */
 #define	RUMP_O_WRONLY	0x00000001	/* open for writing only */
 #define	RUMP_O_RDWR		0x00000002	/* open for reading and writing */
@@ -40,7 +40,7 @@ enum rump_vtype	{ RUMP_VNON, RUMP_VREG, 
 #define	RUMP_LK_NOWAIT	0x00000010	
 #define	RUMP_LK_RETRY	0x00020000	
 
-/*	NetBSD: errno.h,v 1.39 2006/10/31 00:38:07 cbiere Exp 	*/
+/*	NetBSD: errno.h,v 1.40 2013/01/02 18:51:53 dsl Exp 	*/
 #define	RUMP_EPERM		1		/* Operation not permitted */
 #define	RUMP_ENOENT		2		/* No such file or directory */
 #define	RUMP_ESRCH		3		/* No such process */
@@ -170,7 +170,7 @@ enum rump_vtype	{ RUMP_VNON, RUMP_VREG, 
 #define	RUMP_AB_SILENT	0x00040000	
 #define	RUMP_AB_DEBUG	0x00080000	
 
-/*	NetBSD: socket.h,v 1.107 2012/06/22 18:26:35 christos Exp 	*/
+/*	NetBSD: socket.h,v 1.108 2013/01/31 14:30:47 joerg Exp 	*/
 #define	RUMP_SOCK_STREAM	1		
 #define	RUMP_SOCK_DGRAM	2		
 #define	RUMP_SOCK_RAW	3		

Index: src/sys/rump/net/lib/libshmif/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libshmif/rumpcomp_user.c:1.9 src/sys/rump/net/lib/libshmif/rumpcomp_user.c:1.10
--- src/sys/rump/net/lib/libshmif/rumpcomp_user.c:1.9	Tue Apr 30 00:33:16 2013
+++ src/sys/rump/net/lib/libshmif/rumpcomp_user.c	Tue Apr 30 12:39:21 2013
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpcomp_user.c,v 1.9 2013/04/30 00:33:16 pooka Exp $	*/
+/*      $NetBSD: rumpcomp_user.c,v 1.10 2013/04/30 12:39:21 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2010 Antti Kantee.  All Rights Reserved.
@@ -70,7 +70,7 @@ rumpcomp_shmif_watchsetup(int *kqp, int 
 	}
 
  out:
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -91,7 +91,7 @@ rumpcomp_shmif_watchwait(int kq)
 	}
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 #elif defined(__linux__)
@@ -135,7 +135,7 @@ rumpcomp_shmif_watchsetup(int *inotifyp,
 	rv = 0;
 
  out:
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -158,7 +158,7 @@ rumpcomp_shmif_watchwait(int kq)
 		
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 #else
@@ -217,6 +217,6 @@ rumpcomp_shmif_mmap(int fd, size_t len, 
 	}
 
  out:
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 #endif

Index: src/sys/rump/net/lib/libsockin/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libsockin/rumpcomp_user.c:1.4 src/sys/rump/net/lib/libsockin/rumpcomp_user.c:1.5
--- src/sys/rump/net/lib/libsockin/rumpcomp_user.c:1.4	Tue Apr 30 00:03:54 2013
+++ src/sys/rump/net/lib/libsockin/rumpcomp_user.c	Tue Apr 30 12:39:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.4 2013/04/30 00:03:54 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.5 2013/04/30 12:39:21 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -49,7 +49,7 @@ rumpcomp_sockin_socket(int domain, int t
 	seterror(*s);
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -65,7 +65,7 @@ rumpcomp_sockin_sendmsg(int s, const str
 	*snd = (size_t)nn;
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -81,7 +81,7 @@ rumpcomp_sockin_recvmsg(int s, struct ms
 	*rcv = (size_t)nn;
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -95,7 +95,7 @@ rumpcomp_sockin_connect(int s, const str
 	seterror(rv);
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -109,7 +109,7 @@ rumpcomp_sockin_bind(int s, const struct
 	seterror(rv);
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -123,7 +123,7 @@ rumpcomp_sockin_accept(int s, struct soc
 	seterror(*s2);
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -137,7 +137,7 @@ rumpcomp_sockin_listen(int s, int backlo
 	seterror(rv);
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -154,7 +154,7 @@ rumpcomp_sockin_getname(int s, struct so
 	seterror(rv);
 	*lenp = slen;
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -167,7 +167,7 @@ rumpcomp_sockin_setsockopt(int s, int le
 	rv = setsockopt(s, level, name, data, slen);
 	seterror(rv);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 int
@@ -181,6 +181,6 @@ rumpcomp_sockin_poll(struct pollfd *fds,
 	seterror(*nready);
 	rumpuser_component_schedule(cookie);
 
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 #endif

Index: src/sys/rump/net/lib/libvirtif/rumpcomp_user.c
diff -u src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.4 src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.5
--- src/sys/rump/net/lib/libvirtif/rumpcomp_user.c:1.4	Tue Apr 30 00:03:54 2013
+++ src/sys/rump/net/lib/libvirtif/rumpcomp_user.c	Tue Apr 30 12:39:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpcomp_user.c,v 1.4 2013/04/30 00:03:54 pooka Exp $	*/
+/*	$NetBSD: rumpcomp_user.c,v 1.5 2013/04/30 12:39:21 pooka Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -119,7 +119,7 @@ rumpcomp_virtif_create(int devnum, struc
 	rumpuser_component_schedule(cookie);
 
 	*viup = viu;
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 
 void
@@ -174,7 +174,7 @@ rumpcomp_virtif_recv(struct virtif_user 
 	}
 
 	rumpuser_component_schedule(cookie);
-	return rv;
+	return rumpuser_component_errtrans(rv);
 }
 #undef POLLTIMO_MS
 

Added files:

Index: src/lib/librumpuser/rumpuser_errtrans.c
diff -u /dev/null src/lib/librumpuser/rumpuser_errtrans.c:1.1
--- /dev/null	Tue Apr 30 12:39:22 2013
+++ src/lib/librumpuser/rumpuser_errtrans.c	Tue Apr 30 12:39:20 2013
@@ -0,0 +1,321 @@
+/*	$NetBSD: rumpuser_errtrans.c,v 1.1 2013/04/30 12:39:20 pooka Exp $	*/
+
+/*
+ * pseudo-automatically generated.  PLEASE DO EDIT (e.g. in case there
+ * are errnos which are defined to be the same value)
+ *
+ *   awk '/^#define/{printf "#ifdef %s\n\tcase %-15s: return %s;\n#endif\n", \
+ *        $2, $2, $3}' < errno.h
+ *
+ */
+
+#include <errno.h>
+
+/*
+ * Translate host errno to rump kernel errno
+ */
+int rumpuser__errtrans(int); /* a naughty decouple */
+int
+rumpuser__errtrans(int hosterr)
+{
+
+	/* just in case the vompiler is being silly */
+	if (hosterr == 0)
+		return 0;
+
+	switch (hosterr) {
+#ifdef EPERM
+	case EPERM          : return 1;
+#endif
+#ifdef ENOENT
+	case ENOENT         : return 2;
+#endif
+#ifdef ESRCH
+	case ESRCH          : return 3;
+#endif
+#ifdef EINTR
+	case EINTR          : return 4;
+#endif
+#ifdef EIO
+	case EIO            : return 5;
+#endif
+#ifdef ENXIO
+	case ENXIO          : return 6;
+#endif
+#ifdef E2BIG
+	case E2BIG          : return 7;
+#endif
+#ifdef ENOEXEC
+	case ENOEXEC        : return 8;
+#endif
+#ifdef EBADF
+	case EBADF          : return 9;
+#endif
+#ifdef ECHILD
+	case ECHILD         : return 10;
+#endif
+#ifdef EDEADLK
+	case EDEADLK        : return 11;
+#endif
+#ifdef ENOMEM
+	case ENOMEM         : return 12;
+#endif
+#ifdef EACCES
+	case EACCES         : return 13;
+#endif
+#ifdef EFAULT
+	case EFAULT         : return 14;
+#endif
+#ifdef ENOTBLK
+	case ENOTBLK        : return 15;
+#endif
+#ifdef EBUSY
+	case EBUSY          : return 16;
+#endif
+#ifdef EEXIST
+	case EEXIST         : return 17;
+#endif
+#ifdef EXDEV
+	case EXDEV          : return 18;
+#endif
+#ifdef ENODEV
+	case ENODEV         : return 19;
+#endif
+#ifdef ENOTDIR
+	case ENOTDIR        : return 20;
+#endif
+#ifdef EISDIR
+	case EISDIR         : return 21;
+#endif
+#ifdef EINVAL
+	case EINVAL         : return 22;
+#endif
+#ifdef ENFILE
+	case ENFILE         : return 23;
+#endif
+#ifdef EMFILE
+	case EMFILE         : return 24;
+#endif
+#ifdef ENOTTY
+	case ENOTTY         : return 25;
+#endif
+#ifdef ETXTBSY
+	case ETXTBSY        : return 26;
+#endif
+#ifdef EFBIG
+	case EFBIG          : return 27;
+#endif
+#ifdef ENOSPC
+	case ENOSPC         : return 28;
+#endif
+#ifdef ESPIPE
+	case ESPIPE         : return 29;
+#endif
+#ifdef EROFS
+	case EROFS          : return 30;
+#endif
+#ifdef EMLINK
+	case EMLINK         : return 31;
+#endif
+#ifdef EPIPE
+	case EPIPE          : return 32;
+#endif
+#ifdef EDOM
+	case EDOM           : return 33;
+#endif
+#ifdef ERANGE
+	case ERANGE         : return 34;
+#endif
+#ifdef EAGAIN
+	case EAGAIN         : return 35;
+#endif
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+	case EWOULDBLOCK    : return 35;
+#endif
+#ifdef EINPROGRESS
+	case EINPROGRESS    : return 36;
+#endif
+#ifdef EALREADY
+	case EALREADY       : return 37;
+#endif
+#ifdef ENOTSOCK
+	case ENOTSOCK       : return 38;
+#endif
+#ifdef EDESTADDRREQ
+	case EDESTADDRREQ   : return 39;
+#endif
+#ifdef EMSGSIZE
+	case EMSGSIZE       : return 40;
+#endif
+#ifdef EPROTOTYPE
+	case EPROTOTYPE     : return 41;
+#endif
+#ifdef ENOPROTOOPT
+	case ENOPROTOOPT    : return 42;
+#endif
+#ifdef EPROTONOSUPPORT
+	case EPROTONOSUPPORT: return 43;
+#endif
+#ifdef ESOCKTNOSUPPORT
+	case ESOCKTNOSUPPORT: return 44;
+#endif
+#ifdef EOPNOTSUPP
+	case EOPNOTSUPP     : return 45;
+#endif
+#ifdef EPFNOSUPPORT
+	case EPFNOSUPPORT   : return 46;
+#endif
+#ifdef EAFNOSUPPORT
+	case EAFNOSUPPORT   : return 47;
+#endif
+#ifdef EADDRINUSE
+	case EADDRINUSE     : return 48;
+#endif
+#ifdef EADDRNOTAVAIL
+	case EADDRNOTAVAIL  : return 49;
+#endif
+#ifdef ENETDOWN
+	case ENETDOWN       : return 50;
+#endif
+#ifdef ENETUNREACH
+	case ENETUNREACH    : return 51;
+#endif
+#ifdef ENETRESET
+	case ENETRESET      : return 52;
+#endif
+#ifdef ECONNABORTED
+	case ECONNABORTED   : return 53;
+#endif
+#ifdef ECONNRESET
+	case ECONNRESET     : return 54;
+#endif
+#ifdef ENOBUFS
+	case ENOBUFS        : return 55;
+#endif
+#ifdef EISCONN
+	case EISCONN        : return 56;
+#endif
+#ifdef ENOTCONN
+	case ENOTCONN       : return 57;
+#endif
+#ifdef ESHUTDOWN
+	case ESHUTDOWN      : return 58;
+#endif
+#ifdef ETOOMANYREFS
+	case ETOOMANYREFS   : return 59;
+#endif
+#ifdef ETIMEDOUT
+	case ETIMEDOUT      : return 60;
+#endif
+#ifdef ECONNREFUSED
+	case ECONNREFUSED   : return 61;
+#endif
+#ifdef ELOOP
+	case ELOOP          : return 62;
+#endif
+#ifdef ENAMETOOLONG
+	case ENAMETOOLONG   : return 63;
+#endif
+#ifdef EHOSTDOWN
+	case EHOSTDOWN      : return 64;
+#endif
+#ifdef EHOSTUNREACH
+	case EHOSTUNREACH   : return 65;
+#endif
+#ifdef ENOTEMPTY
+	case ENOTEMPTY      : return 66;
+#endif
+#ifdef EPROCLIM
+	case EPROCLIM       : return 67;
+#endif
+#ifdef EUSERS
+	case EUSERS         : return 68;
+#endif
+#ifdef EDQUOT
+	case EDQUOT         : return 69;
+#endif
+#ifdef ESTALE
+	case ESTALE         : return 70;
+#endif
+#ifdef EREMOTE
+	case EREMOTE        : return 71;
+#endif
+#ifdef EBADRPC
+	case EBADRPC        : return 72;
+#endif
+#ifdef ERPCMISMATCH
+	case ERPCMISMATCH   : return 73;
+#endif
+#ifdef EPROGUNAVAIL
+	case EPROGUNAVAIL   : return 74;
+#endif
+#ifdef EPROGMISMATCH
+	case EPROGMISMATCH  : return 75;
+#endif
+#ifdef EPROCUNAVAIL
+	case EPROCUNAVAIL   : return 76;
+#endif
+#ifdef ENOLCK
+	case ENOLCK         : return 77;
+#endif
+#ifdef ENOSYS
+	case ENOSYS         : return 78;
+#endif
+#ifdef EFTYPE
+	case EFTYPE         : return 79;
+#endif
+#ifdef EAUTH
+	case EAUTH          : return 80;
+#endif
+#ifdef ENEEDAUTH
+	case ENEEDAUTH      : return 81;
+#endif
+#ifdef EIDRM
+	case EIDRM          : return 82;
+#endif
+#ifdef ENOMSG
+	case ENOMSG         : return 83;
+#endif
+#ifdef EOVERFLOW
+	case EOVERFLOW      : return 84;
+#endif
+#ifdef EILSEQ
+	case EILSEQ         : return 85;
+#endif
+#if defined(ENOTSUP) && (!defined(EOPNOTSUPP) || ENOTSUP != EOPNOTSUPP)
+	case ENOTSUP        : return 86;
+#endif
+#ifdef ECANCELED
+	case ECANCELED      : return 87;
+#endif
+#ifdef EBADMSG
+	case EBADMSG        : return 88;
+#endif
+#ifdef ENODATA
+	case ENODATA        : return 89;
+#endif
+#ifdef ENOSR
+	case ENOSR          : return 90;
+#endif
+#ifdef ENOSTR
+	case ENOSTR         : return 91;
+#endif
+#ifdef ETIME
+	case ETIME          : return 92;
+#endif
+#ifdef ENOATTR
+	case ENOATTR        : return 93;
+#endif
+#ifdef EMULTIHOP
+	case EMULTIHOP      : return 94;
+#endif
+#ifdef ENOLINK
+	case ENOLINK        : return 95;
+#endif
+#ifdef EPROTO
+	case EPROTO         : return 96;
+#endif
+
+	default             : return 22; /* EINVAL */
+	}
+}

Reply via email to