From owner-svn-src-stable@FreeBSD.ORG Tue Mar 15 13:19:27 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BA461065672; Tue, 15 Mar 2011 13:19:27 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E142A8FC13; Tue, 15 Mar 2011 13:19:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2FDJQrF044062; Tue, 15 Mar 2011 13:19:26 GMT (envelope-from netchild@svn.freebsd.org) Received: (from netchild@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2FDJQos044060; Tue, 15 Mar 2011 13:19:26 GMT (envelope-from netchild@svn.freebsd.org) Message-Id: <201103151319.p2FDJQos044060@svn.freebsd.org> From: Alexander Leidinger Date: Tue, 15 Mar 2011 13:19:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219666 - stable/8/sys/compat/linux X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2011 13:19:27 -0000 Author: netchild Date: Tue Mar 15 13:19:26 2011 New Revision: 219666 URL: http://svn.freebsd.org/changeset/base/219666 Log: MFC r218497: Linux' shm_open() fails because it wants to find some funky shmfs to construct the full pathname. It starts to search at the default mountpoint which is /dev/shm. If this fails it runs through fstab and searches for shmfs and tmpfs. Whatever it finds will be statfs()'ed to be checked for Linux' fs magic for shmfs (0x01021994). Ideally our tmpfs should deliver this fs magic to Linux processes, but as our tmpfs is considered to be an experimental feature we can not assume that there is always a tmpfs available. To make shared memory work in the Linuxulator, force the fs type of /dev/shm (which can be a symlink) to match what Linux expects. The user is responsible (info has to be added to the linux base ports and the docs) to setup a suitable link for /dev/shm. Noticed by: Andre Albsmeier Submitted by: Andre Albsmeier Modified: stable/8/sys/compat/linux/linux_stats.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/linux/linux_stats.c ============================================================================== --- stable/8/sys/compat/linux/linux_stats.c Tue Mar 15 12:24:40 2011 (r219665) +++ stable/8/sys/compat/linux/linux_stats.c Tue Mar 15 13:19:26 2011 (r219666) @@ -60,6 +60,8 @@ __FBSDID("$FreeBSD$"); #include +#define LINUX_SHMFS_MAGIC 0x01021994 + static void translate_vnhook_major_minor(struct vnode *vp, struct stat *sb) { @@ -390,7 +392,7 @@ linux_statfs(struct thread *td, struct l struct l_statfs linux_statfs; struct statfs bsd_statfs; char *path; - int error; + int error, dev_shm; LCONVPATHEXIST(td, args->path, &path); @@ -398,11 +400,17 @@ linux_statfs(struct thread *td, struct l if (ldebug(statfs)) printf(ARGS(statfs, "%s, *"), path); #endif + dev_shm = 0; error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs); + if (strncmp(path, "/dev/shm", sizeof("/dev/shm") - 1) == 0) + dev_shm = (path[8] == '\0' + || (path[8] == '/' && path[9] == '\0')); LFREEPATH(path); if (error) return (error); bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); + if (dev_shm) + linux_statfs.f_type = LINUX_SHMFS_MAGIC; return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); }