Package: hfsutils
Version: 3.2.6-11
Severity: normal
Tags: patch

Hi, there is a limitation in libhfs, which prevents it from using
volumes larger than 2 GiB, although HFS volumes can be much bigger
(terabytes, I think) and most bootable DVDs for mac aren't usable with
hfsutils.

Since I'm using the lib for other project, I fixed most of the code to
use correct types and now I think it works OK with volumes up to
2**(32+12) in size. That's because long ints are still used in other
parts of the code, but I wanted to keep my modifications minimal.

The patch also changes a couple of things in config.h and configure.in
(most notable AC_SYS_LARGEFILE), but you should adapt those and re-run
autotools.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (901, 'testing'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-2-686 (SMP w/2 CPU cores)
Locale: LANG=es_AR.UTF-8, LC_CTYPE=es_AR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages hfsutils depends on:
ii  libc6                         2.6-2      GNU C Library: Shared libraries

hfsutils recommends no packages.

-- no debconf information
diff -aur libhfs/block.c ../../cvs/pancutan/hfsbootfiles/block.c
--- libhfs/block.c	2007-08-16 05:30:19.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/block.c	2007-08-14 14:07:33.000000000 +0100
@@ -578,7 +578,8 @@
  */
 int b_readpb(hfsvol *vol, unsigned long bnum, block *bp, unsigned int blen)
 {
-  unsigned long nblocks;
+  off_t sblocks;
+  ssize_t nblocks;
 
 # ifdef DEBUG
   fprintf(stderr, "BLOCK: READ vol 0x%lx block %lu",
@@ -589,15 +590,15 @@
     fprintf(stderr, "\n");
 # endif
 
-  nblocks = os_seek(&vol->priv, bnum);
-  if (nblocks == (unsigned long) -1)
+  sblocks = os_seek(&vol->priv, (off_t)bnum);
+  if (sblocks == (off_t) -1)
     goto fail;
 
-  if (nblocks != bnum)
+  if (sblocks != bnum)
     ERROR(EIO, "block seek failed for read");
 
-  nblocks = os_read(&vol->priv, bp, blen);
-  if (nblocks == (unsigned long) -1)
+  nblocks = os_read(&vol->priv, bp, (ssize_t)blen);
+  if (nblocks == (ssize_t) -1)
     goto fail;
 
   if (nblocks != blen)
@@ -616,7 +617,8 @@
 int b_writepb(hfsvol *vol, unsigned long bnum, const block *bp,
 	      unsigned int blen)
 {
-  unsigned long nblocks;
+  off_t sblocks;
+  ssize_t nblocks;
 
 # ifdef DEBUG
   fprintf(stderr, "BLOCK: WRITE vol 0x%lx block %lu",
@@ -627,15 +629,15 @@
     fprintf(stderr, "\n");
 # endif
 
-  nblocks = os_seek(&vol->priv, bnum);
-  if (nblocks == (unsigned long) -1)
+  nblocks = os_seek(&vol->priv, (off_t)bnum);
+  if (nblocks == (off_t) -1)
     goto fail;
 
   if (nblocks != bnum)
     ERROR(EIO, "block seek failed for write");
 
-  nblocks = os_write(&vol->priv, bp, blen);
-  if (nblocks == (unsigned long) -1)
+  nblocks = os_write(&vol->priv, bp, (ssize_t)blen);
+  if (nblocks == (ssize_t) -1)
     goto fail;
 
   if (nblocks != blen)
Sólo en libhfs/: block.c.orig
diff -aur libhfs/btree.c ../../cvs/pancutan/hfsbootfiles/btree.c
--- libhfs/btree.c	2007-08-16 05:30:20.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/btree.c	2007-08-16 00:43:23.000000000 +0100
@@ -409,7 +409,7 @@
  * DESCRIPTION:	recursively locate a node and insert a record
  */
 static
-int insertx(node *np, byte *record, int *reclen)
+int insertx(node *np, byte *record, unsigned int *reclen)
 {
   node child;
   byte *rec;
diff -aur libhfs/config.h.in ../../cvs/pancutan/hfsbootfiles/config.h.in
--- libhfs/config.h.in	2007-08-16 05:30:21.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/config.h.in	2007-08-16 00:49:52.000000000 +0100
@@ -1,57 +1,70 @@
-/* config.h.in.  Generated automatically from configure.in by autoheader.  */
-/*
- * libhfs - library for reading and writing Macintosh HFS volumes
- * Copyright (C) 1996-1998 Robert Leslie
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: acconfig.h,v 1.5 1998/04/11 08:27:11 rob Exp $
- */
-
-/*****************************************************************************
- * Definitions selected automatically by `configure'                         *
- *****************************************************************************/
+/* config.h.in.  Generated from configure.in by autoheader.  */
 
-/* Define to empty if the keyword does not work.  */
-#undef const
-
-/* Define to `unsigned' if <sys/types.h> doesn't define.  */
-#undef size_t
+/* "Enable diagnostic debugging support" */
+#undef DEBUG
 
-/* Define if you have the ANSI C header files.  */
-#undef STDC_HEADERS
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
 
-/* Define if your <sys/time.h> declares struct tm.  */
-#undef TM_IN_SYS_TIME
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
 
-/* Define if you want to enable diagnostic debugging support. */
-#undef DEBUG
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
 
-/* Define if you have the mktime function.  */
+/* Define to 1 if you have the `mktime' function. */
 #undef HAVE_MKTIME
 
-/* Define if you have the <fcntl.h> header file.  */
-#undef HAVE_FCNTL_H
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
 
-/* Define if you have the <unistd.h> header file.  */
+/* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/*****************************************************************************
- * End of automatically configured definitions                               *
- *****************************************************************************/
-
-# ifdef DEBUG
-#  include <stdio.h>
-# endif
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
diff -aur libhfs/configure.in ../../cvs/pancutan/hfsbootfiles/configure.in
--- libhfs/configure.in	2007-08-16 05:30:21.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/configure.in	2007-08-16 00:48:35.000000000 +0100
@@ -28,7 +28,7 @@
 
 if test "x$enable_debug" = xyes
 then
-    AC_DEFINE(DEBUG)
+    AC_DEFINE(DEBUG, 1, "Enable diagnostic debugging support")
 fi
 
 dnl Checks for programs.
@@ -50,7 +50,7 @@
 
 AC_TYPE_SIZE_T
 AC_STRUCT_TM
-
+AC_SYS_LARGEFILE
 AC_C_CONST
 
 dnl Checks for library functions.
diff -aur libhfs/hfs.h ../../cvs/pancutan/hfsbootfiles/hfs.h
--- libhfs/hfs.h	2007-08-16 05:30:21.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/hfs.h	2007-08-16 00:44:47.000000000 +0100
@@ -20,6 +20,7 @@
  */
 
 # include <time.h>
+# include <sys/types.h>
 
 # define HFS_BLOCKSZ		512
 # define HFS_BLOCKSZ_BITS	9
@@ -35,8 +36,8 @@
   char name[HFS_MAX_VLEN + 1];	/* name of volume (MacOS Standard Roman) */
   int flags;			/* volume flags */
 
-  unsigned long totbytes;	/* total bytes on volume */
-  unsigned long freebytes;	/* free bytes on volume */
+  ssize_t totbytes;		/* total bytes on volume */
+  ssize_t freebytes;		/* free bytes on volume */
 
   unsigned long alblocksz;	/* volume allocation block size */
   unsigned long clumpsz;	/* default file clump size */
diff -aur libhfs/Makefile.in ../../cvs/pancutan/hfsbootfiles/Makefile.in
--- libhfs/Makefile.in	2007-08-16 05:31:59.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/Makefile.in	2007-08-16 00:43:23.000000000 +0100
@@ -27,11 +27,13 @@
 
 prefix =	@prefix@
 exec_prefix =	@exec_prefix@
+datarootdir =	@datarootdir@
 
 MANDEST =	@mandir@
 
 INCDEST =	@includedir@
 LIBDEST =	@libdir@
+BINDEST =	@bindir@
 
 INSTALL =	@INSTALL@
 LIBINSTALL =	@INSTALL_DATA@
diff -aur libhfs/os/unix.c ../../cvs/pancutan/hfsbootfiles/os/unix.c
--- libhfs/os/unix.c	2007-08-16 05:30:23.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/os/unix.c	2007-08-15 00:36:27.000000000 +0100
@@ -137,14 +137,14 @@
  * NAME:	os->seek()
  * DESCRIPTION:	set a descriptor's seek pointer (offset in blocks)
  */
-unsigned long os_seek(void **priv, unsigned long offset)
+off_t os_seek(void **priv, off_t offset)
 {
   int fd = (int) *priv;
   off_t result;
 
   /* offset == -1 special; seek to last block of device */
 
-  if (offset == (unsigned long) -1)
+  if (offset == (off_t) -1)
     result = lseek(fd, 0, SEEK_END);
   else
     result = lseek(fd, offset << HFS_BLOCKSZ_BITS, SEEK_SET);
@@ -152,7 +152,7 @@
   if (result == -1)
     ERROR(errno, "error seeking medium");
 
-  return (unsigned long) result >> HFS_BLOCKSZ_BITS;
+  return (off_t) result >> HFS_BLOCKSZ_BITS;
 
 fail:
   return -1;
@@ -162,7 +162,7 @@
  * NAME:	os->read()
  * DESCRIPTION:	read blocks from an open descriptor
  */
-unsigned long os_read(void **priv, void *buf, unsigned long len)
+ssize_t os_read(void **priv, void *buf, ssize_t len)
 {
   int fd = (int) *priv;
   ssize_t result;
@@ -172,7 +172,7 @@
   if (result == -1)
     ERROR(errno, "error reading from medium");
 
-  return (unsigned long) result >> HFS_BLOCKSZ_BITS;
+  return (ssize_t) result >> HFS_BLOCKSZ_BITS;
 
 fail:
   return -1;
@@ -182,7 +182,7 @@
  * NAME:	os->write()
  * DESCRIPTION:	write blocks to an open descriptor
  */
-unsigned long os_write(void **priv, const void *buf, unsigned long len)
+ssize_t os_write(void **priv, const void *buf, ssize_t len)
 {
   int fd = (int) *priv;
   ssize_t result;
@@ -192,7 +192,7 @@
   if (result == -1)
     ERROR(errno, "error writing to medium");
 
-  return (unsigned long) result >> HFS_BLOCKSZ_BITS;
+  return (ssize_t) result >> HFS_BLOCKSZ_BITS;
 
 fail:
   return -1;
diff -aur libhfs/os.h ../../cvs/pancutan/hfsbootfiles/os.h
--- libhfs/os.h	2007-08-16 05:30:23.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/os.h	2007-08-14 13:32:49.000000000 +0100
@@ -24,6 +24,6 @@
 
 int os_same(void **, const char *);
 
-unsigned long os_seek(void **, unsigned long);
-unsigned long os_read(void **, void *, unsigned long);
-unsigned long os_write(void **, const void *, unsigned long);
+off_t os_seek(void **, off_t);
+ssize_t os_read(void **, void *, ssize_t);
+ssize_t os_write(void **, const void *, ssize_t);
diff -aur libhfs/volume.c ../../cvs/pancutan/hfsbootfiles/volume.c
--- libhfs/volume.c	2007-08-16 05:30:24.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/volume.c	2007-08-16 00:43:23.000000000 +0100
@@ -758,7 +758,7 @@
  * DESCRIPTION:	translate a pathname; return catalog information
  */
 int v_resolve(hfsvol **vol, const char *path,
-	      CatDataRec *data, long *parid, char *fname, node *np)
+	      CatDataRec *data, unsigned long *parid, char *fname, node *np)
 {
   unsigned long dirid;
   char name[HFS_MAX_FLEN + 1], *nptr;
Sólo en libhfs/: volume.c.orig
diff -aur libhfs/volume.h ../../cvs/pancutan/hfsbootfiles/volume.h
--- libhfs/volume.h	2007-08-16 05:30:25.000000000 +0100
+++ ../../cvs/pancutan/hfsbootfiles/volume.h	2007-08-16 00:43:23.000000000 +0100
@@ -54,7 +54,8 @@
 int v_allocblocks(hfsvol *, ExtDescriptor *);
 int v_freeblocks(hfsvol *, const ExtDescriptor *);
 
-int v_resolve(hfsvol **, const char *, CatDataRec *, long *, char *, node *);
+int v_resolve(hfsvol **, const char *, CatDataRec *, unsigned long *, char *,
+		node *);
 
 int v_adjvalence(hfsvol *, unsigned long, int, int);
 int v_mkdir(hfsvol *, unsigned long, const char *);
Sólo en libhfs/: volume.h.orig

Reply via email to