Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 46342 - New ebuild: hfsplus-tools
Summary: New ebuild: hfsplus-tools
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: PPC Linux
: High major (vote)
Assignee: PPC Porters
Depends on:
Blocks: 61152
  Show dependency tree
Reported: 2004-03-31 03:14 UTC by Simon Strandman
Modified: 2009-10-02 19:32 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---

Ebuild for mkfs.hfsplus, mkfs.hfs, fsck.hfsplus and fsck.hfs (diskdev_cmds-208.11.ebuild,886 bytes, text/plain)
2004-10-21 19:31 UTC, Joe Jezak (RETIRED)
hfsplus-tools based on the previous patchset (hfsplus-tools-208.11.ebuild,890 bytes, text/plain)
2005-03-06 08:04 UTC, Joe Jezak (RETIRED)
hfsplus-tools based on the latest from Apple (hfsplus-tools-277.2.ebuild,893 bytes, text/plain)
2005-03-06 08:05 UTC, Joe Jezak (RETIRED)
hfsplus-tools based on the latest from Apple - Stupid typo in last ebuild (hfsplus-tools-277.2.ebuild,891 bytes, text/plain)
2005-03-06 08:09 UTC, Joe Jezak (RETIRED)
hfs-tools-332.ebuild (hfsplus-tools-332.ebuild,918 bytes, text/plain)
2005-11-12 07:09 UTC, Florian E
Ebuild for hfs-tools from Apple's Mac OS 10.4.4 (hfs-tools-332.11.1.ebuild,1.42 KB, text/plain)
2006-01-15 12:39 UTC, charles bobo
hfs-tools-332.14.ebuild (hfs-tools-332.14.ebuild,1.44 KB, text/plain)
2006-06-19 09:53 UTC, cilly

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Strandman 2004-03-31 03:14:28 UTC
Every time i boot i get the message that my hfs+ disks where not cleanly unmounted and that i schould run fsck to correct it, and therefore they are only mounted read-only.

But when i try tu run hpfsck i get this error:

bash-2.05b# hpfsck /dev/hda2
*** Checking Volume Header:
Volume was not cleanly unmounted
Volume is inconsistent
Reserved attribute in use: 2000

Invalid total blocks 182B32, expected 0                                        Done ***
*** Checking Backup Volume Header:
Unexpected Volume signature '  ' expected 'H+'
hpfsck: hpfsck: This is not a HFS+ volume (Unknown error 4294967295)

I have tried to run fsck from darwin but linux still thinks that they where not cleanly unmounted.

Reproducible: Always
Steps to Reproduce:
1.Install gentoo on a ppc with a hfs+ partition
2.Try to check the hfs+ partition for errors with hpfsck

bash-2.05b$ emerge info
Portage 2.0.50-r1 (default-ppc-2004.0, gcc-3.3.3, glibc-2.3.2-r9, 2.6.3-benh2)
System uname: 2.6.3-benh2 ppc 750FX
Gentoo Base System version
Autoconf: sys-devel/autoconf-2.58-r1
Automake: sys-devel/automake-1.7.8
CFLAGS="-O3 -pipe -mcpu=750 -mtune=750 -mpowerpc-gfxopt -fsigned-char
-falign-functions=4 -fomit-frame-pointer -fforce-addr -frerun-loop-opt
-fprefetch-loop-arrays -funroll-loops"
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config
/usr/kde/3/share/config /usr/share/config /var/lib/pbbuttons /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-O3 -pipe -mcpu=750 -mtune=750 -mpowerpc-gfxopt -fsigned-char
-falign-functions=4 -fomit-frame-pointer -fforce-addr -frerun-loop-opt
-fprefetch-loop-arrays -funroll-loops"
USE="X aalib apm berkdb cdr dga directfb dvd esd fbcon foomaticdb gdbm gif gnome
gnome-libs gphoto2 gpm gtk gtk2 imlib jpeg libwww linguas_sv mad mikmod mitshm
mng mostif motif mozilla mpeg ncurses nls nptl offensive oggvorbis opengl oss
pam pcmcia perl png pnp ppc python quicktime readline samba sdl slang ssl tcltk
tcpd tiff truetype unicode usb video_cards_radeon xine xml2 xv xvid"

bash-2.05b$ uname -a
Linux Stardust 2.6.3-benh2 #2 Wed Mar 31 10:35:34 CEST 2004 ppc 750FX
PowerBook4,3 GNU/Linux
Comment 1 groepaz 2004-10-07 23:27:01 UTC
there is a workaround ... use hpmount to mount the hfs+ partition. it will result in a simelar error-message BUT hpmount will reset the partition-dirty bit. hpumount immediatly. now you should be able to mount the partition r/w normally. however i have also seen warnings about using hpfsck somewhere else, you probably shouldnt use it. (and resort to the non existing fsck.hfsplus :=P)
Comment 2 Pieter Van den Abeele (RETIRED) gentoo-dev 2004-10-21 12:56:45 UTC
We'd probably need an ebuild for:

If I'm not mistaken this provides the much requested fsck.hfsplus
Comment 3 Simon Strandman 2004-10-21 13:32:17 UTC
I have sold my iBook now so I can't test this. But thanks anyway!
Comment 4 Joe Jezak (RETIRED) gentoo-dev 2004-10-21 16:37:48 UTC
Actually, the above is just the hfs+ driver included with the kernel.  To make/fsck an hfsplus fs you need apple's tools.

Get diskdev_cmds-208.11 from the link below:

Now patch it with this patch:

And finally, build with:
make -f makefile.lnx

This should build mkfs and fsck for hfs/hfs+

I don't think later version have been ported, and I'm not sure if we can make an ebuild out of this.
Comment 5 Joe Jezak (RETIRED) gentoo-dev 2004-10-21 19:31:03 UTC
Created attachment 42387 [details]
Ebuild for mkfs.hfsplus, mkfs.hfs, fsck.hfsplus and fsck.hfs

This ebuild will build the OSX 10.2.5 version of these utilities.  Note that
they do not seem to support journaled fs, if I have time, I'll look into
porting the newer verisons, but there are heaps of patches to go through.
Comment 6 Lars Weiler (RETIRED) gentoo-dev 2005-01-09 01:17:47 UTC
JoseJX, can you keep an eye on this package, so that it finds it's way into portage?
Comment 7 Pieter Van den Abeele (RETIRED) gentoo-dev 2005-02-08 21:55:35 UTC
This will not be in the 2005.0 livecd.
Comment 8 Joe Jezak (RETIRED) gentoo-dev 2005-03-05 19:39:49 UTC
Now that I'm back for a bit, I'll try and clean up the ebuild and look at porting one of the newer versions.  I'm not sure if we want to put this one in portage, but if I don't have anything soon, I think I will.  Should we rename the package something more obvious like hfsplus-tools or something like that?
Comment 9 Joe Jezak (RETIRED) gentoo-dev 2005-03-06 08:04:01 UTC
Created attachment 52786 [details]
hfsplus-tools based on the previous patchset

This *may* work on little endian machines as well, but I'm not sure.
Comment 10 Joe Jezak (RETIRED) gentoo-dev 2005-03-06 08:05:37 UTC
Created attachment 52787 [details]
hfsplus-tools based on the latest from Apple

I'm pretty sure this won't work yet on little endian machines and I've only
tested some rudimentary things on linux at the moment, so don't use it if you
value your data.
Comment 11 Joe Jezak (RETIRED) gentoo-dev 2005-03-06 08:09:37 UTC
Created attachment 52788 [details]
hfsplus-tools based on the latest from Apple - Stupid typo in last ebuild
Comment 12 Joe Jezak (RETIRED) gentoo-dev 2005-03-08 21:44:01 UTC
It looks like I missed something in porting 277.2, I'll have to try reworking that again.  208.11 is probably okay for inclusion in portage, it just doesn't support some of the new HFS+ features (like case sensitivity).
Comment 13 Markus Rothe (RETIRED) gentoo-dev 2005-05-06 06:27:16 UTC
just a comment: diskdev_cmds-332 is out...
Comment 14 Ortwin Glueck 2005-08-13 09:26:42 UTC
People that have an iPOD want to use this under x86 as well. Does the patch
address any endianness issues?
Comment 15 Joe Jezak (RETIRED) gentoo-dev 2005-11-04 01:58:31 UTC
I've ported 332, the patch can be found at

Consider it a first draft, it's missing a little bit of error checking, but the
important bits seem fine.  I've tested it on ppc32, both fsck_hfs and newfs_hfs,
on both actual disk partitions and disk images.  I'd appreciate testing on x86
and ppc64, but it should be fine.
Comment 16 Florian E 2005-11-12 07:09:46 UTC
Created attachment 72749 [details]

some filenames for the src-files changed in the newest version ported by
JoseJX, so the old ebuild didn't work.
Comment 17 Joe Jezak (RETIRED) gentoo-dev 2005-11-19 00:06:41 UTC
I've updated the patch again to make it work on OSX again to address Kito's
concerns with conditional patching.  Please test again and let me know if this
version works.  If anyone knows of a simple way to test if a disk is mounted,
that would be useful too. :)
Comment 18 Ortwin Glueck 2005-11-26 07:05:54 UTC
doesn't compile on x86:

gcc -g3 -Wall -I/var/tmp/portage/hfsplus-tools-332/work/diskdev_cmds-332/include
-DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64   -c -o newfs_hfs.o newfs_hfs.c
makehfs.c: In function `WriteExtentsFile':
makehfs.c:816: warning: implicit declaration of function `NXSwapBigShortToHost'
makehfs.c:830: warning: implicit declaration of function `NXSwapBigLongToHost'
makehfs.c: In function `WriteJournalInfo':
makehfs.c:959: warning: implicit declaration of function `NXSwapBigLongLongToHost'
gcc -g3 -Wall -I/var/tmp/portage/hfsplus-tools-332/work/diskdev_cmds-332/include
-DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64 -o newfs_hfs makehfs.o newfs_hfs.o -lssl
makehfs.o: In function `WriteMDB':
undefined reference to `hfs_swap_HFSMasterDirectoryBlock'
makehfs.o: In function `WriteVH':
undefined reference to `hfs_swap_HFSPlusVolumeHeader'
makehfs.o: In function `WriteExtentsFile':
undefined reference to `NXSwapBigShortToHost'
... (hundreds of complaints about undefined references) ...
undefined reference to `NXSwapBigShortToHost'
collect2: ld returned 1 exit status
make[1]: *** [newfs_hfs] Error 1
make[1]: Leaving directory
Comment 19 Florian E 2005-11-28 16:52:50 UTC
while patching anyway, what about a linux style option for testing to make it (gentoo-linux-)init-
compatible? ;)
I get errors at every boot about wrong options and init interprets the exitcode as "Some Filesystem 
errors were corrected" or something like this
Comment 20 Joe Jezak (RETIRED) gentoo-dev 2006-01-04 13:45:47 UTC
Here's a new patch against the latest version (332.11) which fixes the issues with x86:

Perhaps a simple wrapper script would be adequate to fix the fsck on boot issues?   I'll see what I can come up with.
Comment 21 charles bobo 2006-01-15 12:39:46 UTC
Created attachment 77185 [details]
Ebuild for hfs-tools from Apple's Mac OS 10.4.4

hfs-tools-332.11.1.ebuild uses same patch as hfs-tools-332.11.ebuild,
Comment 22 charles bobo 2006-01-15 12:41:21 UTC
hfs-tools-332.11.1 will build on x86 in addition to ppc.
Comment 23 Ortwin Glueck 2006-02-27 13:01:16 UTC
Joe, would you mind to symlink diskdev_cmds-332.11.1.patch.bz2 to ? (mind the extra ".1") Because the latest ebuild expects this location filename and thus doesn't currently build.
Comment 24 Ortwin Glueck 2006-02-28 14:12:48 UTC
Even with 332.11.1 I can not repair my iPod. It claims that the partition is mounted, but it actually isn't. The iPod is connected by IEEE-1394 and managed by the sbp-2 driver.

gimli ~ # fsck -f /dev/sda3
fsck 1.38 (30-Jun-2005)
** /dev/sda3
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
   Incorrect number of thread records
(4, 3)
** Checking multi-linked files.
** Checking Catalog hierarchy.
   Invalid directory item count
   (It should be 10 instead of 11)
** Checking volume bitmap.
   Volume Bit Map needs minor repair
** Checking volume information.
   Invalid volume free block count
   (It should be 1429726 instead of 1429829)
** Cannot repair volume when it is mounted with write access.
** The volume My iPod could not be repaired.
Comment 25 Joe Jezak (RETIRED) gentoo-dev 2006-03-13 22:49:35 UTC
Sorry, that was a stupid mistake in the patch, the mount issue should be fixed now, I updated the patch for 322.11.  I'm cleaning up a few more things and hope to get this in portage soon.
Comment 26 Brian Tarricone 2006-03-15 12:21:08 UTC
(In reply to comment #25)
> Sorry, that was a stupid mistake in the patch, the mount issue should be fixed
> now, I updated the patch for 322.11.  I'm cleaning up a few more things and
> hope to get this in portage soon.

You sure about that?  I downloaded yesterday, and it won't repair *any* volume, whether it's unmounted, or mounted read-only, claiming it's mounted read-write.

This is using 322.11.1 with your 322.11 patch applied against it.

Also of issue: fsck.hfsplus doesn't accept the -a option, and so it doesn't work with Gentoo's quick check on system boot.  I patched my local copy to interpret -a as -y, but I'm not sure that that's the safe/appropriate way to go (it also takes quite a while to run compared to fsck.ext3).
Comment 27 Chris White (RETIRED) gentoo-dev 2006-04-04 22:40:30 UTC
This bug looks somewhat old.. forgotten?
Comment 28 Joe Jezak (RETIRED) gentoo-dev 2006-04-04 23:51:38 UTC
It is old, but my last activity on the bug was a month ago. :p  I've just gotten my new powerbook, so I'll have a look at the hfs+ utils when I get back from LWE.
Comment 29 cilly 2006-06-19 09:53:38 UTC
Created attachment 89543 [details]

This is an ebuild which uses the updated version of hfs-tools available on:

Instead of ppc-sources the x86 sources are used.

This is a port from the recently released x86 Darwin kernel OS X 10.4.[5-6] / Darwin 8.[5-6](x86).

See here for further info about the different patches:
Comment 30 Tyler McGee 2006-06-19 16:07:39 UTC
(In reply to comment #29) Cilly, just thought should comment on your ebuild.

I posted those newer patches in my udel directory in which SRC_URL points. Josex is the developer of the patches, I simply updated the patches for the latest darwin kernel. I have emailed josex about them, and he repled would be adding them to his directory at gentoo at some point. 

Although I have no problem hosting the files for an ebuild; I would recommend that we keep the SRC_URI pointing to josex's directory, since he has indicated that he is still developing new patches.
Comment 31 Philip Derrin 2006-07-15 07:57:48 UTC
(In reply to comment #26)
> Also of issue: fsck.hfsplus doesn't accept the -a option, and so it doesn't
> work with Gentoo's quick check on system boot.  I patched my local copy to
> interpret -a as -y, but I'm not sure that that's the safe/appropriate way to go
> (it also takes quite a while to run compared to fsck.ext3).

It should interpret -a as -p, like e2fsck does. mac os x runs fsck -p at boot time.
Comment 32 Tyler McGee 2006-08-11 08:49:44 UTC
(In reply to comment #31)
> It should interpret -a as -p, like e2fsck does. mac os x runs fsck -p at boot
> time.
Patched hfs-tools for boot check compatibility.
Comment 33 Ryan Olf 2006-09-14 23:08:05 UTC
All of the versions of fsck.hfsplus available here segfault when trying to check a partition on my iPod.  The output does not get beyond 

** /dev/sdb3
** Checking HFS Plus volume.
Segmentation fault

even with -d flag.  The partition was formatted originally with mkfs.hfsplus on this same Gentoo system (gentoo-sources 2.6.17-r7).  The error occurs with the partition both mounted and unmounted.  dmesg claims the filesystem was not cleanly unmounted, and Gentoo will only mount it read-only.
Comment 34 Ryan Olf 2006-09-14 23:11:00 UTC
(In reply to comment #33)
By the way (doh), this is an AMD64 system with CHOST="x86_64-pc-linux-gnu".  Is there something special one needs to do to compile this on a 64 bit system?
Comment 35 Joe Jezak (RETIRED) gentoo-dev 2006-11-12 20:23:09 UTC
I've added this to portage as diskdev_cmds (the Apple name for it).  As for AMD64 support, I don't have a machine to test it on, you'll have to figure out why it's crashing (probably not 64 bit safe) and fix it.  Sorry. :(

If there are any issues with this, please file new bugs.

Comment 36 Todd Partridge 2008-03-26 22:07:54 UTC
Someone has found a way to get diskdev commands to work for AMD64 support haven't tested it though.
Comment 37 hirakendu 2009-10-01 21:19:20 UTC
Thanks a lot for the suggestion to diskdev_cmds. Works fine here.

I had a crash while running fsck.hfsplus (I am on amd64) on a hfsplus partition corrupted by running hfsck (I shouldn't have done that), but I have not been able to reproduce it. On my machine, I had a extended hfs volume (basically hfsplus) which was created on Mac OS X 10.5. Before I knew of diskdev_cmds, since I didn't have fsck.hfsplus, for a try, I used hfsck from sys-fs/hfsutils package in Gentoo. Ideally, it shouldn't have worked, but it corrupted this hfsplus disk eventhough I answered 'n' to the changes hfsck wanted to make. And thereafter, I emerged diskdev_cmds after coming across this thread and when I tried to use fsck.hfsplus on this corrupted volume, fsck segfaulted. I thought it was a (known) problem with diskdev_cmds on amd64, but later on, when I tried on usual hfsplus partitions (not corrupted by hfsck), it seemed to work fine. To reproduce it, I created a hfsplus partition and ran hfsck followed by fsck.hfsplus. Although hfsck still corrupts the disk, this time fsck.hfsplus seems to be able to clean it up! (dd if=/dev/zero of=abc.hfsplus bs=1024 count=50000 ; mkfs.hfsplus abc.hfsplus; hfsck abc.hfsplus; mount abc.hfsplus /mnt/ -o loop; fsck.hfsplus abc.hfsplus; mount abc.hfsplus /mnt/ -o loop;)