Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ext2fs Correct (minor) bogons in filetype option sup...
details: https://anonhg.NetBSD.org/src/rev/2adccbd8b297
branches: trunk
changeset: 481418:2adccbd8b297
user: bouyer <bouyer%NetBSD.org@localhost>
date: Fri Jan 28 16:00:23 2000 +0000
description:
Correct (minor) bogons in filetype option support, and add support
for sparse_super option
diffstat:
sys/ufs/ext2fs/ext2fs.h | 28 ++++++++++++++++++++++++++--
sys/ufs/ext2fs/ext2fs_bswap.c | 14 +++++++-------
sys/ufs/ext2fs/ext2fs_dir.h | 42 +++++++++++++++++++++++++++++++++++++++++-
sys/ufs/ext2fs/ext2fs_lookup.c | 6 +++---
sys/ufs/ext2fs/ext2fs_vfsops.c | 22 +++++++++++++++-------
sys/ufs/ext2fs/ext2fs_vnops.c | 6 +++---
6 files changed, 95 insertions(+), 23 deletions(-)
diffs (232 lines):
diff -r d950ee3972f6 -r 2adccbd8b297 sys/ufs/ext2fs/ext2fs.h
--- a/sys/ufs/ext2fs/ext2fs.h Fri Jan 28 15:52:34 2000 +0000
+++ b/sys/ufs/ext2fs/ext2fs.h Fri Jan 28 16:00:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs.h,v 1.9 2000/01/26 16:21:33 bouyer Exp $ */
+/* $NetBSD: ext2fs.h,v 1.10 2000/01/28 16:00:23 bouyer Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -183,7 +183,7 @@
/* features supported in this implementation */
#define EXT2F_COMPAT_SUPP 0x0000
-#define EXT2F_ROCOMPAT_SUPP 0x0000
+#define EXT2F_ROCOMPAT_SUPP EXT2F_ROCOMPAT_SPARSESUPER
#define EXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE
/*
@@ -213,6 +213,30 @@
};
+
+/*
+ * If the EXT2F_ROCOMPAT_SPARSESUPER flag is set, the cylinder group has a
+ * copy of the super and cylinder group descriptors blocks only if it's
+ * a power of 3, 5 or 7
+ */
+
+static __inline__ int cg_has_sb __P((int)) __attribute__((__unused__));
+static __inline int
+cg_has_sb(i)
+ int i;
+{
+ int a3 ,a5 , a7;
+
+ if (i == 0 || i == 1)
+ return 1;
+ for (a3 = 3, a5 = 5, a7 = 7;
+ a3 <= i || a5 <= i || a7 <= i;
+ a3 *= 3, a5 *= 5, a7 *= 7)
+ if (i == a3 || i == a5 || i == a7)
+ return 1;
+ return 0;
+}
+
/* EXT2FS metadatas are stored in little-endian byte order. These macros
* helps reading theses metadatas
*/
diff -r d950ee3972f6 -r 2adccbd8b297 sys/ufs/ext2fs/ext2fs_bswap.c
--- a/sys/ufs/ext2fs/ext2fs_bswap.c Fri Jan 28 15:52:34 2000 +0000
+++ b/sys/ufs/ext2fs/ext2fs_bswap.c Fri Jan 28 16:00:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_bswap.c,v 1.3 2000/01/26 16:21:33 bouyer Exp $ */
+/* $NetBSD: ext2fs_bswap.c,v 1.4 2000/01/28 16:00:23 bouyer Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -86,12 +86,12 @@
{
int i;
for (i=0; i < (size / sizeof(struct ext2_gd)); i++) {
- new[i].ext2bgd_b_bitmap = bswap32(old[i].ext2bgd_b_bitmap);
- new[i].ext2bgd_i_bitmap = bswap32(old[i].ext2bgd_i_bitmap);
- new[i].ext2bgd_i_tables = bswap32(old[i].ext2bgd_i_tables);
- new[i].ext2bgd_nbfree = bswap16(old[i].ext2bgd_nbfree);
- new[i].ext2bgd_nifree = bswap16(old[i].ext2bgd_nifree);
- new[i].ext2bgd_ndirs = bswap16(old[i].ext2bgd_ndirs);
+ new[i].ext2bgd_b_bitmap = bswap32(old[i].ext2bgd_b_bitmap);
+ new[i].ext2bgd_i_bitmap = bswap32(old[i].ext2bgd_i_bitmap);
+ new[i].ext2bgd_i_tables = bswap32(old[i].ext2bgd_i_tables);
+ new[i].ext2bgd_nbfree = bswap16(old[i].ext2bgd_nbfree);
+ new[i].ext2bgd_nifree = bswap16(old[i].ext2bgd_nifree);
+ new[i].ext2bgd_ndirs = bswap16(old[i].ext2bgd_ndirs);
}
}
diff -r d950ee3972f6 -r 2adccbd8b297 sys/ufs/ext2fs/ext2fs_dir.h
--- a/sys/ufs/ext2fs/ext2fs_dir.h Fri Jan 28 15:52:34 2000 +0000
+++ b/sys/ufs/ext2fs/ext2fs_dir.h Fri Jan 28 16:00:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_dir.h,v 1.3 2000/01/26 16:21:33 bouyer Exp $ */
+/* $NetBSD: ext2fs_dir.h,v 1.4 2000/01/28 16:00:23 bouyer Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -90,6 +90,46 @@
char e2d_name[EXT2FS_MAXNAMLEN];/* name with length <= EXT2FS_MAXNAMLEN */
};
+/* Ext2 directory file types (not the same as FFS. Sigh. */
+#define EXT2_FT_UNKNOWN 0
+#define EXT2_FT_REG_FILE 1
+#define EXT2_FT_DIR 2
+#define EXT2_FT_CHRDEV 3
+#define EXT2_FT_BLKDEV 4
+#define EXT2_FT_FIFO 5
+#define EXT2_FT_SOCK 6
+#define EXT2_FT_SYMLINK 7
+
+#define EXT2_FT_MAX 8
+
+#define E2IFTODT(mode) (((mode) & 0170000) >> 12)
+
+static __inline__ u_int8_t inot2ext2dt __P((u_int16_t))
+ __attribute__((__unused__));
+static __inline__ u_int8_t
+inot2ext2dt(type)
+ u_int16_t type;
+{
+ switch(type) {
+ case E2IFTODT(EXT2_IFIFO):
+ return EXT2_FT_FIFO;
+ case E2IFTODT(EXT2_IFCHR):
+ return EXT2_FT_CHRDEV;
+ case E2IFTODT(EXT2_IFDIR):
+ return EXT2_FT_DIR;
+ case E2IFTODT(EXT2_IFBLK):
+ return EXT2_FT_BLKDEV;
+ case E2IFTODT(EXT2_IFREG):
+ return EXT2_FT_REG_FILE;
+ case E2IFTODT(EXT2_IFLNK):
+ return EXT2_FT_SYMLINK;
+ case E2IFTODT(EXT2_IFSOCK):
+ return EXT2_FT_SOCK;
+ default:
+ return 0;
+ }
+}
+
/*
* The EXT2FS_DIRSIZ macro gives the minimum record length which will hold
* the directory entryfor a name len "len" (without the terminating null byte).
diff -r d950ee3972f6 -r 2adccbd8b297 sys/ufs/ext2fs/ext2fs_lookup.c
--- a/sys/ufs/ext2fs/ext2fs_lookup.c Fri Jan 28 15:52:34 2000 +0000
+++ b/sys/ufs/ext2fs/ext2fs_lookup.c Fri Jan 28 16:00:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_lookup.c,v 1.13 2000/01/26 16:21:33 bouyer Exp $ */
+/* $NetBSD: ext2fs_lookup.c,v 1.14 2000/01/28 16:00:23 bouyer Exp $ */
/*
* Modified for NetBSD 1.2E
@@ -773,7 +773,7 @@
newdir.e2d_namlen = cnp->cn_namelen;
if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
(ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
- newdir.e2d_type = IFTODT(ip->i_ffs_mode);
+ newdir.e2d_type = inot2ext2dt(IFTODT(ip->i_ffs_mode));
} else {
newdir.e2d_type = 0;
};
@@ -950,7 +950,7 @@
ep->e2d_ino = h2fs32(ip->i_number);
if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
(ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
- ep->e2d_type = IFTODT(ip->i_ffs_mode);
+ ep->e2d_type = inot2ext2dt(IFTODT(ip->i_ffs_mode));
} else {
ep->e2d_type = 0;
}
diff -r d950ee3972f6 -r 2adccbd8b297 sys/ufs/ext2fs/ext2fs_vfsops.c
--- a/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Jan 28 15:52:34 2000 +0000
+++ b/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Jan 28 16:00:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_vfsops.c,v 1.31 2000/01/26 16:21:34 bouyer Exp $ */
+/* $NetBSD: ext2fs_vfsops.c,v 1.32 2000/01/28 16:00:23 bouyer Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -678,6 +678,7 @@
register struct ufsmount *ump;
register struct m_ext2fs *fs;
u_int32_t overhead, overhead_per_group;
+ int i, ngroups;
ump = VFSTOUFS(mp);
fs = ump->um_e2fs;
@@ -693,14 +694,21 @@
/*
* Compute the overhead (FS structures)
*/
- overhead_per_group = 1 /* super block */ +
- fs->e2fs_ngdb +
- 1 /* block bitmap */ +
- 1 /* inode bitmap */ +
- fs->e2fs_itpg;
+ overhead_per_group = 1 /* block bitmap */ +
+ 1 /* inode bitmap */ +
+ fs->e2fs_itpg;
overhead = fs->e2fs.e2fs_first_dblock +
fs->e2fs_ncg * overhead_per_group;
-
+ if (fs->e2fs.e2fs_rev > E2FS_REV0 &&
+ fs->e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_SPARSESUPER) {
+ for (i = 0, ngroups = 0; i < fs->e2fs_ncg; i++) {
+ if (cg_has_sb(i))
+ ngroups++;
+ }
+ } else {
+ ngroups = fs->e2fs_ncg;
+ }
+ overhead += ngroups * (1 + fs->e2fs_ngdb);
sbp->f_bsize = fs->e2fs_bsize;
sbp->f_iosize = fs->e2fs_bsize;
diff -r d950ee3972f6 -r 2adccbd8b297 sys/ufs/ext2fs/ext2fs_vnops.c
--- a/sys/ufs/ext2fs/ext2fs_vnops.c Fri Jan 28 15:52:34 2000 +0000
+++ b/sys/ufs/ext2fs/ext2fs_vnops.c Fri Jan 28 16:00:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_vnops.c,v 1.22 2000/01/26 16:21:34 bouyer Exp $ */
+/* $NetBSD: ext2fs_vnops.c,v 1.23 2000/01/28 16:00:23 bouyer Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -1045,7 +1045,7 @@
dirtemplate.dot_namlen = 1;
if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
(ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
- dirtemplate.dot_type = IFTODT(EXT2_IFDIR);
+ dirtemplate.dot_type = EXT2_FT_DIR;
}
dirtemplate.dot_name[0] = '.';
dirtemplate.dotdot_ino = h2fs32(dp->i_number);
@@ -1053,7 +1053,7 @@
dirtemplate.dotdot_namlen = 2;
if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
(ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
- dirtemplate.dotdot_type = IFTODT(EXT2_IFDIR);
+ dirtemplate.dotdot_type = EXT2_FT_DIR;
}
dirtemplate.dotdot_name[0] = dirtemplate.dotdot_name[1] = '.';
error = vn_rdwr(UIO_WRITE, tvp, (caddr_t)&dirtemplate,
Home |
Main Index |
Thread Index |
Old Index