1
0
Эх сурвалжийг харах

Added sys/mnttab.h CD-ROM detection. Fixes missing CD-ROM support on Solaris.

Ryan C. Gordon 17 жил өмнө
parent
commit
0bc32891ba
2 өөрчлөгдсөн 40 нэмэгдсэн , 0 устгасан
  1. 14 0
      CMakeLists.txt
  2. 26 0
      src/platform_unix.c

+ 14 - 0
CMakeLists.txt

@@ -169,6 +169,20 @@ IF(UNIX)
             SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
         ENDIF(HAVE_MNTENT_H)
 
+        # !!! FIXME: Solaris fails this, because mnttab.h implicitly
+        # !!! FIXME:  depends on other system headers.  :(
+        #CHECK_INCLUDE_FILE(sys/mnttab.h HAVE_SYS_MNTTAB_H)
+        CHECK_C_SOURCE_COMPILES("
+            #include <stdio.h>
+            #include <sys/mnttab.h>
+            int main(int argc, char **argv) { return 0; }
+        " HAVE_SYS_MNTTAB_H)
+
+        IF(HAVE_SYS_MNTTAB_H)
+            ADD_DEFINITIONS(-DPHYSFS_HAVE_SYS_MNTTAB_H=1)
+            SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
+        ENDIF(HAVE_SYS_MNTTAB_H)
+
         CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
         IF(HAVE_PTHREAD_H)
             SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)

+ 26 - 0
src/platform_unix.c

@@ -40,6 +40,10 @@
 #include <mntent.h>
 #endif
 
+#ifdef PHYSFS_HAVE_SYS_MNTTAB_H
+#include <sys/mnttab.h>
+#endif
+
 #include "physfs_internal.h"
 
 
@@ -101,6 +105,28 @@ void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
     } /* while */
 
     endmntent(mounts);
+
+#elif (defined PHYSFS_HAVE_SYS_MNTTAB_H)
+    FILE *mounts = fopen(MNTTAB, "r");
+    struct mnttab ent;
+
+    BAIL_IF_MACRO(mounts == NULL, ERR_IO_ERROR, /*return void*/);
+    while (getmntent(mounts, &ent) == 0)
+    {
+        int add_it = 0;
+        if (strcmp(ent.mnt_fstype, "hsfs") == 0)
+            add_it = 1;
+
+        /* add other mount types here */
+
+        if (add_it)
+            cb(data, ent.mnt_mountp);
+    } /* while */
+
+    fclose(mounts);
+
+#else
+#error Unknown platform. Should have defined PHYSFS_NO_CDROM_SUPPORT, perhaps.
 #endif
 } /* __PHYSFS_platformDetectAvailableCDs */