Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JJQpB-00057F-P1 for mharc-grub-devel@gnu.org; Mon, 28 Jan 2008 05:02:45 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJQp9-00056a-O5 for grub-devel@gnu.org; Mon, 28 Jan 2008 05:02:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJQp7-000564-8b for grub-devel@gnu.org; Mon, 28 Jan 2008 05:02:42 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJQp6-00055r-9G for grub-devel@gnu.org; Mon, 28 Jan 2008 05:02:40 -0500 Received: from rv-out-0910.google.com ([209.85.198.185]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JJQp5-0003Tq-1p for grub-devel@gnu.org; Mon, 28 Jan 2008 05:02:39 -0500 Received: by rv-out-0910.google.com with SMTP id c27so2502644rvf.6 for ; Mon, 28 Jan 2008 02:02:37 -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=jA1KAW3Ekzrl9YLMoM9wW41Q/2ZBvgaV5/A3extpLSs=; b=Fb0947HuQAzs2PuMmTXycKEBh/mv36sR9mrYvbGruhftRVicZe9SpTiA9IPgatfFkMotKjmliuYJph3GhAeGlpvL2upAZlOhHm8oZmx2euNJkCciR3/+IqNrcb4CrLWf5TP1HvtlQnRZsFK4/WIa1ZBZ4L5RCszzLC2PW2fGzuE= 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=D3iaTjJQ7JvmkwU4kV5rSIRSsQMQV3OBcpF0YBSVWxtvUFCs/kXSlI1DFai7UK2V7RpbM6R0J33TUdYjA5/kj91kKrvoI6Fxup/N0UkJ83d9BOhW+jM2RJkqVlAQ66ML2Wgw3CbWvKyCpsOlRixizqZ79GfwiEVLK4B114Z6NgQ= Received: by 10.140.82.38 with SMTP id f38mr3298323rvb.27.1201514557705; Mon, 28 Jan 2008 02:02:37 -0800 (PST) Received: by 10.141.82.5 with HTTP; Mon, 28 Jan 2008 02:02:37 -0800 (PST) Message-ID: Date: Mon, 28 Jan 2008 18:02:37 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <1201485266.11624.12.camel@k9.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080124145317.GA9385@thorin> <1201193272.334.2.camel@k9.localnet> <20080124171206.GA1515@thorin> <1201382697.541.11.camel@k9.localnet> <1201464791.964.23.camel@k9> <1201485266.11624.12.camel@k9.localnet> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2) 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: Mon, 28 Jan 2008 10:02:44 -0000 On Jan 28, 2008 9:54 AM, walt wrote: > > On Mon, 2008-01-28 at 04:25 +0800, Bean wrote: > ... > > > > please make a small ufs image containing the netbsd kernel, i don't a > > > > a bsd system at hand > > http://leaf.dragonflybsd.org/~wa1ter/ufs.gz > > I included a small text file (motd) to demonstrate that you can cat it > okay, but when you try 'multiboot /netbsd' you should get the same error > I've been describing. > > > > btw, if you have time, please try the a.out loader, it should be able > > to boot /boot/loader of freebsd, i don't know if openbsd and netbsd > > use the same booting method. > > diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk > > Heh. I'm assuming an .rmk file involves ruby somehow? The bonehead > build process that I'm using doesn't turn an .rmk into a .mk AFAICT, > but I'd like to know how to do it. all you need to do is do install ruby. here is a patch for ufs, it fix the indirect block calculation problem. * fs/ufs.c (INODE_BLKSZ): Fix incorrect value. (grub_ufs_get_file_block): Fix indirect block calculation problem. diff --git a/fs/ufs.c b/fs/ufs.c index 25cd1fa..ebb7198 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -52,7 +52,7 @@ grub_le_to_cpu##bits2 (data->inode2.field)) #define INODE_SIZE(data) INODE_ENDIAN (data,size,32,64) #define INODE_MODE(data) INODE_ENDIAN (data,mode,16,16) -#define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 32 : 64) +#define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 4 : 8) #define INODE_DIRBLOCKS(data,blk) INODE_ENDIAN \ (data,blocks.dir_blocks[blk],32,64) #define INODE_INDIRBLOCKS(data,blk) INODE_ENDIAN \ @@ -205,35 +205,41 @@ grub_ufs_get_file_block (struct grub_ufs_data *data, unsigned int blk) { struct grub_ufs_sblock *sblock = &data->sblock; unsigned int indirsz; + int log2_blksz; /* Direct. */ if (blk < GRUB_UFS_DIRBLKS) return INODE_DIRBLOCKS (data, blk); + log2_blksz = grub_le_to_cpu32 (data->sblock.log2_blksz); + blk -= GRUB_UFS_DIRBLKS; indirsz = UFS_BLKSZ (sblock) / INODE_BLKSZ (data); /* Single indirect block. */ if (blk < indirsz) { - grub_uint32_t indir[UFS_BLKSZ (sblock)]; - grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 0), + grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2]; + grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 0) << log2_blksz, 0, sizeof (indir), (char *) indir); - return indir[blk]; + return (data->ufs_type == UFS1) ? indir[blk] : indir[blk << 1]; } blk -= indirsz; /* Double indirect block. */ if (blk < UFS_BLKSZ (sblock) / indirsz) { - grub_uint32_t indir[UFS_BLKSZ (sblock)]; + grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2]; - grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1), + grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1) << log2_blksz, 0, sizeof (indir), (char *) indir); - grub_disk_read (data->disk, indir[blk / indirsz], + grub_disk_read (data->disk, + (data->ufs_type == UFS1) ? + indir[blk / indirsz] : indir [(blk / indirsz) << 1], 0, sizeof (indir), (char *) indir); - return indir[blk % indirsz]; + return (data->ufs_type == UFS1) ? + indir[blk % indirsz] : indir[(blk % indirsz) << 1]; } -- Bean