[felix at fkurth.de: Re: [Ogle-user] libdvdread: Can't seek to block 256]

H}kan Hjort d95hjort at dtek.chalmers.se
Wed Dec 10 20:53:48 CET 2003


Wed Dec 10 2003, Sam Hocevar wrote:
> On Wed, Dec 10, 2003, H}kan Hjort wrote:
> 
> > There is a problem with the seek call in device.c.  It seems that 
> > it's not supported to do a cast to off_t of an integer (or it's not
> > supported to do multiplication of two off_t) in all cases.  It might
> > simply be a bug in GCC but it would be good if this could be resolved
> > somehow.
> 
>    The code relies on off_t being 64 bits (hence the -D__USE_UNIX98
> -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE flags). Looks like an
> incompatibility between the libc and its headers.
> 
>    I would very much like to know on what distribution it was compiled,
> with what compiler and what libc headers. Also I'd like to know on what
> distribution it was run, with what libc version. A compilation log might
> be useful as well.
> 
Still not sure what causes this but rewriting the code as in the attached
patch seems to have cured the problems.

-- 
Håkan Hjort
-------------- next part --------------
Index: device.c
===================================================================
RCS file: /var/cvs/videolan/libdvdcss/src/device.c,v
retrieving revision 1.18
diff -p -u -d -r1.18 device.c
--- device.c	9 Sep 2003 13:17:24 -0000	1.18
+++ device.c	10 Dec 2003 19:51:02 -0000
@@ -435,9 +435,9 @@ static int libc_seek( dvdcss_t dvdcss, i
         /* We are already in position */
         return i_blocks;
     }
-
-    i_seek = lseek( dvdcss->i_read_fd,
-                    (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE, SEEK_SET );
+    
+    i_seek = (off_t)i_blocks * DVDCSS_BLOCK_SIZE;
+    i_seek = lseek( dvdcss->i_read_fd, i_seek, SEEK_SET );
 
     if( i_seek < 0 )
     {
@@ -518,10 +518,11 @@ static int aspi_seek( dvdcss_t dvdcss, i
  *****************************************************************************/
 static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
 {
+    off_t i_size;
     off_t i_ret;
-
-    i_ret = read( dvdcss->i_read_fd, p_buffer,
-                  (off_t)i_blocks * DVDCSS_BLOCK_SIZE );
+    
+    i_size = (off_t)i_blocks * DVDCSS_BLOCK_SIZE;
+    i_ret = read( dvdcss->i_read_fd, p_buffer, i_size );
 
     if( i_ret < 0 )
     {
@@ -531,7 +532,7 @@ static int libc_read ( dvdcss_t dvdcss, 
     }
 
     /* Handle partial reads */
-    if( i_ret != (off_t)i_blocks * DVDCSS_BLOCK_SIZE )
+    if( i_ret != i_size )
     {
         int i_seek;
 


More information about the libdvdcss-devel mailing list