[vlc-devel] [PATCH] Udev SD: Try to find out the mount point for blu-ray discs.
Konstantin Pavlov
thresh at videolan.org
Thu Feb 16 21:49:49 CET 2012
On Thu, Feb 16, 2012 at 10:03:13AM +0100, Rémi Denis-Courmont wrote:
> On Thu, 16 Feb 2012 12:57:31 +0400, Konstantin Pavlov
> <thresh at videolan.org>
> wrote:
> > You're right. I moved the check to bluray access, see attached patch.
>
> That should work, I suppose.
>
> Why do you need to check that the path is a block device?
Blu-Ray access requires the disc to be mounted, so it's possible that
access module gets bluray:///media/DISC_NAME/ as input and I don't want to
parse /proc/mounts to check the catalogue...
Attached patch fixes comments about non-sys/stat.h-enabled systems as
suggested on IRC.
--
Konstantin Pavlov
VideoLAN team
-------------- next part --------------
>From 846a67b136aff7593e12849ca4219a0056445f5d Mon Sep 17 00:00:00 2001
From: Konstantin Pavlov <thresh at videolan.org>
Date: Wed, 15 Feb 2012 16:30:38 +0400
Subject: [PATCH] Bluray: try to find mount point if block device file is
passed.
---
configure.ac | 2 +-
modules/access/bluray.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4aaf07a..0f0a88a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -730,7 +730,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...
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 7bfc3f0..2f9ef6f 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -26,6 +26,10 @@
#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);
--
1.7.8.4
More information about the vlc-devel
mailing list