From owner-freebsd-emulation@FreeBSD.ORG Sat Sep 1 15:40:44 2012 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 035B9106566C for ; Sat, 1 Sep 2012 15:40:44 +0000 (UTC) (envelope-from holger@freyther.de) Received: from mail.sysmocom.de (sysmocom.de [78.46.147.233]) by mx1.freebsd.org (Postfix) with ESMTP id B448C8FC0A for ; Sat, 1 Sep 2012 15:40:43 +0000 (UTC) Received: from sangmingze-mail.local (91-66-230-199-dynip.superkabel.de [91.66.230.199]) by mail.sysmocom.de (Postfix) with ESMTPSA id 25EDF254346B for ; Sat, 1 Sep 2012 15:36:23 +0000 (UTC) Received: from ich by sangmingze-mail.local with local (Exim 4.80) (envelope-from ) id 1T7phs-0004VT-Hv for freebsd-emulation@freebsd.org; Sat, 01 Sep 2012 17:33:56 +0200 Date: Sat, 1 Sep 2012 17:33:56 +0200 From: Holger Hans Peter Freyther To: freebsd-emulation@freebsd.org Message-ID: <20120901153356.GW1299@localhost> References: <20120822164106.GE4301@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120822164106.GE4301@localhost> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: Linux SHM inside a jail X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Sep 2012 15:40:44 -0000 On Wed, Aug 22, 2012 at 06:41:06PM +0200, Holger Hans Peter Freyther wrote: > PS: I looked at both GLIBC ntpl/sem_open.c and linux_stats.c. One option > would be to list another directory in /proc/mounts with tmpfs/shmfs and > replicate the check in linux_stats.c for this alternative directory. I went ahead and explored this route and created the following patch. Does anyone have an idea how to make it work with a custom devfs.rule? With the below patch I can use/run the python multiprocess module inside a jail. comments? >From 3eeb57564e0fb6b7234e3db50309fd359701d9dc Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 1 Sep 2012 17:20:42 +0200 Subject: [PATCH] Announce shm on /tmp/shm Make linprocfs announce shm and let statfs return the shmfs magic for this directory. This makes it easy to use shmfs inside a jail. --- sys/compat/linprocfs/linprocfs.c | 4 ++++ sys/compat/linux/linux_stats.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 3adbe96..9a2f97e 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -390,6 +390,10 @@ linprocfs_domtab(PFS_FILL_ARGS) /* a real Linux mtab will also show NFS options */ sbuf_printf(sb, " 0 0\n"); } + + /* Add a mountpoint for shm inside jails */ + sbuf_printf(sb, "tmpfs /tmp/shm tmpfs rw,nosuid,nodev,relatime 0 0\n"); + mtx_unlock(&mountlist_mtx); if (flep != NULL) free(flep, M_TEMP); diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 2e05c85..7411570 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -409,9 +409,11 @@ linux_statfs(struct thread *td, struct linux_statfs_args *args) #endif dev_shm = 0; error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs); - if (strncmp(path, "/dev/shm", sizeof("/dev/shm") - 1) == 0) + if (strncmp(path, "/dev/shm", sizeof("/dev/shm") - 1) == 0 || + strncmp(path, "/tmp/shm", sizeof("/tmp/shm") - 1) == 0) dev_shm = (path[8] == '\0' || (path[8] == '/' && path[9] == '\0')); + LFREEPATH(path); if (error) return (error); -- 1.7.11.5