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 <hol...@freyther.de>
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

_______________________________________________
freebsd-emulation@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-emulation
To unsubscribe, send any mail to "freebsd-emulation-unsubscr...@freebsd.org"

Reply via email to