[hfs-user] HFS utils and large volumes

James Pearson jcpearso@ps.ucl.ac.uk
Wed, 02 Oct 2002 16:09:45 +0100


In case anyone is interested, here is a small patch to make hfsutils work
with large volumes (over 4Gb).

Under Linux, I also has to compile the code with 

	"-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"

(There is probably a way to do this via 'configure', but I haven't a clue
how to do that ...)

The only strange bit about the the patch is that I had to split the 
"return" line into two lines - which is the only way it would gives
the correct result using gcc v2.96-98 on Linux for large numbers ...

James Pearson

*** hfsutils-3.2.6/libhfs/os/unix.c.dist	Mon Nov  2 22:09:13 1998
--- hfsutils-3.2.6/libhfs/os/unix.c	Wed Oct  2 13:46:29 2002
***************
*** 147,158 ****
    if (offset == (unsigned long) -1)
      result = lseek(fd, 0, SEEK_END);
    else
!     result = lseek(fd, offset << HFS_BLOCKSZ_BITS, SEEK_SET);
  
    if (result == -1)
      ERROR(errno, "error seeking medium");
  
!   return (unsigned long) result >> HFS_BLOCKSZ_BITS;
  
  fail:
    return -1;
--- 147,160 ----
    if (offset == (unsigned long) -1)
      result = lseek(fd, 0, SEEK_END);
    else
!     result = lseek(fd, (off_t)offset << HFS_BLOCKSZ_BITS, SEEK_SET);
  
    if (result == -1)
      ERROR(errno, "error seeking medium");
  
!   result >>= HFS_BLOCKSZ_BITS;
! 
!   return (unsigned long) result;
  
  fail:
    return -1;