diff options
author | pfg <pfg@FreeBSD.org> | 2013-02-02 22:23:45 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2013-02-02 22:23:45 +0000 |
commit | e94b41487b15810ca86ef4cf9a1cacddd428846d (patch) | |
tree | fae557b6c70ee080d74d079cff333d22b4435bb8 | |
parent | fb83414a6ee4316b1c8a79da870c9c6e453535a6 (diff) | |
download | FreeBSD-src-e94b41487b15810ca86ef4cf9a1cacddd428846d.zip FreeBSD-src-e94b41487b15810ca86ef4cf9a1cacddd428846d.tar.gz |
ext2fs: general cleanup.
- Remove unused extern declarations in fs.h
- Correct comments in ext2_dir.h
- Several panic() messages showed wrong function names.
- Remove commented out stray line in ext2_alloc.c.
- Remove the unused macro EXT2_BLOCK_SIZE_BITS() and the then
write-only member e2fs_blocksize_bits from struct m_ext2fs.
- Remove the unused macro EXT2_FIRST_INO() and the then write-only
member e2fs_first_inode from struct m_ext2fs.
- Remove EXT2_DESC_PER_BLOCK() and the member e2fs_descpb from
struct m_ext2fs.
- Remove the unused members e2fs_bmask, e2fs_dbpg and
e2fs_mount_opt from struct m_ext2fs
- Correct harmless off-by-one error for fspath in ext2_vfsops.c.
- Remove the unused and broken macros EXT2_ADDR_PER_BLOCK_BITS()
and EXT2_DESC_PER_BLOCK_BITS().
- Remove the !_KERNEL versions of the EXT2_* macros.
Submitted by: Christoph Mallon
MFC after: 2 weeks
-rw-r--r-- | sys/fs/ext2fs/ext2_alloc.c | 9 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2_dir.h | 4 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2_inode.c | 2 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2_lookup.c | 2 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2_vfsops.c | 13 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2fs.h | 45 | ||||
-rw-r--r-- | sys/fs/ext2fs/fs.h | 3 |
7 files changed, 17 insertions, 61 deletions
diff --git a/sys/fs/ext2fs/ext2_alloc.c b/sys/fs/ext2fs/ext2_alloc.c index 0f32795..cafd32d 100644 --- a/sys/fs/ext2fs/ext2_alloc.c +++ b/sys/fs/ext2fs/ext2_alloc.c @@ -242,7 +242,7 @@ ext2_reallocblks(ap) } 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)) @@ -1004,7 +1004,7 @@ ext2_blkfree(ip, bno, size) 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); @@ -1032,7 +1032,6 @@ ext2_vfree(pvp, ino, mode) struct ext2mount *ump; int error, cg; char * ibp; -/* mode_t save_i_mode; */ pip = VTOI(pvp); fs = pip->i_e2fs; @@ -1055,7 +1054,7 @@ ext2_vfree(pvp, ino, mode) 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); @@ -1100,7 +1099,7 @@ ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t bpref) if (loc == NULL) { printf("start = %d, len = %d, fs = %s\n", start, len, fs->e2fs_fsmnt); - panic("ext2fs_alloccg: map corrupted"); + panic("ext2_mapsearch: map corrupted"); /* NOTREACHED */ } } diff --git a/sys/fs/ext2fs/ext2_dir.h b/sys/fs/ext2fs/ext2_dir.h index 5e11166..2bad4cd 100644 --- a/sys/fs/ext2fs/ext2_dir.h +++ b/sys/fs/ext2fs/ext2_dir.h @@ -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 { 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 */ }; diff --git a/sys/fs/ext2fs/ext2_inode.c b/sys/fs/ext2fs/ext2_inode.c index 1195659..fe9b50d 100644 --- a/sys/fs/ext2fs/ext2_inode.c +++ b/sys/fs/ext2fs/ext2_inode.c @@ -311,7 +311,7 @@ ext2_truncate(vp, length, flags, cred, td) 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 diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index c279998..9aadb6a 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -812,7 +812,7 @@ ext2_direnter(ip, dvp, cnp) #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; diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 3f181fd..136f01c 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -127,7 +127,7 @@ ext2_mount(struct mount *mp) 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 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es, 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 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es, 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 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es, 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); @@ -766,7 +763,7 @@ ext2_statfs(struct mount *mp, struct statfs *sbp) ump = VFSTOEXT2(mp); fs = ump->um_e2fs; if (fs->e2fs->e2fs_magic != E2FS_MAGIC) - panic("ext2fs_statfs"); + panic("ext2_statfs"); /* * Compute the overhead (FS structures) diff --git a/sys/fs/ext2fs/ext2fs.h b/sys/fs/ext2fs/ext2fs.h index 5cafc7b..c5a4c15 100644 --- a/sys/fs/ext2fs/ext2fs.h +++ b/sys/fs/ext2fs/ext2fs.h @@ -153,7 +153,6 @@ struct m_ext2fs { 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 @@ struct m_ext2fs { 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 @@ struct csum { #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 @@ struct csum { #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)) - -#endif +#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->e2fs_bpg) #endif /* !_FS_EXT2FS_EXT2FS_H_ */ diff --git a/sys/fs/ext2fs/fs.h b/sys/fs/ext2fs/fs.h index 880c500..7068e79 100644 --- a/sys/fs/ext2fs/fs.h +++ b/sys/fs/ext2fs/fs.h @@ -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_ */ |