From owner-svn-src-stable-12@freebsd.org Mon Aug 24 16:06:19 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D94553C5C19; Mon, 24 Aug 2020 16:06:19 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BZxnQ4M7kz3Z8T; Mon, 24 Aug 2020 16:06:18 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 65BDF1AE4E; Mon, 24 Aug 2020 16:06:18 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07OG6IAb061943; Mon, 24 Aug 2020 16:06:18 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07OG6HKO061940; Mon, 24 Aug 2020 16:06:17 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <202008241606.07OG6HKO061940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Mon, 24 Aug 2020 16:06:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r364702 - in stable/12/sys: compat/linux i386/linux X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: in stable/12/sys: compat/linux i386/linux X-SVN-Commit-Revision: 364702 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 16:06:20 -0000 Author: trasz Date: Mon Aug 24 16:06:17 2020 New Revision: 364702 URL: https://svnweb.freebsd.org/changeset/base/364702 Log: MFC r354413: 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. Sponsored by: The FreeBSD Foundation Modified: stable/12/sys/compat/linux/linux.c stable/12/sys/compat/linux/linux.h stable/12/sys/compat/linux/linux_common.c stable/12/sys/i386/linux/linux_sysvec.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linux/linux.c ============================================================================== --- stable/12/sys/compat/linux/linux.c Mon Aug 24 16:06:11 2020 (r364701) +++ stable/12/sys/compat/linux/linux.c Mon Aug 24 16:06:17 2020 (r364702) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -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. */ @@ -523,4 +530,24 @@ linux_to_bsd_sockaddr(const struct l_sockaddr *osa, st 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); } Modified: stable/12/sys/compat/linux/linux.h ============================================================================== --- stable/12/sys/compat/linux/linux.h Mon Aug 24 16:06:11 2020 (r364701) +++ stable/12/sys/compat/linux/linux.h Mon Aug 24 16:06:17 2020 (r364702) @@ -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_ */ Modified: stable/12/sys/compat/linux/linux_common.c ============================================================================== --- stable/12/sys/compat/linux/linux_common.c Mon Aug 24 16:06:11 2020 (r364701) +++ stable/12/sys/compat/linux/linux_common.c Mon Aug 24 16:06:17 2020 (r364702) @@ -68,6 +68,7 @@ linux_common_modevent(module_t mod, int type, void *da 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 *da 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); Modified: stable/12/sys/i386/linux/linux_sysvec.c ============================================================================== --- stable/12/sys/i386/linux/linux_sysvec.c Mon Aug 24 16:06:11 2020 (r364701) +++ stable/12/sys/i386/linux/linux_sysvec.c Mon Aug 24 16:06:17 2020 (r364702) @@ -1057,6 +1057,7 @@ linux_elf_modevent(module_t mod, int type, void *data) linux_get_machine(&linux_kplatform); linux_szplatform = roundup(strlen(linux_kplatform) + 1, sizeof(char *)); + linux_dev_shm_create(); linux_osd_jail_register(); stclohz = (stathz ? stathz : hz); if (bootverbose) @@ -1082,6 +1083,7 @@ linux_elf_modevent(module_t mod, int type, void *data) EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag); EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag); EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag); + linux_dev_shm_destroy(); linux_osd_jail_deregister(); if (bootverbose) printf("Linux ELF exec handler removed\n");