diff options
author | pfg <pfg@FreeBSD.org> | 2013-08-13 15:40:43 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2013-08-13 15:40:43 +0000 |
commit | 1d7e5a040e9e45c0417e66c77735c9dd9fad8ee1 (patch) | |
tree | b9f3dee80edb10d7fdf255006fdc5f23c5e588ba /sys/fs/ext2fs/ext2_inode.c | |
parent | 33afc0388b6fdde2fe8879b8589ed3dfee555904 (diff) | |
download | FreeBSD-src-1d7e5a040e9e45c0417e66c77735c9dd9fad8ee1.zip FreeBSD-src-1d7e5a040e9e45c0417e66c77735c9dd9fad8ee1.tar.gz |
Define ext2fs local types and use them.
Add definitions for e2fs_daddr_t, e4fs_daddr_t in addition
to the already existing e2fs_lbn_t and adjust them for ext4.
Other than making the code more readable these changes should
fix problems related to big filesystems.
Setting the proper types can be tricky so the process was
helped by looking at UFS. In our implementation, logical block
numbers can be negative and the code depends on it. In ext2,
block numbers are unsigned so it is convenient to keep
e2fs_daddr_t unsigned and use the complete 32 bits. In the
case of e4fs_daddr_t, while the value should be unsigned, for
ext4 we only need to support 48 bits so preserving an extra
bit from the sign is not an issue.
While here also drop the ext2_setblock() prototype that was
never used.
Discussed with: mckusick, bde
MFC after: 3 weeks
Diffstat (limited to 'sys/fs/ext2fs/ext2_inode.c')
-rw-r--r-- | sys/fs/ext2fs/ext2_inode.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/fs/ext2fs/ext2_inode.c b/sys/fs/ext2fs/ext2_inode.c index d1e872c..11180f0 100644 --- a/sys/fs/ext2fs/ext2_inode.c +++ b/sys/fs/ext2fs/ext2_inode.c @@ -54,8 +54,8 @@ #include <fs/ext2fs/fs.h> #include <fs/ext2fs/ext2_extern.h> -static int ext2_indirtrunc(struct inode *, int32_t, int32_t, int32_t, int, - long *); +static int ext2_indirtrunc(struct inode *, daddr_t, daddr_t, + daddr_t, int, e4fs_daddr_t *); /* * Update the access, modified, and inode change times as specified by the @@ -119,7 +119,7 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred, struct m_ext2fs *fs; struct buf *bp; int offset, size, level; - long count, nblocks, blocksreleased = 0; + e4fs_daddr_t count, nblocks, blocksreleased = 0; int error, i, allerror; off_t osize; @@ -356,16 +356,16 @@ done: */ static int -ext2_indirtrunc(struct inode *ip, int32_t lbn, int32_t dbn, int32_t lastbn, - int level, long *countp) +ext2_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn, + daddr_t lastbn, int level, e4fs_daddr_t *countp) { struct buf *bp; struct m_ext2fs *fs = ip->i_e2fs; struct vnode *vp; - int32_t *bap, *copy, nb, nlbn, last; - long blkcount, factor; - int i, nblocks, blocksreleased = 0; - int error = 0, allerror = 0; + e2fs_daddr_t *bap, *copy; + int i, nblocks, error = 0, allerror = 0; + e2fs_lbn_t nb, nlbn, last; + e4fs_daddr_t blkcount, factor, blocksreleased = 0; /* * Calculate index in current block of last @@ -405,11 +405,11 @@ ext2_indirtrunc(struct inode *ip, int32_t lbn, int32_t dbn, int32_t lastbn, return (error); } - bap = (int32_t *)bp->b_data; + bap = (e2fs_daddr_t *)bp->b_data; copy = malloc(fs->e2fs_bsize, M_TEMP, M_WAITOK); bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->e2fs_bsize); bzero((caddr_t)&bap[last + 1], - (u_int)(NINDIR(fs) - (last + 1)) * sizeof(int32_t)); + (NINDIR(fs) - (last + 1)) * sizeof(e2fs_daddr_t)); if (last == -1) bp->b_flags |= B_INVAL; if (DOINGASYNC(vp)) { |