Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JHGXN-0001z6-B7 for mharc-grub-devel@gnu.org; Tue, 22 Jan 2008 05:39:25 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JHGXK-0001vb-EG for grub-devel@gnu.org; Tue, 22 Jan 2008 05:39:22 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JHGXI-0001tr-Je for grub-devel@gnu.org; Tue, 22 Jan 2008 05:39:21 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JHGXI-0001sv-3s for grub-devel@gnu.org; Tue, 22 Jan 2008 05:39:20 -0500 Received: from nz-out-0506.google.com ([64.233.162.225]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JHGXI-0008Fe-4i for grub-devel@gnu.org; Tue, 22 Jan 2008 05:39:20 -0500 Received: by nz-out-0506.google.com with SMTP id f1so1326824nzc.21 for ; Tue, 22 Jan 2008 02:39:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=f/+eGoAzWKV1JExKP9IbM8Gku71cg1GoIUqcrj8MKd8=; b=FiuPpKdn/H8eBIA+A6OGnaPycvJN+hfJQjxN9hn3pmCS5mrhv9eS1fitulPL/ciCsKCqJKPNPcyJoOmk9d4091LIPHhAFVoFiY76ZU6YDX52Axiu0w/kuVJF4EZkgSTBxSej2X2GqZcnS2wVoAg+DiSI/vikixaThjYdRMN1Afw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=riRfYM1Ouesy5FC5nf4t9u8sn6wYp3GN387Xtx+tgmI6bpu1Id5en/n0dXoewdDaOmEjsPjWcL0TjH+4uSUgZbE6nYhSA/KoE/UmHUIJcMTCGEQZNLlcdrkl+L/Midp9FlDxJD6LM2Ckh2XXE4REseUkJPyvRt/KzLvTg+FZOsc= Received: by 10.110.42.13 with SMTP id p13mr3335574tip.34.1200998357788; Tue, 22 Jan 2008 02:39:17 -0800 (PST) Received: by 10.110.31.8 with HTTP; Tue, 22 Jan 2008 02:39:17 -0800 (PST) Message-ID: Date: Tue, 22 Jan 2008 18:39:17 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <874pd7xy3b.fsf@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1200443894.16148.16.camel@dv> <874pd7xy3b.fsf@xs4all.nl> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: hfs breakage X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jan 2008 10:39:23 -0000 On Jan 21, 2008 6:38 PM, Marco Gerards wrote: > Bean writes: > > Hi Bean, > > Thanks for picking this one up! > > [...] > > >> Moreover, if I mount the image as loop in Linux and remove files "grub" > >> and "grub.cfg", "ls" in grub-emu will go into infinite loop and print > >> "ofboot.b pc.mod raid.mod reboot.mod reiserfs.mod search.mod sfs.mod > >> sun.mod suspend.mod terminal.mod" over and over again. > > > > I think i figure out the problem, please try the following patch. > > > > * fs/hfs.c : Add magic values for cnid > > Did you forget the function name? perhaps i should use a name for the enum, something like hfs_cnid_t. > > > (grub_hfs_iterate_records): Use the correct file number for extents > > and catalog file. Fix problem in next index calculation. > > This line is too long, I think? Can you wrap this manually? ok. > > > (grub_hfs_find_node): Replace recursive function call with loop. > > (grub_hfs_iterate_dir): Replace recursive function call with loop. > > :-) > > I guess this code sucked a bit ;-) is the fix ok ? > > > diff --git a/fs/hfs.c b/fs/hfs.c > > index e8e9c3e..3480d3e 100644 > > --- a/fs/hfs.c > > +++ b/fs/hfs.c > > @@ -43,6 +43,16 @@ enum > > GRUB_HFS_FILETYPE_FILE = 2 > > }; > > > > +/* Catalog node ID (CNID). */ > > +enum > > + { > > + GRUB_HFS_CNID_ROOT_PARENT = 1, > > + GRUB_HFS_CNID_ROOT = 2, > > + GRUB_HFS_CNID_EXT = 3, > > + GRUB_HFS_CNID_CAT = 4, > > + GRUB_HFS_CNID_BAD = 5 > > + }; > > This is missing in the changelog entry. > > > /* A node descriptor. This is the header of every node. */ > > struct grub_hfs_node > > { > > @@ -447,7 +457,8 @@ grub_hfs_iterate_records (struct grub_hfs_data > > *data, int type, int idx, > > > > /* Read the node into memory. */ > > blk = grub_hfs_block (data, dat, > > - 0, idx / (data->blksz / nodesize), 0); > > + (type == 0) ? GRUB_HFS_CNID_CAT : > > GRUB_HFS_CNID_EXT, > > + idx / (data->blksz / nodesize), 0); > > What was the problem here? extents file and catalog file uses special file number, 3 and 4, respectively. for example, in sda.img, sector 5: 00 00 00 00 00 00 00 00 FF 01 00 01 00 00 07 00 00 00 00 04 00 2D 04 C3 00 0F 00 00 00 00 00 00 this is the first extent of catalog file that's not stored in super block, you can see that it use 4 as the file number. -- Bean