[Midnightbsd-cvs] src [8783] trunk/sys/fs/ext2fs: ext2fs: general cleanups.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 23:10:49 EDT 2016
Revision: 8783
http://svnweb.midnightbsd.org/src/?rev=8783
Author: laffer1
Date: 2016-09-25 23:10:49 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
ext2fs: general cleanups.
Modified Paths:
--------------
trunk/sys/fs/ext2fs/ext2_alloc.c
trunk/sys/fs/ext2fs/ext2_bmap.c
trunk/sys/fs/ext2fs/ext2_dir.h
trunk/sys/fs/ext2fs/ext2_inode.c
trunk/sys/fs/ext2fs/ext2_lookup.c
trunk/sys/fs/ext2fs/ext2_vfsops.c
trunk/sys/fs/ext2fs/ext2fs.h
trunk/sys/fs/ext2fs/fs.h
Modified: trunk/sys/fs/ext2fs/ext2_alloc.c
===================================================================
--- trunk/sys/fs/ext2fs/ext2_alloc.c 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/ext2_alloc.c 2016-09-26 03:10:49 UTC (rev 8783)
@@ -242,7 +242,7 @@
} else {
#ifdef DIAGNOSTIC
if (start_ap[start_lvl-1].in_lbn == idp->in_lbn)
- panic("ext2_reallocblk: start == end");
+ panic("ext2_reallocblks: start == end");
#endif
ssize = len - (idp->in_off + 1);
if (bread(vp, idp->in_lbn, (int)fs->e2fs_bsize, NOCRED, &ebp))
@@ -1010,7 +1010,7 @@
if (isclr(bbp, bno)) {
printf("block = %lld, fs = %s\n",
(long long)bno, fs->e2fs_fsmnt);
- panic("blkfree: freeing free block");
+ panic("ext2_blkfree: freeing free block");
}
clrbit(bbp, bno);
EXT2_LOCK(ump);
@@ -1038,7 +1038,6 @@
struct ext2mount *ump;
int error, cg;
char * ibp;
-/* mode_t save_i_mode; */
pip = VTOI(pvp);
fs = pip->i_e2fs;
@@ -1061,7 +1060,7 @@
printf("ino = %llu, fs = %s\n",
(unsigned long long)ino, fs->e2fs_fsmnt);
if (fs->e2fs_ronly == 0)
- panic("ifree: freeing free inode");
+ panic("ext2_vfree: freeing free inode");
}
clrbit(ibp, ino);
EXT2_LOCK(ump);
@@ -1105,7 +1104,7 @@
if (loc == 0) {
printf("start = %d, len = %d, fs = %s\n",
start, len, fs->e2fs_fsmnt);
- panic("ext2fs_alloccg: map corrupted");
+ panic("ext2_mapsearch: map corrupted");
/* NOTREACHED */
}
}
Modified: trunk/sys/fs/ext2fs/ext2_bmap.c
===================================================================
--- trunk/sys/fs/ext2fs/ext2_bmap.c 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/ext2_bmap.c 2016-09-26 03:10:49 UTC (rev 8783)
@@ -188,7 +188,7 @@
if ((bp->b_flags & B_CACHE) == 0) {
#ifdef DIAGNOSTIC
if (!daddr)
- panic("ufs_bmaparray: indirect block not in cache");
+ panic("ext2_bmaparray: indirect block not in cache");
#endif
bp->b_blkno = blkptrtodb(ump, daddr);
bp->b_iocmd = BIO_READ;
Modified: trunk/sys/fs/ext2fs/ext2_dir.h
===================================================================
--- trunk/sys/fs/ext2fs/ext2_dir.h 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/ext2_dir.h 2016-09-26 03:10:49 UTC (rev 8783)
@@ -37,7 +37,7 @@
struct ext2fs_direct {
uint32_t e2d_ino; /* inode number of entry */
uint16_t e2d_reclen; /* length of this record */
- uint16_t e2d_namlen; /* length of string in d_name */
+ uint16_t e2d_namlen; /* length of string in e2d_name */
char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */
};
/*
@@ -49,7 +49,7 @@
struct ext2fs_direct_2 {
uint32_t e2d_ino; /* inode number of entry */
uint16_t e2d_reclen; /* length of this record */
- uint8_t e2d_namlen; /* length of string in d_name */
+ uint8_t e2d_namlen; /* length of string in e2d_name */
uint8_t e2d_type; /* file type */
char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */
};
Modified: trunk/sys/fs/ext2fs/ext2_inode.c
===================================================================
--- trunk/sys/fs/ext2fs/ext2_inode.c 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/ext2_inode.c 2016-09-26 03:10:49 UTC (rev 8783)
@@ -311,7 +311,7 @@
oip->i_size = length;
newspace = blksize(fs, oip, lastblock);
if (newspace == 0)
- panic("itrunc: newspace");
+ panic("ext2_truncate: newspace");
if (oldspace - newspace > 0) {
/*
* Block number of space to be free'd is
@@ -398,8 +398,7 @@
*/
vp = ITOV(ip);
bp = getblk(vp, lbn, (int)fs->e2fs_bsize, 0, 0, 0);
- if (bp->b_flags & (B_DONE | B_DELWRI)) {
- } else {
+ if ((bp->b_flags & (B_DONE | B_DELWRI)) == 0) {
bp->b_iocmd = BIO_READ;
if (bp->b_bcount > bp->b_bufsize)
panic("ext2_indirtrunc: bad buffer size");
Modified: trunk/sys/fs/ext2fs/ext2_lookup.c
===================================================================
--- trunk/sys/fs/ext2fs/ext2_lookup.c 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/ext2_lookup.c 2016-09-26 03:10:49 UTC (rev 8783)
@@ -812,7 +812,7 @@
#ifdef DIAGNOSTIC
if ((cnp->cn_flags & SAVENAME) == 0)
- panic("direnter: missing name");
+ panic("ext2_direnter: missing name");
#endif
dp = VTOI(dvp);
newdir.e2d_ino = ip->i_number;
Modified: trunk/sys/fs/ext2fs/ext2_vfsops.c
===================================================================
--- trunk/sys/fs/ext2fs/ext2_vfsops.c 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/ext2_vfsops.c 2016-09-26 03:10:49 UTC (rev 8783)
@@ -127,7 +127,7 @@
vfs_getopt(opts, "fspath", (void **)&path, NULL);
/* Double-check the length of path.. */
- if (strlen(path) >= MAXMNTLEN - 1)
+ if (strlen(path) >= MAXMNTLEN)
return (ENAMETOOLONG);
fspec = NULL;
@@ -318,12 +318,12 @@
int i;
int logic_sb_block = 1; /* XXX for now */
struct buf *bp;
+ uint32_t e2fs_descpb;
fs->e2fs_bsize = EXT2_MIN_BLOCK_SIZE << es->e2fs_log_bsize;
fs->e2fs_bshift = EXT2_MIN_BLOCK_LOG_SIZE + es->e2fs_log_bsize;
fs->e2fs_fsbtodb = es->e2fs_log_bsize + 1;
fs->e2fs_qbmask = fs->e2fs_bsize - 1;
- fs->e2fs_blocksize_bits = es->e2fs_log_bsize + 10;
fs->e2fs_fsize = EXT2_MIN_FRAG_SIZE << es->e2fs_log_fsize;
if (fs->e2fs_fsize)
fs->e2fs_fpb = fs->e2fs_bsize / fs->e2fs_fsize;
@@ -331,10 +331,8 @@
fs->e2fs_fpg = es->e2fs_fpg;
fs->e2fs_ipg = es->e2fs_ipg;
if (es->e2fs_rev == E2FS_REV0) {
- fs->e2fs_first_inode = EXT2_FIRSTINO;
fs->e2fs_isize = E2FS_REV0_INODE_SIZE ;
} else {
- fs->e2fs_first_inode = es->e2fs_first_ino;
fs->e2fs_isize = es->e2fs_inode_size;
/*
@@ -357,12 +355,11 @@
fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs);
fs->e2fs_itpg = fs->e2fs_ipg /fs->e2fs_ipb;
- fs->e2fs_descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
/* s_resuid / s_resgid ? */
fs->e2fs_gcount = (es->e2fs_bcount - es->e2fs_first_dblock +
EXT2_BLOCKS_PER_GROUP(fs) - 1) / EXT2_BLOCKS_PER_GROUP(fs);
- db_count = (fs->e2fs_gcount + EXT2_DESC_PER_BLOCK(fs) - 1) /
- EXT2_DESC_PER_BLOCK(fs);
+ e2fs_descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
+ db_count = (fs->e2fs_gcount + e2fs_descpb - 1) / e2fs_descpb;
fs->e2fs_gdbcount = db_count;
fs->e2fs_gd = malloc(db_count * fs->e2fs_bsize,
M_EXT2MNT, M_WAITOK);
@@ -767,7 +764,7 @@
ump = VFSTOEXT2(mp);
fs = ump->um_e2fs;
if (fs->e2fs->e2fs_magic != E2FS_MAGIC)
- panic("ext2fs_statvfs");
+ panic("ext2_statfs");
/*
* Compute the overhead (FS structures)
Modified: trunk/sys/fs/ext2fs/ext2fs.h
===================================================================
--- trunk/sys/fs/ext2fs/ext2fs.h 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/ext2fs.h 2016-09-26 03:10:49 UTC (rev 8783)
@@ -153,7 +153,6 @@
char e2fs_fmod; /* super block modified flag */
uint32_t e2fs_bsize; /* Block size */
uint32_t e2fs_bshift; /* calc of logical block no */
- int32_t e2fs_bmask; /* calc of block offset */
int32_t e2fs_bpg; /* Number of blocks per group */
int64_t e2fs_qbmask; /* = s_blocksize -1 */
uint32_t e2fs_fsbtodb; /* Shift to get disk block */
@@ -163,14 +162,9 @@
uint32_t e2fs_fsize; /* Size of fragments per block */
uint32_t e2fs_fpb; /* Number of fragments per block */
uint32_t e2fs_fpg; /* Number of fragments per group */
- uint32_t e2fs_dbpg; /* Number of descriptor blocks per group */
- uint32_t e2fs_descpb; /* Number of group descriptors per block */
uint32_t e2fs_gdbcount; /* Number of group descriptors */
uint32_t e2fs_gcount; /* Number of groups */
- uint32_t e2fs_first_inode;/* First inode on fs */
int32_t e2fs_isize; /* Size of inode */
- uint32_t e2fs_mount_opt;
- uint32_t e2fs_blocksize_bits;
uint32_t e2fs_total_dir; /* Total number of directories */
uint8_t *e2fs_contigdirs; /* (u) # of contig. allocated dirs */
char e2fs_wasvalid; /* valid at mount time */
@@ -313,27 +307,9 @@
#define EXT2_MIN_BLOCK_SIZE 1024
#define EXT2_MAX_BLOCK_SIZE 4096
#define EXT2_MIN_BLOCK_LOG_SIZE 10
-#if defined(_KERNEL)
-# define EXT2_BLOCK_SIZE(s) ((s)->e2fs_bsize)
-#else
-# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->e2fs_log_bsize)
-#endif
+#define EXT2_BLOCK_SIZE(s) ((s)->e2fs_bsize)
#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
-#if defined(_KERNEL)
-# define EXT2_BLOCK_SIZE_BITS(s) ((s)->e2fs_blocksize_bits)
-#else
-# define EXT2_BLOCK_SIZE_BITS(s) ((s)->e2fs_log_bsize + 10)
-#endif
-#if defined(_KERNEL)
-#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_addr_per_block_bits)
#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->e2fs_isize)
-#define EXT2_FIRST_INO(s) (EXT2_SB(s)->e2fs_first_inode)
-#else
-#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == E2FS_REV0) ? \
- E2FS_REV0 : (s)->s_inode_size)
-#define EXT2_FIRST_INO(s) (((s)->s_rev_level == E2FS_REV0) ? \
- E2FS_REV0 : (s)->e2fs_first_ino)
-#endif
/*
* Macro-instructions used to manage fragments
@@ -341,25 +317,12 @@
#define EXT2_MIN_FRAG_SIZE 1024
#define EXT2_MAX_FRAG_SIZE 4096
#define EXT2_MIN_FRAG_LOG_SIZE 10
-#if defined(_KERNEL)
-# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->e2fs_fsize)
-# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->e2fs_fpb)
-#else
-# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->e2fs_log_fsize)
-# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
-#endif
+#define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->e2fs_fsize)
+#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->e2fs_fpb)
/*
* Macro-instructions used to manage group descriptors
*/
-#if defined(_KERNEL)
-# define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->e2fs_bpg)
-# define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->e2fs_descpb)
-# define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
-#else
-# define EXT2_BLOCKS_PER_GROUP(s) ((s)->e2fs_bpg)
-# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(struct ext2_gd))
+#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->e2fs_bpg)
-#endif
-
#endif /* !_FS_EXT2FS_EXT2FS_H_ */
Modified: trunk/sys/fs/ext2fs/fs.h
===================================================================
--- trunk/sys/fs/ext2fs/fs.h 2016-09-26 03:09:13 UTC (rev 8782)
+++ trunk/sys/fs/ext2fs/fs.h 2016-09-26 03:10:49 UTC (rev 8783)
@@ -149,7 +149,4 @@
*/
#define NINDIR(fs) (EXT2_ADDR_PER_BLOCK(fs))
-extern int inside[], around[];
-extern u_char *fragtbl[];
-
#endif /* !_FS_EXT2FS_FS_H_ */
More information about the Midnightbsd-cvs
mailing list