Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: VCB Blocks, Volume Ref#'s and other mysteries Message-ID: <6590@hoptoad.uucp> Date: 21 Feb 89 05:14:32 GMT References: <1668@psu-cs.UUCP> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 39 In article <1668@psu-cs.UUCP> fitzgerd@psu-cs.UUCP (Don Fitzgerald) writes: >I have bumped into what I think is a very interesting situation. After a call >to GetVol I get a volume reference number for my HD20 which seems reasonable. >A few lines later I make a call to PBHGetVInfo and ioVRefNum gives me a >different Number ! I had set ioVolindex as one and there were not any other >volumes mounted. Hmmm interesting. Once again the weirdness of HFS bites the unwary traveller. GetVol returns a working directory reference number, which pretends to be a volume reference number but is in fact a volume/directory pair. PBHGetVInfo returns the actual volume reference number. Both are behaving correctly. Because there still seems to be a lot of misunderstanding about working directories (three years later), a brief summary is in order. The original Mac had a flat file system; all the files in a volume were at the top level, and the folders were rather unconvincing fictions which only the Finder could see. Bad design, but that's neither here nor there. When the HD20 came out, there was an obvious need for a real hierarchical file system, but it had to be compatible with existing software. The Standard File Package used by users to select files returned only a name and a volume reference number (and a type), so somehow the volume/directory pair had to be crammed into the volume reference number. They did this by creating working directory reference numbers, which look like volume reference numbers and can be used in all the old file system calls that take a volume reference number, but they actualy refer to an internal table holding a volume/directory pair. All the old (non-"H") traps use these now, including GetVol and SetVol. I am sorely tempted to complain about the initial bad design; if part of the Mac design team realized the need for folders, how could they possibly fail to require them of the file system team? But this would serve no purpose, I suppose. We're stuck with the current cleverly hacked system. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "Americans will buy anything, as long as it doesn't cross the thin line between cute and demonic." -- Ian Shoales