Browse Source

nptl: Allow sem_open to work on MMU-less systems

Allow both tmpfs and ramfs for shm devices.

	* libpthread/nptl/linux_fsinfo.h (SHMFS_SUPER_MAGIC_WITH_MMU): Define.
	(SHMFS_SUPER_MAGIC_WITHOUT_MMU): Define.
	* libpthread/nptl/sem_open.c (__where_is_shmfs): Add support for
	SHMFS_SUPER_MAGIC_WITHOUT_MMU.

Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Christophe Lyon 5 years ago
parent
commit
a20c0b71dc
2 changed files with 10 additions and 3 deletions
  1. 4 1
      libpthread/nptl/linux_fsinfo.h
  2. 6 2
      libpthread/nptl/sem_open.c

+ 4 - 1
libpthread/nptl/linux_fsinfo.h

@@ -126,7 +126,10 @@
 #define XENIX_SUPER_MAGIC	0x012ff7b4
 #define XENIX_SUPER_MAGIC	0x012ff7b4
 
 
 /* Constant that identifies the `shm' filesystem.  */
 /* Constant that identifies the `shm' filesystem.  */
-#define SHMFS_SUPER_MAGIC	0x01021994
+/* Mount as tmpfs.  */
+#define SHMFS_SUPER_MAGIC_WITH_MMU      0x01021994
+/* The kernel uses a ramfs file system for tmpfs.  */
+#define SHMFS_SUPER_MAGIC_WITHOUT_MMU   0x858458f6
 
 
 /* Constants that identify the `xfs' filesystem.  */
 /* Constants that identify the `xfs' filesystem.  */
 #define XFS_SUPER_MAGIC		0x58465342
 #define XFS_SUPER_MAGIC		0x58465342

+ 6 - 2
libpthread/nptl/sem_open.c

@@ -72,7 +72,9 @@ __where_is_shmfs (void)
 
 
   /* The canonical place is /dev/shm.  This is at least what the
   /* The canonical place is /dev/shm.  This is at least what the
      documentation tells everybody to do.  */
      documentation tells everybody to do.  */
-  if (__statfs (defaultmount, &f) == 0 && f.f_type == SHMFS_SUPER_MAGIC)
+  if (__statfs (defaultmount, &f) == 0
+      && (f.f_type == SHMFS_SUPER_MAGIC_WITH_MMU
+	  || f.f_type == SHMFS_SUPER_MAGIC_WITHOUT_MMU))
     {
     {
       /* It is in the normal place.  */
       /* It is in the normal place.  */
       mountpoint.dir = (char *) defaultdir;
       mountpoint.dir = (char *) defaultdir;
@@ -106,7 +108,9 @@ __where_is_shmfs (void)
 	/* First make sure this really is the correct entry.  At least
 	/* First make sure this really is the correct entry.  At least
 	   some versions of the kernel give wrong information because
 	   some versions of the kernel give wrong information because
 	   of the implicit mount of the shmfs for SysV IPC.  */
 	   of the implicit mount of the shmfs for SysV IPC.  */
-	if (__statfs (mp->mnt_dir, &f) != 0 || f.f_type != SHMFS_SUPER_MAGIC)
+	if (__statfs (mp->mnt_dir, &f) != 0
+	    || (f.f_type != SHMFS_SUPER_MAGIC_WITH_MMU
+		&& f.f_type != SHMFS_SUPER_MAGIC_WITHOUT_MMU))
 	  continue;
 	  continue;
 
 
 	namelen = strlen (mp->mnt_dir);
 	namelen = strlen (mp->mnt_dir);