Merge branch 'org.openembedded.dev' of git://git.openembedded.net/openembedded into...
[vuplus_openembedded] / packages / libdvdnav / files / dvdnav-fix-read-dvdlabel.patch
1 --- libdvdnav-0.1.10-org/src/vm.c       2004-05-21 21:32:25.000000000 +0200
2 +++ libdvdnav-0.1.10/src/vm/vm.c        2008-04-15 13:25:33.000000000 +0200
3 @@ -43,6 +43,10 @@
4  
5  #include "dvdnav_internal.h"
6  
7 +#if defined(__linux__)
8 +#include <mntent.h>
9 +#endif
10 +
11  #ifdef _MSC_VER
12  #include <io.h>   /* read() */
13  #endif /* _MSC_VER */
14 @@ -131,7 +135,7 @@
15       * all off_t are 64bit.
16       */
17      off_t off;
18 -    int fd, i;
19 +    int fd = 0, i;
20      uint8_t data[DVD_VIDEO_LB_LEN];
21  
22      /* Read DVD name */
23 @@ -141,6 +145,29 @@
24        if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
25          off = read( fd, data, DVD_VIDEO_LB_LEN ); 
26          close(fd);
27 +#if defined(__linux__)
28 +       if (off != ( (off_t) DVD_VIDEO_LB_LEN )) {
29 +               FILE *mntfile;
30 +               mntfile = fopen( MOUNTED, "r" );
31 +               if ( mntfile ) {
32 +                       struct mntent *me;
33 +                       while( ( me = getmntent( mntfile ) ) ) {
34 +                               if( strstr( device, me->mnt_dir ) ) {
35 +                                       fprintf( stderr, "libdvdnav: Attempting to read dvd label from device %s mounted on %s \n", me->mnt_fsname, me->mnt_dir );
36 +                                       fd = open(me->mnt_fsname, O_RDONLY);
37 +                               }
38 +                       }
39 +                       fclose( mntfile );
40 +               }
41 +               if (fd > 0) {
42 +                       off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
43 +                       if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
44 +                               off = read( fd, data, DVD_VIDEO_LB_LEN );
45 +                               close(fd);
46 +                       }
47 +               }
48 +       }
49 +#endif
50          if (off == ( (off_t) DVD_VIDEO_LB_LEN )) {
51            fprintf(MSG_OUT, "libdvdnav: DVD Title: ");
52            for(i=25; i < 73; i++ ) {