]> git.sesse.net Git - vlc/commitdiff
Bluray: try to find mount point if block device file is passed.
authorKonstantin Pavlov <thresh@videolan.org>
Wed, 15 Feb 2012 12:30:38 +0000 (16:30 +0400)
committerKonstantin Pavlov <thresh@videolan.org>
Fri, 17 Feb 2012 10:59:53 +0000 (14:59 +0400)
configure.ac
modules/access/bluray.c

index 50fdee0b4b546cf140e1715490bea69c7fc6648b..1c8223a4510144f3473928bc5eda6b08d4daf5a7 100644 (file)
@@ -707,7 +707,7 @@ AC_CHECK_HEADERS([sys/mount.h], [], [],
 if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
   AC_CHECK_HEADERS(machine/param.h sys/shm.h)
   AC_CHECK_HEADERS([linux/version.h linux/dccp.h scsi/scsi.h linux/magic.h])
-  AC_CHECK_HEADERS(syslog.h)
+  AC_CHECK_HEADERS(syslog.h mntent.h)
 fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
 
 dnl LP64 and LLP64 architectures had better define ssize_t by themselves...
index 7bfc3f0e09d9cd03e5125a56e6b6b24ea1f7737b..2f9ef6f18e20ab7f26c33f0acbaa86c1903fb0b8 100644 (file)
 
 #include <assert.h>
 #include <limits.h>                         /* PATH_MAX */
+#if defined (HAVE_MNTENT_H) && defined(HAVE_SYS_STAT_H)
+#include <mntent.h>
+#include <sys/stat.h>
+#endif
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -122,6 +126,26 @@ static int blurayOpen( vlc_object_t *object )
         bd_path[PATH_MAX - 1] = '\0';
     }
 
+#if defined (HAVE_MNTENT_H) && defined (HAVE_SYS_STAT_H)
+    /* If we're passed a block device, try to convert it to the mount point. */
+    struct stat st;
+    if ( !stat (bd_path, &st)) {
+        if (S_ISBLK (st.st_mode)) {
+            FILE* mtab = setmntent ("/proc/self/mounts", "r");
+            struct mntent* m;
+            struct mntent mbuf;
+            char buf [8192];
+            while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf))) != NULL) {
+                if (!strcmp (m->mnt_fsname, bd_path)) {
+                    strncpy (bd_path, m->mnt_dir, sizeof(bd_path));
+                    bd_path[sizeof(bd_path) - 1] = '\0';
+                    break;
+                }
+            }
+            endmntent (mtab);
+        }
+    }
+#endif /* HAVE_MNTENT_H && HAVE_SYS_STAT_H */
     p_sys->bluray = bd_open(bd_path, NULL);
     if (!p_sys->bluray) {
         free(p_sys);