[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 09:57:31 CET 2012
On Wed, Feb 15, 2012 at 06:09:41PM +0100, Rémi Denis-Courmont wrote:
> On Wed, 15 Feb 2012 20:18:40 +0400, Konstantin Pavlov
> <thresh at videolan.org>
> wrote:
> > On Wed, Feb 15, 2012 at 04:39:02PM +0100, Rémi Denis-Courmont wrote:
> >> >> > + while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf)))
> !=
> >> >> NULL)
> >> >> > + {
> >> >> > + if( !strcmp (m->mnt_fsname, val)) val = m->mnt_dir;
> >> >> > + }
> >> >> > + endmntent (mtab);
> >> >> > + }
> >> >> > +
> >> >> > return make_URI (val, scheme);
> >> >>
> >> >> This looks like use-after-release to me.
> >> >
> >> > Uhm, why?
> >>
> >> val = m->mnt_dir... I don't suppose the storage for that is still
> valid.
> >
> > The attached patch doesnt re-use val.
>
> We already went through this. It will fail if the disc is inserted _after_
> the SD plugin starts. By the time udev fires the disc event, the file
> system is obviously not mounted.
You're right. I moved the check to bluray access, see attached patch.
--
Konstantin Pavlov
VideoLAN team
-------------- next part --------------
>From e374130fc2a3caf273d0e31453d59817237e3769 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.
---
modules/access/bluray.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 7bfc3f0..9b5660c 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -26,6 +26,10 @@
#include <assert.h>
#include <limits.h> /* PATH_MAX */
+#ifdef 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';
}
+#ifdef 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_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