Module Name:    src
Committed By:   pooka
Date:           Thu Mar 13 01:42:59 UTC 2014

Modified Files:
        src/sys/rump/net/lib/libshmif: Makefile if_shmem.c
Added Files:
        src/sys/rump/net/lib/libshmif: shmif_user.c shmif_user.h
Removed Files:
        src/sys/rump/net/lib/libshmif: rumpcomp_user.c rumpcomp_user.h

Log Message:
rename rumpcomp_user.* -> shmif_user.*


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libshmif/Makefile
cvs rdiff -u -r1.58 -r1.59 src/sys/rump/net/lib/libshmif/if_shmem.c
cvs rdiff -u -r1.14 -r0 src/sys/rump/net/lib/libshmif/rumpcomp_user.c
cvs rdiff -u -r1.4 -r0 src/sys/rump/net/lib/libshmif/rumpcomp_user.h
cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libshmif/shmif_user.c \
    src/sys/rump/net/lib/libshmif/shmif_user.h

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

Modified files:

Index: src/sys/rump/net/lib/libshmif/Makefile
diff -u src/sys/rump/net/lib/libshmif/Makefile:1.4 src/sys/rump/net/lib/libshmif/Makefile:1.5
--- src/sys/rump/net/lib/libshmif/Makefile:1.4	Sun Apr 28 10:43:45 2013
+++ src/sys/rump/net/lib/libshmif/Makefile	Thu Mar 13 01:42:59 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2013/04/28 10:43:45 pooka Exp $
+#	$NetBSD: Makefile,v 1.5 2014/03/13 01:42:59 pooka Exp $
 #
 
 LIB=	rumpnet_shmif
@@ -8,7 +8,7 @@ SRCS+=	component.c
 
 CPPFLAGS+=	-I${.CURDIR}/../../../librump/rumpkern
 
-RUMPCOMP_USER=	# filewatch
+RUMPCOMP_USER_SRCS=	shmif_user.c
 
 .include <bsd.lib.mk>
 .include <bsd.klinks.mk>

Index: src/sys/rump/net/lib/libshmif/if_shmem.c
diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.58 src/sys/rump/net/lib/libshmif/if_shmem.c:1.59
--- src/sys/rump/net/lib/libshmif/if_shmem.c:1.58	Fri Sep 13 20:38:04 2013
+++ src/sys/rump/net/lib/libshmif/if_shmem.c	Thu Mar 13 01:42:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_shmem.c,v 1.58 2013/09/13 20:38:04 joerg Exp $	*/
+/*	$NetBSD: if_shmem.c,v 1.59 2014/03/13 01:42:59 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.58 2013/09/13 20:38:04 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.59 2014/03/13 01:42:59 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -52,7 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v
 
 #include "rump_private.h"
 #include "rump_net_private.h"
-#include "rumpcomp_user.h"
+#include "shmif_user.h"
 
 static int shmif_clone(struct if_clone *, int);
 static int shmif_unclone(struct ifnet *);

Added files:

Index: src/sys/rump/net/lib/libshmif/shmif_user.c
diff -u /dev/null src/sys/rump/net/lib/libshmif/shmif_user.c:1.1
--- /dev/null	Thu Mar 13 01:42:59 2014
+++ src/sys/rump/net/lib/libshmif/shmif_user.c	Thu Mar 13 01:42:59 2014
@@ -0,0 +1,230 @@
+/*      $NetBSD: shmif_user.c,v 1.1 2014/03/13 01:42:59 pooka Exp $	*/
+
+/*-
+ * Copyright (c) 2009, 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.
+ */
+#ifndef _KERNEL
+#include <sys/types.h>
+#include <sys/mman.h>
+
+#include <errno.h>
+
+#include <rump/rumpuser_component.h>
+
+#include "shmif_user.h"
+
+#define seterr(_v_) if ((_v_) == -1) *error = errno; else *error = 0;
+
+/*
+ * On BSD we use kqueue, on Linux we use inotify.  The underlying
+ * interface requirements aren't quite the same, but we have a very
+ * good chance of doing the fd->path mapping on Linux thanks to dcache,
+ * so just keep the existing interfaces for now.
+ */
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) \
+    || defined(__OpenBSD__)
+#include <sys/event.h>
+
+#include <stdlib.h>
+
+int
+rumpcomp_shmif_watchsetup(int *kqp, int fd)
+{
+	struct kevent kev;
+	int rv, kq;
+
+	kq = *kqp;
+	if (kq == -1) {
+		kq = kqueue();
+		if (kq == -1) {
+			rv = errno;
+			goto out;
+		}
+	}
+
+	EV_SET(&kev, fd, EVFILT_VNODE, EV_ADD|EV_ENABLE|EV_CLEAR,
+	    NOTE_WRITE, 0, 0);
+	if (kevent(kq, &kev, 1, NULL, 0, NULL) == -1) {
+		rv = errno;
+	} else {
+		rv = 0;
+		*kqp = kq;
+	}
+
+ out:
+	return rumpuser_component_errtrans(rv);
+}
+
+int
+rumpcomp_shmif_watchwait(int kq)
+{
+	void *cookie;
+	struct kevent kev;
+	int rv;
+
+	cookie = rumpuser_component_unschedule();
+	do {
+		rv = kevent(kq, NULL, 0, &kev, 1, NULL);
+	} while (rv == -1 && errno == EINTR);
+	if (rv == -1) {
+		rv = errno;
+	} else {
+		rv = 0;
+	}
+	rumpuser_component_schedule(cookie);
+
+	return rumpuser_component_errtrans(rv);
+}
+
+#elif defined(__linux__)
+#include <sys/inotify.h>
+
+#include <limits.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int
+rumpcomp_shmif_watchsetup(int *inotifyp, int fd)
+{
+	char procbuf[PATH_MAX], linkbuf[PATH_MAX];
+	ssize_t nn;
+	int inotify, rv;
+
+	inotify = *inotifyp;
+	if (inotify == -1) {
+		inotify = inotify_init();
+		if (inotify == -1) {
+			rv = errno;
+			goto out;
+		}
+	}
+
+	/* ok, need to map fd into path for inotify */
+	snprintf(procbuf, sizeof(procbuf), "/proc/self/fd/%d", fd);
+	nn = readlink(procbuf, linkbuf, sizeof(linkbuf)-1);
+	if (nn >= (ssize_t)sizeof(linkbuf)-1) {
+		nn = -1;
+		errno = E2BIG; /* pick something */
+	}
+	if (nn == -1) {
+		rv = errno;
+		close(inotify);
+		goto out;
+	}
+
+	linkbuf[nn] = '\0';
+	if (inotify_add_watch(inotify, linkbuf, IN_MODIFY) == -1) {
+		rv = errno;
+		close(inotify);
+		goto out;
+	}
+	rv = 0;
+	*inotifyp = inotify;
+
+ out:
+	return rumpuser_component_errtrans(rv);
+}
+
+int
+rumpcomp_shmif_watchwait(int kq)
+{
+	struct inotify_event iev;
+	void *cookie;
+	ssize_t nn;
+	int rv;
+
+	cookie = rumpuser_component_unschedule();
+	do {
+		nn = read(kq, &iev, sizeof(iev));
+	} while (nn == -1 && errno == EINTR);
+	if (nn == -1) {
+		rv = errno;
+	} else {
+		rv = 0;
+	}
+		
+	rumpuser_component_schedule(cookie);
+
+	return rumpuser_component_errtrans(rv);
+}
+
+#else
+#include <stdio.h>
+#include <unistd.h>
+
+/* a polling default implementation */
+int
+rumpcomp_shmif_watchsetup(int *nono, int fd)
+{
+	static int warned = 0;
+
+	if (!warned) {
+		fprintf(stderr, "WARNING: rumpuser writewatchfile routines are "
+		    "polling-only on this platform\n");
+		warned = 1;
+	}
+
+	return 0;
+}
+
+int
+rumpcomp_shmif_watchwait(int kq)
+{
+	void *cookie;
+
+	cookie = rumpuser_component_unschedule();
+	usleep(10000);
+	rumpuser_component_schedule(cookie);
+
+	return 0;
+}
+#endif
+
+int
+rumpcomp_shmif_mmap(int fd, size_t len, void **memp)
+{
+	void *mem;
+	int rv;
+
+	if (ftruncate(fd, len) == -1) {
+		rv = errno;
+		goto out;
+	}
+
+#if defined(__sun__) && !defined(MAP_FILE)
+#define MAP_FILE 0
+#endif
+	
+	mem = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, 0);
+	if (mem == MAP_FAILED) {
+		rv = errno;
+	} else {
+		rv = 0;
+		*memp = mem;
+	}
+
+ out:
+	return rumpuser_component_errtrans(rv);
+}
+#endif
Index: src/sys/rump/net/lib/libshmif/shmif_user.h
diff -u /dev/null src/sys/rump/net/lib/libshmif/shmif_user.h:1.1
--- /dev/null	Thu Mar 13 01:42:59 2014
+++ src/sys/rump/net/lib/libshmif/shmif_user.h	Thu Mar 13 01:42:59 2014
@@ -0,0 +1,30 @@
+/*	$NetBSD: shmif_user.h,v 1.1 2014/03/13 01:42:59 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2013 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.
+ */
+
+int	rumpcomp_shmif_watchsetup(int *, int);
+int	rumpcomp_shmif_watchwait(int);
+int	rumpcomp_shmif_mmap(int, size_t, void **);

Reply via email to