From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Q8zXg-0000eJ-O9 for mharc-grub-devel@gnu.org; Sun, 10 Apr 2011 14:39:24 -0400 Received: from [140.186.70.92] (port=56609 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8zXd-0000Yd-1y for grub-devel@gnu.org; Sun, 10 Apr 2011 14:39:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q8zXb-0006rB-2o for grub-devel@gnu.org; Sun, 10 Apr 2011 14:39:20 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:62943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q8zXa-0006qp-P9 for grub-devel@gnu.org; Sun, 10 Apr 2011 14:39:18 -0400 Received: by wwb39 with SMTP id 39so5104351wwb.30 for ; Sun, 10 Apr 2011 11:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:x-enigmail-version:content-type; bh=ftqr4wFhYc9+08DSXu/NNt9xy4tX44K5Deb93muEO1I=; b=IC4wdjENZNL7/H8eDkzOqpf0FGvmtaBhWacdcnNDXwuKPGN1iu0FogdrhcQWi/0Cgw pYd6zHb4vtszdC07Zq5HZkqB+2xsFia4nOHDoRA26XrDDtWopXMLpI4btdm77jygVtez mS2CdjLVP/McbvoDY45ZhpVO0eSiUVmtqnWZc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type; b=qkUHcj7tikhxYLOm2JcZqRGAXrB8jIsYSvbgCQnMXe3XTQNjii+dvTd0u0h5KjjmgZ WSPvhqxH/vdxSGjkYbbhPwgbSQv43cgf0+nYSFy0n/UW2Zv8ssR5tOLRNqohbz7b8Ma/ vWH1495k9F+UAsB/QNLRX2SlUUCIxnVF3yIDM= Received: by 10.216.58.200 with SMTP id q50mr518010wec.83.1302460756863; Sun, 10 Apr 2011 11:39:16 -0700 (PDT) Received: from debian.x201.phnet (200-57.62-81.cust.bluewin.ch [81.62.57.200]) by mx.google.com with ESMTPS id r80sm2292783wei.15.2011.04.10.11.39.12 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 10 Apr 2011 11:39:14 -0700 (PDT) Message-ID: <4DA1F948.4020506@gmail.com> Date: Sun, 10 Apr 2011 20:39:04 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110402 Iceowl/1.0b2 Icedove/3.1.9 MIME-Version: 1.0 To: The development of GNU GRUB References: In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig182F470F883926A4AC014AE9" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.49 Cc: Fam Zheng Subject: Re: [PATCH] MINIX file system version 3 support X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 18:39:22 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig182F470F883926A4AC014AE9 Content-Type: multipart/mixed; boundary="------------040703060209030500080100" This is a multi-part message in MIME format. --------------040703060209030500080100 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 28.07.2010 05:25, Fam Zheng wrote: > Hi, > > To support MINIX file system version 3, this patch adds a new module > named 'minix3'. It reuses most of the code in minix.mod, and handles > the latest MINIX file system version 3. > I've cleaned it up. Could you test it and point me as to where I can get an minix3 image for my own tests? > The requested assignment information has also been sent to > assign@gnu.org . > > --=20 > Best Regards! > Fam Zheng > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------040703060209030500080100 Content-Type: text/x-diff; name="minix3.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="minix3.diff" =3D=3D=3D modified file 'grub-core/Makefile.core.def' --- grub-core/Makefile.core.def 2011-03-26 11:59:02 +0000 +++ grub-core/Makefile.core.def 2011-04-10 15:36:48 +0000 @@ -959,6 +959,11 @@ }; =20 module =3D { + name =3D minix3; + common =3D fs/minix3.c; +}; + +module =3D { name =3D nilfs2; common =3D fs/nilfs2.c; }; =3D=3D=3D modified file 'grub-core/fs/minix.c' --- grub-core/fs/minix.c 2010-10-16 20:16:52 +0000 +++ grub-core/fs/minix.c 2011-04-10 16:35:06 +0000 @@ -25,14 +25,17 @@ #include #include =20 -#ifdef MODE_MINIX2 +#ifdef MODE_MINIX3 +#define GRUB_MINIX_MAGIC 0x4D5A +#elif defined(MODE_MINIX2) #define GRUB_MINIX_MAGIC 0x2468 #define GRUB_MINIX_MAGIC_30 0x2478 #else #define GRUB_MINIX_MAGIC 0x137F #define GRUB_MINIX_MAGIC_30 0x138F #endif -#define GRUB_MINIX_BSIZE 1024U + +#define GRUB_MINIX_INODE_DIR_BLOCKS 7 #define GRUB_MINIX_LOG2_BSIZE 1 #define GRUB_MINIX_ROOT_INODE 1 #define GRUB_MINIX_MAX_SYMLNK_CNT 8 @@ -41,7 +44,7 @@ #define GRUB_MINIX_IFDIR 0040000U #define GRUB_MINIX_IFLNK 0120000U =20 -#ifdef MODE_MINIX2 +#if defined(MODE_MINIX2) || defined(MODE_MINIX3) typedef grub_uint32_t grub_minix_uintn_t; #define grub_minix_le_to_cpu_n grub_le_to_cpu32 #else @@ -50,6 +53,13 @@ #endif =20 #define GRUB_MINIX_INODE_BLKSZ(data) sizeof (grub_minix_uintn_t) +#ifdef MODE_MINIX3 +typedef grub_uint32_t grub_minix_ino_t; +#define grub_minix_le_to_cpu_ino grub_le_to_cpu32 +#else +typedef grub_uint16_t grub_minix_ino_t; +#define grub_minix_le_to_cpu_ino grub_le_to_cpu16 +#endif =20 #define GRUB_MINIX_INODE_SIZE(data) (grub_minix_le_to_cpu_n (data->inode= =2Esize)) #define GRUB_MINIX_INODE_MODE(data) (grub_le_to_cpu16 (data->inode.mode)= ) @@ -62,9 +72,28 @@ =20 #define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \ + grub_le_to_cpu16 (sblock->log2_zone_size)) -#define GRUB_MINIX_ZONESZ (GRUB_MINIX_BSIZE \ +#define GRUB_MINIX_ZONESZ (data->block_size \ << grub_le_to_cpu16 (sblock->log2_zone_size)) =20 +#ifdef MODE_MINIX3 +struct grub_minix_sblock +{ + grub_uint32_t inode_cnt; + grub_uint16_t zone_cnt; + grub_uint16_t inode_bmap_size; + grub_uint16_t zone_bmap_size; + grub_uint16_t first_data_zone; + grub_uint16_t log2_zone_size; + grub_uint16_t pad; + grub_uint32_t max_file_size; + grub_uint32_t zones; + grub_uint16_t magic; + =20 + grub_uint16_t pad2; + grub_uint16_t block_size; + grub_uint8_t disk_version;=20 +}; +#else struct grub_minix_sblock { grub_uint16_t inode_cnt; @@ -76,8 +105,28 @@ grub_uint32_t max_file_size; grub_uint16_t magic; }; - -#ifndef MODE_MINIX2 +#endif + +#if defined(MODE_MINIX3) + +struct grub_minix_inode +{ + grub_uint16_t mode; + grub_uint16_t nlinks; + grub_uint16_t uid; + grub_uint8_t gid; + grub_uint8_t pad; + grub_uint32_t size; + grub_uint32_t atime; + grub_uint32_t mtime; + grub_uint32_t ctime; + grub_uint32_t dir_zones[7]; + grub_uint32_t indir_zone; + grub_uint32_t double_indir_zone; + grub_uint32_t unused; +}; + +#elif defined(MODE_MINIX2) struct grub_minix_inode { grub_uint16_t mode; @@ -121,6 +170,7 @@ int linknest; grub_disk_t disk; int filename_size; + grub_size_t block_size; }; =20 static grub_dl_t my_mod; @@ -141,18 +191,22 @@ { grub_minix_uintn_t indirn; grub_disk_read (data->disk, +#ifdef MODE_MINIX3 + zone * (data->block_size / GRUB_DISK_SECTOR_SIZE),= +#else zone << GRUB_MINIX_LOG2_ZONESZ, +#endif sizeof (grub_minix_uintn_t) * num, sizeof (grub_minix_uintn_t), (char *) &indirn); return grub_minix_le_to_cpu_n (indirn); } =20 /* Direct block. */ - if (blk < 7) + if (blk < GRUB_MINIX_INODE_DIR_BLOCKS) return GRUB_MINIX_INODE_DIR_ZONES (data, blk); =20 /* Indirect block. */ - blk -=3D 7; + blk -=3D GRUB_MINIX_INODE_DIR_BLOCKS; if (blk < GRUB_MINIX_ZONESZ / GRUB_MINIX_INODE_BLKSZ (data)) { indir =3D grub_get_indir (GRUB_MINIX_INODE_INDIR_ZONE (data), blk)= ; @@ -185,25 +239,27 @@ grub_minix_read_file (struct grub_minix_data *data, void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, unsigned offset, unsigned length), - int pos, grub_disk_addr_t len, char *buf) + grub_off_t pos, grub_disk_addr_t len, char *buf) { struct grub_minix_sblock *sblock =3D &data->sblock; - int i; - int blockcnt; + grub_disk_addr_t i; + grub_disk_addr_t blockcnt; + grub_uint64_t posblock; + grub_uint32_t blockoff; =20 /* Adjust len so it we can't read past the end of the file. */ if (len + pos > GRUB_MINIX_INODE_SIZE (data)) len =3D GRUB_MINIX_INODE_SIZE (data) - pos; =20 - blockcnt =3D (len + pos + GRUB_MINIX_BSIZE - 1) / GRUB_MINIX_BSIZE; + blockcnt =3D grub_divmod64 ((len + pos + data->block_size - 1), + data->block_size, 0); + posblock =3D grub_divmod64 (pos, data->block_size, &blockoff); =20 - for (i =3D pos / GRUB_MINIX_BSIZE; i < blockcnt; i++) + for (i =3D posblock; i < blockcnt; i++) { - int blknr; - int blockoff =3D pos % GRUB_MINIX_BSIZE; - int blockend =3D GRUB_MINIX_BSIZE; - - int skipfirst =3D 0; + grub_disk_addr_t blknr; + grub_uint32_t blockend =3D data->block_size; + grub_off_t skipfirst =3D 0; =20 blknr =3D grub_minix_get_file_block (data, i); if (grub_errno) @@ -212,28 +268,32 @@ /* Last block. */ if (i =3D=3D blockcnt - 1) { - blockend =3D (len + pos) % GRUB_MINIX_BSIZE; + grub_divmod64 (len + pos, data->block_size, &blockend); =20 if (!blockend) - blockend =3D GRUB_MINIX_BSIZE; + blockend =3D data->block_size; } =20 /* First block. */ - if (i =3D=3D (pos / (int) GRUB_MINIX_BSIZE)) + if (i =3D=3D posblock) { skipfirst =3D blockoff; blockend -=3D skipfirst; } =20 data->disk->read_hook =3D read_hook; - grub_disk_read (data->disk, blknr << GRUB_MINIX_LOG2_ZONESZ, + grub_disk_read (data->disk, +#ifdef MODE_MINIX3 + blknr * (sblock->block_size / GRUB_DISK_SECTOR_SIZE), +#else + blknr << GRUB_MINIX_LOG2_ZONESZ, +#endif skipfirst, blockend, buf); - data->disk->read_hook =3D 0; if (grub_errno) return -1; =20 - buf +=3D GRUB_MINIX_BSIZE - skipfirst; + buf +=3D data->block_size - skipfirst; } =20 return len; @@ -248,16 +308,18 @@ struct grub_minix_sblock *sblock =3D &data->sblock; =20 /* Block in which the inode is stored. */ - int block; + grub_disk_addr_t block; data->ino =3D ino; =20 /* The first inode in minix is inode 1. */ ino--; - - block =3D ((2 + grub_le_to_cpu16 (sblock->inode_bmap_size) - + grub_le_to_cpu16 (sblock->zone_bmap_size)) - << GRUB_MINIX_LOG2_BSIZE); - + block =3D (2 + grub_le_to_cpu16 (sblock->inode_bmap_size) + + grub_le_to_cpu16 (sblock->zone_bmap_size)); +#ifndef MODE_MINIX3 + block <<=3D GRUB_MINIX_LOG2_BSIZE; +#else + block *=3D sblock->block_size / GRUB_DISK_SECTOR_SIZE; +#endif block +=3D ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_in= ode)); int offs =3D (ino % (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode)) @@ -333,7 +395,7 @@ =20 do { - grub_uint16_t ino; + grub_minix_ino_t ino; char filename[data->filename_size + 1]; =20 if (grub_strlen (name) =3D=3D 0) @@ -353,7 +415,7 @@ if (!grub_strcmp (name, filename)) { dirino =3D data->ino; - grub_minix_read_inode (data, grub_le_to_cpu16 (ino)); + grub_minix_read_inode (data, grub_minix_le_to_cpu_ino (ino)); =20 /* Follow the symlink. */ if ((GRUB_MINIX_INODE_MODE (data) @@ -409,20 +471,35 @@ goto fail; =20 if (grub_le_to_cpu16 (data->sblock.magic) =3D=3D GRUB_MINIX_MAGIC) + { +#if !defined(MODE_MINIX3) data->filename_size =3D 14; +#else + data->filename_size =3D 60; +#endif + } +#if !defined(MODE_MINIX3) else if (grub_le_to_cpu16 (data->sblock.magic) =3D=3D GRUB_MINIX_MAGIC= _30) data->filename_size =3D 30; +#endif else goto fail; =20 data->disk =3D disk; data->linknest =3D 0; +#ifdef MODE_MINIX3 + data->block_size =3D grub_le_to_cpu16 (data->sblock.block_size); +#else + data->block_size =3D 1024U; +#endif =20 return data; =20 fail: grub_free (data); -#ifdef MODE_MINIX2 +#if defined(MODE_MINIX3) + grub_error (GRUB_ERR_BAD_FS, "not a minix3 filesystem"); +#elif defined(MODE_MINIX2) grub_error (GRUB_ERR_BAD_FS, "not a minix2 filesystem"); #else grub_error (GRUB_ERR_BAD_FS, "not a minix filesystem"); @@ -458,7 +535,7 @@ =20 while (pos < GRUB_MINIX_INODE_SIZE (data)) { - grub_uint16_t ino; + grub_minix_ino_t ino; char filename[data->filename_size + 1]; int dirino =3D data->ino; struct grub_dirhook_info info; @@ -474,10 +551,13 @@ (char *) filename) < 0) return grub_errno; filename[data->filename_size] =3D '\0'; + if (!ino) + { + pos +=3D sizeof (ino) + data->filename_size; + continue; + } =20 - /* The filetype is not stored in the dirent. Read the inode to - find out the filetype. This *REALLY* sucks. */ - grub_minix_read_inode (data, grub_le_to_cpu16 (ino)); + grub_minix_read_inode (data, grub_minix_le_to_cpu_ino (ino)); info.dir =3D ((GRUB_MINIX_INODE_MODE (data) & GRUB_MINIX_IFDIR) =3D=3D GRUB_MINIX_IFDIR); if (hook (filename, &info) ? 1 : 0) @@ -556,7 +636,9 @@ =0C static struct grub_fs grub_minix_fs =3D { -#ifdef MODE_MINIX2 +#if defined(MODE_MINIX3) + .name =3D "minix3", +#elif defined(MODE_MINIX2) .name =3D "minix2", #else .name =3D "minix", @@ -568,7 +650,9 @@ .next =3D 0 }; =20 -#ifdef MODE_MINIX2 +#if defined(MODE_MINIX3) +GRUB_MOD_INIT(minix3) +#elif defined(MODE_MINIX2) GRUB_MOD_INIT(minix2) #else GRUB_MOD_INIT(minix) @@ -578,7 +662,9 @@ my_mod =3D mod; } =20 -#ifdef MODE_MINIX2 +#if defined(MODE_MINIX3) +GRUB_MOD_FINI(minix3) +#elif defined(MODE_MINIX2) GRUB_MOD_FINI(minix2) #else GRUB_MOD_FINI(minix) =3D=3D=3D added file 'grub-core/fs/minix3.c' --- grub-core/fs/minix3.c 1970-01-01 00:00:00 +0000 +++ grub-core/fs/minix3.c 2011-04-10 15:36:48 +0000 @@ -0,0 +1,2 @@ +#define MODE_MINIX3 1 +#include "minix.c" --------------040703060209030500080100-- --------------enig182F470F883926A4AC014AE9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAk2h+UgACgkQNak7dOguQgnP4wD/fqXtokTYaZWX9UURi3zXxg92 ylOOwgImIhaDiyTClDAA/361ogrzwIchWM8Lm8WEP/41TBhzReSdW6bhvDY+YSnY =4ZN2 -----END PGP SIGNATURE----- --------------enig182F470F883926A4AC014AE9--