NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/43344
The following reply was made to PR kern/43344; it has been noted by GNATS.
From: Jeff Rizzo <riz%tastylime.net@localhost>
To: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
Cc: gnats-bugs%NetBSD.org@localhost
Subject: Re: kern/43344
Date: Wed, 16 Jun 2010 14:30:24 -0700
This is a multi-part message in MIME format.
--------------040308030201050100000304
Content-Type: multipart/alternative;
boundary="------------040801040209050107010005"
--------------040801040209050107010005
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
On 06/16/2010 10:25 AM, Izumi Tsutsui wrote:
>> Here's what the patch consists of. If there's other important stuff,
>> I'll be glad to add it before requesting a pullup.
>>
> At least the following revisions are also required, but
> I have not checked if they can be applied cleanly to netbsd-5:
> ---
> src/sbin/fsck_ext2fs/inode.c 1.28
> src/sbin/fsck_ext2fs/setup.c 1.26
> src/sbin/newfs_ext2fs/mke2fs.c 1.11, 1.12
> src/sbin/newfs_ext2fs/newfs_ext2fs.c 1.6, 1.7, 1.8
> src/sbin/newfs_ext2fs/newfs_ext2fs.8 1.3, 1.4
> src/sys/lib/libsa/ext2fs.c 1.7
> src/sys/ufs/ext2fs/ext2fs_dinode.h 1.19
> ---
>
> FYI, not relevant to this PR, but IIRC I saw some problems on
> inode=256 ext2fs. It sometimes got mangled on fsck_ext2fs(8),
> but I didn't track what caused the issue...
>
The following revisions apply cleanly to netbsd-5:
sbin/fsck_ext2fs/inode.c 1.24-28
sbin/fsck_ext2fs/setup.c 1.26
sbin/newfs_ext2fs/extern.h 1.3
sbin/newfs_ext2fs/mke2fs.c 1.10-12
sbin/newfs_ext2fs/newfs_ext2fs.8 1.2-4
sbin/newfs_ext2fs/newfs_ext2fs.c 1.5-8
sys/lib/libsa/ext2fs.c 1.6-7
sys/ufs/ext2fs/ext2fs_dinode.h 1.18-19
sys/ufs/ext2fs/ext2fs_inode.c 1.68
sys/ufs/ext2fs/ext2fs_vfsops.c 1.142
If someone can verify for me that they have the intended effect, I will
request pullup to netbsd-5.
I built netbsd-5/amd64 with these revisions, which can be retrieved here:
http://www.tastylime.net/netbsd/amd64-PR43344/
attached is a patch against netbsd-5-RC3, and the commit messages for
all the included revisions.
--------------040801040209050107010005
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 06/16/2010 10:25 AM, Izumi Tsutsui wrote:
<blockquote cite="mid:100617022549.M0114633%mirage.ceres.dti.ne.jp@localhost"
type="cite">
<blockquote type="cite">
<pre wrap=""> Here's what the patch consists of. If there's other
important stuff,
I'll be glad to add it before requesting a pullup.
</pre>
</blockquote>
<pre wrap="">
At least the following revisions are also required, but
I have not checked if they can be applied cleanly to netbsd-5:
---
src/sbin/fsck_ext2fs/inode.c 1.28
src/sbin/fsck_ext2fs/setup.c 1.26
src/sbin/newfs_ext2fs/mke2fs.c 1.11, 1.12
src/sbin/newfs_ext2fs/newfs_ext2fs.c 1.6, 1.7, 1.8
src/sbin/newfs_ext2fs/newfs_ext2fs.8 1.3, 1.4
src/sys/lib/libsa/ext2fs.c 1.7
src/sys/ufs/ext2fs/ext2fs_dinode.h 1.19
---
FYI, not relevant to this PR, but IIRC I saw some problems on
inode=256 ext2fs. It sometimes got mangled on fsck_ext2fs(8),
but I didn't track what caused the issue...
</pre>
</blockquote>
<br>
The following revisions apply cleanly to netbsd-5:<br>
<br>
sbin/fsck_ext2fs/inode.c
1.24-28<br>
sbin/fsck_ext2fs/setup.c
1.26<br>
sbin/newfs_ext2fs/extern.h
1.3<br>
sbin/newfs_ext2fs/mke2fs.c
1.10-12<br>
sbin/newfs_ext2fs/newfs_ext2fs.8
1.2-4<br>
sbin/newfs_ext2fs/newfs_ext2fs.c
1.5-8<br>
sys/lib/libsa/ext2fs.c
1.6-7<br>
sys/ufs/ext2fs/ext2fs_dinode.h
1.18-19<br>
sys/ufs/ext2fs/ext2fs_inode.c
1.68<br>
sys/ufs/ext2fs/ext2fs_vfsops.c
1.142<br>
<br>
<br>
If someone can verify for me that they have the intended effect, I will
request pullup to netbsd-5.<br>
<br>
I built netbsd-5/amd64 with these revisions, which can be retrieved
here:<br>
<br>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<a
href="http://www.tastylime.net/netbsd/amd64-PR43344/">http://www.tastylime.net/netbsd/amd64-PR43344/</a><br>
<br>
attached is a patch against netbsd-5-RC3, and the commit messages for
all the included revisions.<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>
--------------040801040209050107010005--
--------------040308030201050100000304
Content-Type: text/plain;
name="40936"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="40936"
Module Name: src
Committed By: christos
Date: Sun Mar 1 15:59:57 UTC 2009
Modified Files:
src/sys/ufs/ext2fs: ext2fs_dinode.h ext2fs_inode.c ext2fs_vfsops.c
Log Message:
PR/40936: Frederik Sausmikat: ext2fs: add support for inodes > 128 bytes
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/ext2fs/ext2fs_dinode.h
cvs rdiff -u -r1.67 -r1.68 src/sys/ufs/ext2fs/ext2fs_inode.c
cvs rdiff -u -r1.141 -r1.142 src/sys/ufs/ext2fs/ext2fs_vfsops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: christos
Date: Sun Mar 1 19:21:09 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: extern.h mke2fs.c newfs_ext2fs.8 newfs_ext2fs.c
Log Message:
Support variable inode sizes.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/newfs_ext2fs/extern.h
cvs rdiff -u -r1.9 -r1.10 src/sbin/newfs_ext2fs/mke2fs.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/newfs_ext2fs/newfs_ext2fs.8
cvs rdiff -u -r1.4 -r1.5 src/sbin/newfs_ext2fs/newfs_ext2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: christos
Date: Sun Mar 1 19:37:16 UTC 2009
Modified Files:
src/sys/lib/libsa: ext2fs.c
Log Message:
catch up with variable inode size.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/lib/libsa/ext2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: tsutsui
Date: Mon Mar 2 09:54:49 UTC 2009
Modified Files:
src/sys/ufs/ext2fs: ext2fs_dinode.h
Log Message:
Don't use e2fs_inode_size in superblock on E2FS_REV0 file system.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/ufs/ext2fs/ext2fs_dinode.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: tsutsui
Date: Mon Mar 2 10:15:59 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: mke2fs.c
Log Message:
- accept only EXT2_REV0_DINODE_SIZE inodesize on -O 0
- use inodesize to get offset of inode, not struct ext2fs_dinode array
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/newfs_ext2fs/mke2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: tsutsui
Date: Mon Mar 2 10:16:49 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: newfs_ext2fs.c
Log Message:
Replace a magic number with a new EXT2_REV0_DINODE_SIZE macro.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/newfs_ext2fs/newfs_ext2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: tsutsui
Date: Mon Mar 2 10:25:01 UTC 2009
Modified Files:
src/sys/lib/libsa: ext2fs.c
Log Message:
Use EXT2_DINODE_SIZE() to get offset of inode, not struct ext2fs_dinode array.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/lib/libsa/ext2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: tsutsui
Date: Mon Mar 2 10:38:13 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: newfs_ext2fs.c
Log Message:
Fix botched logic in inodesize check.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/newfs_ext2fs/newfs_ext2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: tsutsui
Date: Mon Mar 2 10:57:03 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: mke2fs.c
Log Message:
Use inodesize to get offset of inode in one more place.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sbin/newfs_ext2fs/mke2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: tsutsui
Date: Mon Mar 2 11:31:59 UTC 2009
Modified Files:
src/sbin/fsck_ext2fs: inode.c setup.c
Log Message:
- add a sanity check for e2fs_inode_size in readsb()
- use EXT2_DINODE_SIZE() rather than sizeof(struct ext2fs_dinode) or
struct ext2fs_dinode array/pointer to see e2fs_ipb and inode offsets
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sbin/fsck_ext2fs/inode.c
cvs rdiff -u -r1.25 -r1.26 src/sbin/fsck_ext2fs/setup.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: wiz
Date: Sun Mar 1 21:52:37 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: newfs_ext2fs.8
Log Message:
Sort options.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/newfs_ext2fs/newfs_ext2fs.8
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: wiz
Date: Sun Mar 1 21:52:59 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: newfs_ext2fs.8
Log Message:
New sentence, new line.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/newfs_ext2fs/newfs_ext2fs.8
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Module Name: src
Committed By: wiz
Date: Sun Mar 1 21:54:31 UTC 2009
Modified Files:
src/sbin/newfs_ext2fs: newfs_ext2fs.c
Log Message:
Sort options in usage.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/newfs_ext2fs/newfs_ext2fs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified Files:
src/sbin/fsck_ext2fs: inode.c
Log Message:
- unsigned -> unsigned int
- remove unnecessary casts from malloc(3) and free(3)
- fix a bogus indent
To generate a diff of this commit:
cvs rdiff -r1.23 -r1.24 src/sbin/fsck_ext2fs/inode.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified Files:
src/sbin/fsck_ext2fs: inode.c
Log Message:
Use "size > INT32_MAX" rather than "size >= 0x80000000U" to check 2GB limit.
To generate a diff of this commit:
cvs rdiff -r1.24 -r1.25 src/sbin/fsck_ext2fs/inode.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified Files:
src/sbin/fsck_ext2fs: inode.c
Log Message:
Add missed byteswap ops against ext2fs_dinode members.
To generate a diff of this commit:
cvs rdiff -r1.25 -r1.26 src/sbin/fsck_ext2fs/inode.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified Files:
src/sbin/fsck_ext2fs: inode.c
Log Message:
Handle 32 bit uid field on E2FS_REV1.
To generate a diff of this commit:
cvs rdiff -r1.26 -r1.27 src/sbin/fsck_ext2fs/inode.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
--------------040308030201050100000304
Content-Type: text/x-diff;
name="40936.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="40936.patch"
Index: sbin/fsck_ext2fs/inode.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ext2fs/inode.c,v
retrieving revision 1.23
diff -p -u -r1.23 inode.c
--- sbin/fsck_ext2fs/inode.c 9 Oct 2008 16:56:23 -0000 1.23
+++ sbin/fsck_ext2fs/inode.c 16 Jun 2010 21:29:47 -0000
@@ -127,7 +127,7 @@ inosize(struct ext2fs_dinode *dp)
if ((fs2h16(dp->e2di_mode) & IFMT) == IFREG)
size |= (u_int64_t)fs2h32(dp->e2di_dacl) << 32;
- if (size >= 0x80000000U)
+ if (size > INT32_MAX)
(void)setlarge();
return size;
}
@@ -137,10 +137,10 @@ inossize(struct ext2fs_dinode *dp, u_int
{
if ((fs2h16(dp->e2di_mode) & IFMT) == IFREG) {
dp->e2di_dacl = h2fs32(size >> 32);
- if (size >= 0x80000000U)
+ if (size > INT32_MAX)
if (!setlarge())
return;
- } else if (size >= 0x80000000U) {
+ } else if (size > INT32_MAX) {
pfatal("TRYING TO SET FILESIZE TO %llu ON MODE %x FILE\n",
(unsigned long long)size, fs2h16(dp->e2di_mode) & IFMT);
return;
@@ -169,7 +169,7 @@ ckinode(struct ext2fs_dinode *dp, struct
dino = *dp;
ndb = howmany(inosize(&dino), sblock.e2fs_bsize);
for (ap = &dino.e2di_blocks[0]; ap < &dino.e2di_blocks[NDADDR];
-
ap++,ndb--) {
+ ap++,ndb--) {
idesc->id_numfrags = 1;
if (*ap == 0) {
if (idesc->id_type == DATA && ndb > 0) {
@@ -325,7 +325,7 @@ chkrange(daddr_t blk, int cnt)
{
int c, overh;
- if ((unsigned)(blk + cnt) > maxfsblock)
+ if ((unsigned int)(blk + cnt) > maxfsblock)
return (1);
c = dtog(&sblock, blk);
overh = cgoverhead(c);
@@ -371,6 +371,7 @@ struct ext2fs_dinode *
ginode(ino_t inumber)
{
daddr_t iblk;
+ struct ext2fs_dinode *dp;
if ((inumber < EXT2_FIRSTINO &&
inumber != EXT2_ROOTINO &&
@@ -385,9 +386,13 @@ ginode(ino_t inumber)
if (pbp != 0)
pbp->b_flags &= ~B_INUSE;
pbp = getdatablk(iblk, sblock.e2fs_bsize);
- startinum = ((inumber -1) / sblock.e2fs_ipb) * sblock.e2fs_ipb
+ 1;
+ startinum =
+ ((inumber - 1) / sblock.e2fs_ipb) * sblock.e2fs_ipb + 1;
}
- return (&pbp->b_un.b_dinode[(inumber-1) % sblock.e2fs_ipb]);
+ dp = (struct ext2fs_dinode *)(pbp->b_un.b_buf +
+ EXT2_DINODE_SIZE(&sblock) * ino_to_fsbo(&sblock, inumber));
+
+ return dp;
}
/*
@@ -396,14 +401,15 @@ ginode(ino_t inumber)
*/
ino_t nextino, lastinum;
long readcnt, readpercg, fullcnt, inobufsize, partialcnt, partialsize;
-struct ext2fs_dinode *inodebuf;
+char *inodebuf;
struct ext2fs_dinode *
getnextinode(ino_t inumber)
{
long size;
daddr_t dblk;
- static struct ext2fs_dinode *dp;
+ struct ext2fs_dinode *dp;
+ static char *bp;
if (inumber != nextino++ || inumber > maxino)
errexit("bad inode number %llu to nextinode",
@@ -418,10 +424,13 @@ getnextinode(ino_t inumber)
size = inobufsize;
lastinum += fullcnt;
}
- (void)bread(fsreadfd, (char *)inodebuf, dblk, size);
- dp = inodebuf;
+ (void)bread(fsreadfd, inodebuf, dblk, size);
+ bp = inodebuf;
}
- return (dp++);
+ dp = (struct ext2fs_dinode *)bp;
+ bp += EXT2_DINODE_SIZE(&sblock);
+
+ return dp;
}
void
@@ -433,10 +442,10 @@ resetinodebuf(void)
lastinum = 1;
readcnt = 0;
inobufsize = blkroundup(&sblock, INOBUFSIZE);
- fullcnt = inobufsize / sizeof(struct ext2fs_dinode);
+ fullcnt = inobufsize / EXT2_DINODE_SIZE(&sblock);
readpercg = sblock.e2fs.e2fs_ipg / fullcnt;
partialcnt = sblock.e2fs.e2fs_ipg % fullcnt;
- partialsize = partialcnt * sizeof(struct ext2fs_dinode);
+ partialsize = partialcnt * EXT2_DINODE_SIZE(&sblock);
if (partialcnt != 0) {
readpercg++;
} else {
@@ -444,8 +453,7 @@ resetinodebuf(void)
partialsize = inobufsize;
}
if (inodebuf == NULL &&
- (inodebuf = (struct ext2fs_dinode *)malloc((unsigned)inobufsize)) ==
- NULL)
+ (inodebuf = malloc((unsigned int)inobufsize)) == NULL)
errexit("Cannot allocate space for inode buffer");
while (nextino < EXT2_ROOTINO)
(void)getnextinode(nextino);
@@ -456,7 +464,7 @@ freeinodebuf(void)
{
if (inodebuf != NULL)
- free((char *)inodebuf);
+ free(inodebuf);
inodebuf = NULL;
}
@@ -478,8 +486,7 @@ cacheino(struct ext2fs_dinode *dp, ino_t
if (blks > NDADDR)
blks = NDADDR + NIADDR;
/* XXX ondisk32 */
- inp = (struct inoinfo *)
- malloc(sizeof(*inp) + (blks - 1) * sizeof(int32_t));
+ inp = malloc(sizeof(*inp) + (blks - 1) * sizeof(int32_t));
if (inp == NULL)
return;
inpp = &inphead[inumber % numdirs];
@@ -499,7 +506,7 @@ cacheino(struct ext2fs_dinode *dp, ino_t
if (inplast == listmax) {
listmax += 100;
inpsort = (struct inoinfo **)realloc((char *)inpsort,
- (unsigned)listmax * sizeof(struct inoinfo *));
+ (unsigned int)listmax * sizeof(struct inoinfo *));
if (inpsort == NULL)
errexit("cannot increase directory list");
}
@@ -534,9 +541,9 @@ inocleanup(void)
if (inphead == NULL)
return;
for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--)
- free((char *)(*inpp));
- free((char *)inphead);
- free((char *)inpsort);
+ free(*inpp);
+ free(inphead);
+ free(inpsort);
inphead = inpsort = NULL;
}
@@ -555,7 +562,7 @@ clri(struct inodesc *idesc, const char *
dp = ginode(idesc->id_number);
if (flag == 1) {
pwarn("%s %s", type,
- (dp->e2di_mode & IFMT) == IFDIR ? "DIR" : "FILE");
+ (fs2h16(dp->e2di_mode) & IFMT) == IFDIR ? "DIR" : "FILE");
pinode(idesc->id_number);
}
if (preen || reply("CLEAR") == 1) {
@@ -612,18 +619,22 @@ pinode(ino_t ino)
char *p;
struct passwd *pw;
time_t t;
+ uid_t uid;
printf(" I=%llu ", (unsigned long long)ino);
if ((ino < EXT2_FIRSTINO && ino != EXT2_ROOTINO) || ino > maxino)
return;
dp = ginode(ino);
+ uid = fs2h16(dp->e2di_uid);
+ if (sblock.e2fs.e2fs_rev > E2FS_REV0)
+ uid |= fs2h16(dp->e2di_uid_high) << 16;
printf(" OWNER=");
#ifndef SMALL
- if (Uflag && (pw = getpwuid((int)dp->e2di_uid)) != 0)
+ if (Uflag && (pw = getpwuid(uid)) != 0)
printf("%s ", pw->pw_name);
else
#endif
- printf("%u ", (unsigned)fs2h16(dp->e2di_uid));
+ printf("%u ", (unsigned int)uid);
printf("MODE=%o\n", fs2h16(dp->e2di_mode));
if (preen)
printf("%s: ", cdevname());
Index: sbin/fsck_ext2fs/setup.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ext2fs/setup.c,v
retrieving revision 1.25
diff -p -u -r1.25 setup.c
--- sbin/fsck_ext2fs/setup.c 16 Mar 2008 23:17:55 -0000 1.25
+++ sbin/fsck_ext2fs/setup.c 16 Jun 2010 21:29:47 -0000
@@ -309,6 +309,14 @@ readsb(int listerr)
badsb(listerr, "BAD LOG_BSIZE");
return 0;
}
+ if (sblock.e2fs.e2fs_rev > E2FS_REV0 &&
+ (!powerof2(sblock.e2fs.e2fs_inode_size) ||
+ sblock.e2fs.e2fs_inode_size < sizeof(struct ext2fs_dinode) ||
+ sblock.e2fs.e2fs_inode_size >
+ (1024 << sblock.e2fs.e2fs_log_bsize))) {
+ badsb(listerr, "BAD INODE_SIZE");
+ return 0;
+ }
/* compute the dynamic fields of the in-memory sb */
/* compute dynamic sb infos */
@@ -323,7 +331,7 @@ readsb(int listerr)
sblock.e2fs_bmask = ~sblock.e2fs_qbmask;
sblock.e2fs_ngdb = howmany(sblock.e2fs_ncg,
sblock.e2fs_bsize / sizeof(struct ext2_gd));
- sblock.e2fs_ipb = sblock.e2fs_bsize / sizeof(struct ext2fs_dinode);
+ sblock.e2fs_ipb = sblock.e2fs_bsize / EXT2_DINODE_SIZE(&sblock);
sblock.e2fs_itpg = howmany(sblock.e2fs.e2fs_ipg, sblock.e2fs_ipb);
/*
Index: sbin/newfs_ext2fs/extern.h
===================================================================
RCS file: /cvsroot/src/sbin/newfs_ext2fs/extern.h,v
retrieving revision 1.2
diff -p -u -r1.2 extern.h
--- sbin/newfs_ext2fs/extern.h 14 Dec 2007 13:19:35 -0000 1.2
+++ sbin/newfs_ext2fs/extern.h 16 Jun 2010 21:29:47 -0000
@@ -41,6 +41,7 @@ extern int Nflag; /* run mkfs without w
extern int Oflag; /* format as an 4.3BSD file system */
extern int verbosity; /* amount of printf() output */
extern int64_t fssize; /* file system size */
+extern uint16_t inodesize; /* bytes per inode */
extern uint sectorsize; /* sector size */
extern uint fsize; /* fragment size */
extern uint bsize; /* block size */
Index: sbin/newfs_ext2fs/mke2fs.c
===================================================================
RCS file: /cvsroot/src/sbin/newfs_ext2fs/mke2fs.c,v
retrieving revision 1.9
diff -p -u -r1.9 mke2fs.c
--- sbin/newfs_ext2fs/mke2fs.c 28 Aug 2008 16:29:24 -0000 1.9
+++ sbin/newfs_ext2fs/mke2fs.c 16 Jun 2010 21:29:47 -0000
@@ -243,6 +243,12 @@ mke2fs(const char *fsys, int fi, int fo)
bsize, fsize);
}
+ /* variable inodesize is REV1 feature */
+ if (Oflag == 0 && inodesize != EXT2_REV0_DINODE_SIZE) {
+ errx(EXIT_FAILURE, "GOOD_OLD_REV file system format"
+ " doesn't support %d byte inode\n", inodesize);
+ }
+
sblock.e2fs.e2fs_log_bsize = ilog2(bsize) - LOG_MINBSIZE;
/* Umm, why not e2fs_log_fsize? */
sblock.e2fs.e2fs_fsize = ilog2(fsize) - LOG_MINBSIZE;
@@ -252,7 +258,7 @@ mke2fs(const char *fsys, int fi, int fo)
sblock.e2fs_qbmask = sblock.e2fs_bsize - 1;
sblock.e2fs_bmask = ~sblock.e2fs_qbmask;
sblock.e2fs_fsbtodb = ilog2(sblock.e2fs_bsize) - ilog2(sectorsize);
- sblock.e2fs_ipb = sblock.e2fs_bsize / EXT2_DINODE_SIZE;
+ sblock.e2fs_ipb = sblock.e2fs_bsize / inodesize;
/*
* Ext2fs preserves BBSIZE (1024 bytes) space at the top for
@@ -301,7 +307,7 @@ mke2fs(const char *fsys, int fi, int fo)
num_inodes = UINT16_MAX * ncg; /* ext2bgd_nifree is uint16_t */
inodes_per_cg = num_inodes / ncg;
- iblocks_per_cg = howmany(EXT2_DINODE_SIZE * inodes_per_cg, bsize);
+ iblocks_per_cg = howmany(inodesize * inodes_per_cg, bsize);
/* Check that the last cylinder group has enough space for inodes */
minblocks_per_cg =
@@ -404,7 +410,7 @@ mke2fs(const char *fsys, int fi, int fo)
sblock.e2fs.e2fs_rgid = getegid();
sblock.e2fs.e2fs_first_ino = EXT2_FIRSTINO;
- sblock.e2fs.e2fs_inode_size = EXT2_DINODE_SIZE;
+ sblock.e2fs.e2fs_inode_size = inodesize;
/* e2fs_block_group_nr is set on writing superblock to each group */
@@ -754,11 +760,11 @@ initcg(uint cylno)
* to override these generated numbers.
*/
memset(buf, 0, sblock.e2fs_bsize);
- dp = (struct ext2fs_dinode *)buf;
for (i = 0; i < sblock.e2fs_itpg; i++) {
for (j = 0; j < sblock.e2fs_ipb; j++) {
+ dp = (struct ext2fs_dinode *)(buf + inodesize * j);
/* h2fs32() just for consistency */
- dp[j].e2di_gen = h2fs32(arc4random());
+ dp->e2di_gen = h2fs32(arc4random());
}
wtfs(fsbtodb(&sblock, gd[cylno].ext2bgd_i_tables + i),
sblock.e2fs_bsize, buf);
@@ -1352,8 +1358,8 @@ iput(struct ext2fs_dinode *ip, ino_t ino
d = fsbtodb(&sblock, ino_to_fsba(&sblock, ino));
rdfs(d, sblock.e2fs_bsize, bp);
- dp = (struct ext2fs_dinode *)bp;
- dp += ino_to_fsbo(&sblock, ino);
+ dp = (struct ext2fs_dinode *)(bp +
+ inodesize * ino_to_fsbo(&sblock, ino));
e2fs_isave(ip, dp);
/* e2fs_i_bswap() doesn't swap e2di_blocks addrs */
if ((ip->e2di_mode & EXT2_IFMT) != EXT2_IFLNK) {
Index: sbin/newfs_ext2fs/newfs_ext2fs.8
===================================================================
RCS file: /cvsroot/src/sbin/newfs_ext2fs/newfs_ext2fs.8,v
retrieving revision 1.1
diff -p -u -r1.1 newfs_ext2fs.8
--- sbin/newfs_ext2fs/newfs_ext2fs.8 17 Nov 2007 16:50:26 -0000 1.1
+++ sbin/newfs_ext2fs/newfs_ext2fs.8 16 Jun 2010 21:29:47 -0000
@@ -29,7 +29,7 @@
.\"
.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95
.\"
-.Dd November 17, 2007
+.Dd March 1, 2009
.Dt NEWFS_EXT2FS 8
.Os
.Sh NAME
@@ -39,6 +39,7 @@
.Nm
.Op Fl FINZ
.Op Fl b Ar block-size
+.Op Fl D Ar inodesize
.Op Fl f Ar frag-size
.Op Fl i Ar bytes-per-inode
.Op Fl m Ar free-space
@@ -93,6 +94,10 @@ The default size depends upon the size o
.It \*[Gt] 512 MB
4 KB
.El
+.It Fl D
+Set the inode size.
+Defaults to 128, and can also be set to 256 for
+compatibility with ext4.
.It Fl F
Create a file system image in
.Ar special .
@@ -134,7 +139,8 @@ Select the filesystem-format
.It 0
.Ql GOOD_OLD_REV ;
This option is primarily used to build root file systems that can be
-understood by old or dumb firmwares for bootstrap. (default)
+understood by old or dumb firmwares for bootstrap.
+(default)
.It 1
.Ql DYNAMIC_REV ;
Various extended (and sometimes incompatible) features are enabled
Index: sbin/newfs_ext2fs/newfs_ext2fs.c
===================================================================
RCS file: /cvsroot/src/sbin/newfs_ext2fs/newfs_ext2fs.c,v
retrieving revision 1.4
diff -p -u -r1.4 newfs_ext2fs.c
--- sbin/newfs_ext2fs/newfs_ext2fs.c 20 Jul 2008 01:20:23 -0000 1.4
+++ sbin/newfs_ext2fs/newfs_ext2fs.c 16 Jun 2010 21:29:47 -0000
@@ -54,6 +54,7 @@ __RCSID("$NetBSD$");
#include <sys/mount.h>
#include <ufs/ext2fs/ext2fs.h>
+#include <ufs/ext2fs/ext2fs_dinode.h>
#include <disktab.h>
#include <err.h>
@@ -104,6 +105,7 @@ int verbosity; /* amount of printf() ou
#define DEFAULT_VERBOSITY 3 /* 4 is traditional behavior of newfs(8) */
int64_t fssize; /* file system size */
uint sectorsize; /* bytes/sector */
+uint16_t inodesize = EXT2_REV0_DINODE_SIZE; /* inode size */
uint fsize = 0; /* fragment size */
uint bsize = 0; /* block size */
uint minfree = MINFREE; /* free space threshold */
@@ -133,10 +135,16 @@ main(int argc, char *argv[])
fsi = fso = -1;
Fflag = Iflag = Zflag = 0;
verbosity = -1;
- opstring = "FINO:S:V:Zb:f:i:l:m:n:s:v:";
+ opstring = "D:FINO:S:V:Zb:f:i:l:m:n:s:v:";
byte_sized = 0;
while ((ch = getopt(argc, argv, opstring)) != -1)
switch (ch) {
+ case 'D':
+ inodesize = (uint16_t)strtol(optarg, &s1, 0);
+ if (*s1 || (inodesize != 128 && inodesize != 256))
+ errx(1, "Bad inode size %d "
+ "(only 128 and 256 supported)", inodesize);
+ break;
case 'F':
Fflag = 1;
break;
@@ -449,20 +457,21 @@ strsuftoi64(const char *desc, const char
}
static const char help_strings[] =
- "\t-F \t\tcreate file system image in regular file\n"
- "\t-I \t\tdo not check that the file system type is `Linux Ext2'\n"
- "\t-N \t\tdo not create file system, just print out parameters\n"
- "\t-O N\t\tfilesystem revision: 0 ==> REV0, 1 ==> REV1 (default 0)\n"
- "\t-S secsize\tsector size\n"
- "\t-V verbose\toutput verbosity: 0 ==> none, 4 ==> max\n"
- "\t-Z \t\tpre-zero the image file\n"
"\t-b bsize\tblock size\n"
+ "\t-D inodesize\tsize of an inode in bytes (128 or 256)\n"
+ "\t-F \t\tcreate file system image in regular file\n"
"\t-f fsize\tfragment size\n"
+ "\t-I \t\tdo not check that the file system type is `Linux Ext2'\n"
"\t-i density\tnumber of bytes per inode\n"
"\t-m minfree\tminimum free space %\n"
+ "\t-N \t\tdo not create file system, just print out parameters\n"
"\t-n inodes\tnumber of inodes (overrides -i density)\n"
+ "\t-O N\t\tfilesystem revision: 0 ==> REV0, 1 ==> REV1 (default 0)\n"
+ "\t-S secsize\tsector size\n"
"\t-s fssize\tfile system size (sectors)\n"
- "\t-v volname\text2fs volume name\n";
+ "\t-V verbose\toutput verbosity: 0 ==> none, 4 ==> max\n"
+ "\t-v volname\text2fs volume name\n"
+ "\t-Z \t\tpre-zero the image file\n";
static void
usage(void)
Index: sys/lib/libsa/ext2fs.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/ext2fs.c,v
retrieving revision 1.4
diff -p -u -r1.4 ext2fs.c
--- sys/lib/libsa/ext2fs.c 2 Dec 2007 06:47:43 -0000 1.4
+++ sys/lib/libsa/ext2fs.c 16 Jun 2010 21:29:47 -0000
@@ -189,8 +189,9 @@ read_inode(ino32_t inumber, struct open_
if (rsize != fs->e2fs_bsize)
return EIO;
- dip = (struct ext2fs_dinode *)buf;
- e2fs_iload(&dip[ino_to_fsbo(fs, inumber)], &fp->f_di);
+ dip = (struct ext2fs_dinode *)(buf +
+ EXT2_DINODE_SIZE(fs) * ino_to_fsbo(fs, inumber));
+ e2fs_iload(dip, &fp->f_di);
/*
* Clear out the old buffers
@@ -431,7 +432,7 @@ read_sblock(struct open_file *f, struct
if (ext2fs.e2fs_rev > E2FS_REV1 ||
(ext2fs.e2fs_rev == E2FS_REV1 &&
(ext2fs.e2fs_first_ino != EXT2_FIRSTINO ||
- ext2fs.e2fs_inode_size != EXT2_DINODE_SIZE ||
+ (ext2fs.e2fs_inode_size != 128 && ext2fs.e2fs_inode_size != 256) ||
ext2fs.e2fs_features_incompat & ~EXT2F_INCOMPAT_SUPP))) {
return ENODEV;
}
@@ -449,7 +450,7 @@ read_sblock(struct open_file *f, struct
fs->e2fs_bmask = ~fs->e2fs_qbmask;
fs->e2fs_ngdb =
howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd));
- fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE;
+ fs->e2fs_ipb = fs->e2fs_bsize / ext2fs.e2fs_inode_size;
fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb;
return 0;
Index: sys/ufs/ext2fs/ext2fs_dinode.h
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_dinode.h,v
retrieving revision 1.16.28.1
diff -p -u -r1.16.28.1 ext2fs_dinode.h
--- sys/ufs/ext2fs/ext2fs_dinode.h 29 Nov 2008 23:10:18 -0000
1.16.28.1
+++ sys/ufs/ext2fs/ext2fs_dinode.h 16 Jun 2010 21:29:47 -0000
@@ -154,7 +154,10 @@ struct ext2fs_dinode {
#define EXT2_NODUMP 0x00000040 /* do not dump file */
/* Size of on-disk inode. */
-#define EXT2_DINODE_SIZE (sizeof(struct ext2fs_dinode)) /* 128
*/
+#define EXT2_REV0_DINODE_SIZE sizeof(struct ext2fs_dinode)
+#define EXT2_DINODE_SIZE(fs) ((fs)->e2fs.e2fs_rev > E2FS_REV0 ? \
+ (fs)->e2fs.e2fs_inode_size : \
+ EXT2_REV0_DINODE_SIZE)
/*
* The e2di_blocks fields may be overlaid with other information for
Index: sys/ufs/ext2fs/ext2fs_inode.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_inode.c,v
retrieving revision 1.66.8.1
diff -p -u -r1.66.8.1 ext2fs_inode.c
--- sys/ufs/ext2fs/ext2fs_inode.c 22 Feb 2010 04:43:46 -0000 1.66.8.1
+++ sys/ufs/ext2fs/ext2fs_inode.c 16 Jun 2010 21:29:47 -0000
@@ -221,7 +221,7 @@ ext2fs_update(struct vnode *vp, const st
}
ip->i_flag &= ~(IN_MODIFIED | IN_ACCESSED);
cp = (char *)bp->b_data +
- (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE);
+ (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE(fs));
e2fs_isave(ip->i_din.e2fs_din, (struct ext2fs_dinode *)cp);
if ((updflags & (UPDATE_WAIT|UPDATE_DIROP)) != 0 &&
(flags & IN_MODIFIED) != 0 &&
Index: sys/ufs/ext2fs/ext2fs_vfsops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_vfsops.c,v
retrieving revision 1.137.6.5
diff -p -u -r1.137.6.5 ext2fs_vfsops.c
--- sys/ufs/ext2fs/ext2fs_vfsops.c 27 Oct 2009 21:41:07 -0000
1.137.6.5
+++ sys/ufs/ext2fs/ext2fs_vfsops.c 16 Jun 2010 21:29:47 -0000
@@ -577,7 +577,7 @@ ext2fs_reload(struct mount *mountp, kaut
fs->e2fs_bmask = ~fs->e2fs_qbmask;
fs->e2fs_ngdb =
howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd));
- fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE;
+ fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE(fs);
fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb;
brelse(bp, 0);
@@ -646,7 +646,7 @@ loop:
break;
}
cp = (char *)bp->b_data +
- (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE);
+ (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE(fs));
e2fs_iload((struct ext2fs_dinode *)cp, ip->i_din.e2fs_din);
ext2fs_set_inode_guid(ip);
brelse(bp, 0);
@@ -696,8 +696,7 @@ ext2fs_mountfs(struct vnode *devvp, stru
ump = NULL;
#ifdef DEBUG_EXT2
- printf("sb size: %d ino size %d\n", sizeof(struct ext2fs),
- EXT2_DINODE_SIZE);
+ printf("ext2 sb size: %d\n", sizeof(struct ext2fs));
#endif
error = bread(devvp, (SBOFF / size), SBSIZE, cred, 0, &bp);
if (error)
@@ -717,6 +716,10 @@ ext2fs_mountfs(struct vnode *devvp, stru
bp = NULL;
m_fs = ump->um_e2fs;
m_fs->e2fs_ronly = ronly;
+
+#ifdef DEBUG_EXT2
+ printf("ext2 ino size %d\n", EXT2_DINODE_SIZE(m_fs));
+#endif
if (ronly == 0) {
if (m_fs->e2fs.e2fs_state == E2FS_ISCLEAN)
m_fs->e2fs.e2fs_state = 0;
@@ -737,7 +740,7 @@ ext2fs_mountfs(struct vnode *devvp, stru
m_fs->e2fs_bmask = ~m_fs->e2fs_qbmask;
m_fs->e2fs_ngdb =
howmany(m_fs->e2fs_ncg, m_fs->e2fs_bsize / sizeof(struct ext2_gd));
- m_fs->e2fs_ipb = m_fs->e2fs_bsize / EXT2_DINODE_SIZE;
+ m_fs->e2fs_ipb = m_fs->e2fs_bsize / EXT2_DINODE_SIZE(m_fs);
m_fs->e2fs_itpg = m_fs->e2fs.e2fs_ipg / m_fs->e2fs_ipb;
m_fs->e2fs_gd = malloc(m_fs->e2fs_ngdb * m_fs->e2fs_bsize,
@@ -1078,7 +1081,7 @@ retry:
*vpp = NULL;
return (error);
}
- cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE);
+ cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE(fs));
ip->i_din.e2fs_din = pool_get(&ext2fs_dinode_pool, PR_WAITOK);
e2fs_iload((struct ext2fs_dinode *)cp, ip->i_din.e2fs_din);
ext2fs_set_inode_guid(ip);
@@ -1260,9 +1263,8 @@ ext2fs_checksb(struct ext2fs *fs, int ro
return (EINVAL); /* XXX needs translation */
}
if (fs2h32(fs->e2fs_rev) > E2FS_REV0) {
- if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO ||
- fs2h16(fs->e2fs_inode_size) != EXT2_DINODE_SIZE) {
- printf("Ext2 fs: unsupported inode size\n");
+ if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO) {
+ printf("Ext2 fs: unsupported first inode position\n");
return (EINVAL); /* XXX needs translation */
}
if (fs2h32(fs->e2fs_features_incompat) &
--------------040308030201050100000304--
Home |
Main Index |
Thread Index |
Old Index