aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2019-11-06 20:53:33 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2019-11-06 20:53:33 +0000
commit044ab55e41712a07fcec3e803eda03cf9cb36c60 (patch)
tree00b17582c8598947022c48010e25dccb906b9fa0 /sys/compat
parentfcb71d3f8e6290b37dfc9404409c8a9174663565 (diff)
downloadsrc-044ab55e41712a07fcec3e803eda03cf9cb36c60.tar.gz
src-044ab55e41712a07fcec3e803eda03cf9cb36c60.zip
Make linux(4) create /dev/shm. Linux applications often expect
a tmpfs to be mounted there, and because they like to verify it's actually a mountpoint, a symlink won't do. Reviewed by: dchagin (earlier version) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20333
Notes
Notes: svn path=/head/; revision=354413
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux.c27
-rw-r--r--sys/compat/linux/linux.h3
-rw-r--r--sys/compat/linux/linux_common.c2
3 files changed, 32 insertions, 0 deletions
diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c
index fa1e8f315f9e..621efaf3a4ab 100644
--- a/sys/compat/linux/linux.c
+++ b/sys/compat/linux/linux.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/conf.h>
#include <sys/ctype.h>
#include <sys/jail.h>
#include <sys/lock.h>
@@ -129,6 +130,12 @@ static int linux_to_bsd_sigtbl[LINUX_SIGTBLSZ] = {
SIGSYS /* LINUX_SIGSYS */
};
+static struct cdev *dev_shm_cdev;
+static struct cdevsw dev_shm_cdevsw = {
+ .d_version = D_VERSION,
+ .d_name = "dev_shm",
+};
+
/*
* Map Linux RT signals to the FreeBSD RT signals.
*/
@@ -524,3 +531,23 @@ out:
free(kosa, M_SONAME);
return (error);
}
+
+void
+linux_dev_shm_create(void)
+{
+ int error;
+
+ error = make_dev_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &dev_shm_cdev,
+ &dev_shm_cdevsw, NULL, UID_ROOT, GID_WHEEL, 0, "shm/.mountpoint");
+ if (error != 0) {
+ printf("%s: failed to create device node, error %d\n",
+ __func__, error);
+ }
+}
+
+void
+linux_dev_shm_destroy(void)
+{
+
+ destroy_dev(dev_shm_cdev);
+}
diff --git a/sys/compat/linux/linux.h b/sys/compat/linux/linux.h
index 2959c1dfe320..00650d075837 100644
--- a/sys/compat/linux/linux.h
+++ b/sys/compat/linux/linux.h
@@ -143,4 +143,7 @@ int bsd_to_linux_signal(int sig);
extern LIST_HEAD(futex_list, futex) futex_list;
extern struct mtx futex_mtx;
+void linux_dev_shm_create(void);
+void linux_dev_shm_destroy(void);
+
#endif /* _LINUX_MI_H_ */
diff --git a/sys/compat/linux/linux_common.c b/sys/compat/linux/linux_common.c
index 2bb11c279761..a6c780bd5e10 100644
--- a/sys/compat/linux/linux_common.c
+++ b/sys/compat/linux/linux_common.c
@@ -68,6 +68,7 @@ linux_common_modevent(module_t mod, int type, void *data)
switch(type) {
case MOD_LOAD:
+ linux_dev_shm_create();
linux_osd_jail_register();
linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
linux_proc_exit, NULL, 1000);
@@ -81,6 +82,7 @@ linux_common_modevent(module_t mod, int type, void *data)
mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
break;
case MOD_UNLOAD:
+ linux_dev_shm_destroy();
linux_osd_jail_deregister();
SET_FOREACH(ldhp, linux_device_handler_set)
linux_device_unregister_handler(*ldhp);