[comp.sys.mac.programmer] HFS Esoterica question

amanda@mermaid.intercon.com (Amanda Walker) (12/15/89)

Here's a question for all you file system hackers.  I've been meditating
upon IM-IV and hex dumps of volume header blocks, and I can't find a
definitive answer to a simple question: is the extents file on an HFS
volume guaranteed to be contiguous?  All the examples I can find are,
and IM-IV seems to imply it, but it doesn't actually say.  There's space
for up to 3 extents in the volume header, but for more than that you'd
have to look in the file itself, which seems uncomfortably recursive :-).

Amanda Walker
InterCon Systems Corporation
--

keith@Apple.COM (Keith Rollin) (12/20/89)

In article <1631@intercon.com> amanda@mermaid.intercon.com (Amanda Walker) writes:
>Here's a question for all you file system hackers.  I've been meditating
>upon IM-IV and hex dumps of volume header blocks, and I can't find a
>definitive answer to a simple question: is the extents file on an HFS
>volume guaranteed to be contiguous?  All the examples I can find are,
>and IM-IV seems to imply it, but it doesn't actually say.  There's space
>for up to 3 extents in the volume header, but for more than that you'd
>have to look in the file itself, which seems uncomfortably recursive :-).
>

Amanda,

The extents file is not guaranteed to be contiguous. It can be split up into
3 extents of its own. Beyond that, I don't know what happens. Some sort of
system failure, I suppose. However, I've never seen more than one extent, and
there is probably some sort of methematical reason why you'll never exceed the
3 set aside for the extents file. I've never seen any that spans more than
even 1 extent.

So the answer is, no, we don't go recurcurcurcurcursive.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

amanda@mermaid.intercon.com (Amanda Walker) (12/21/89)

In article <37421@apple.Apple.COM>, keith@Apple.COM (Keith Rollin) writes:
> The extents file is not guaranteed to be contiguous. It can be split up into
> 3 extents of its own. Beyond that, I don't know what happens. Some sort of
> system failure, I suppose.

How reassuring :-).

> However, I've never seen more than one extent, and
> there is probably some sort of methematical reason why you'll never exceed the
> 3 set aside for the extents file. I've never seen any that spans more than
> even 1 extent.

Well, I've poked around a little more, and it seems that the clump size
for the extents file is set based on the number of allocation blocks on
the volume.  Since this number is fixed at the time the volume is formatted,
and since the maximum size of the extents file is directly related to the
number of allocation blocks (a fact which initially escaped me), it looks
like the extents file will in fact never need more than one (or possibly
three :-)) extents.  Just in case, I'll write my code so that it handles
up to three properly...

Why do I care, you ask?  Well, there are SCSI drivers in the world which
do not reset the drive after a read error, and thus hang the File Manager in
SCSIDispatch if you try and read a file containing a bad block.  Since
a partially scrogged disk is just the kind of thing you want to backup
before you reformat or replace it :-),  I've been examining ways to scan
a volume's file structure as robustly as possible.  Luckily, HFS isn't too
bad as long as you understand B*-trees...

Unfortunately, this is of more than hypothetical concern at the moment. 
Sigh.

Amanda Walker
InterCon Systems Corporation
--

keith@apple.com@canremote.uucp (keith@Apple.COM) (12/21/89)

From: keith@Apple.COM (Keith Rollin)
Orga: Apple Computer Inc, Cupertino, CA

In article <1631@intercon.com> amanda@mermaid.intercon.com (Amanda
Walker) writes: >Here's a question for all you file system hackers. 
I've been meditating >upon IM-IV and hex dumps of volume header
blocks, and I can't find a >definitive answer to a simple question:
is the extents file on an HFS >volume guaranteed to be contiguous? 
All the examples I can find are, >and IM-IV seems to imply it, but it
doesn't actually say.  There's space >for up to 3 extents in the
volume header, but for more than that you'd >have to look in the file
itself, which seems uncomfortably recursive :-). >

Amanda,

The extents file is not guaranteed to be contiguous. It can be split
up into 3 extents of its own. Beyond that, I don't know what happens.
Some sort of system failure, I suppose. However, I've never seen more
than one extent, and there is probably some sort of methematical
reason why you'll never exceed the 3 set aside for the extents file.
I've never seen any that spans more than even 1 extent.

So the answer is, no, we don't go recurcurcurcurcursive.

-- 
---------------------------------------------------------------------
--------- Keith Rollin  ---  Apple Computer, Inc.  ---  Developer
Technical Support INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin,
Contusions
---
 * Via MaSNet/HST96/HST144/V32 - UN Mac Programmer
 * Via Usenet Newsgroup comp.sys.mac.programmer