1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

ext2fs: make some inode fields match the ext2 spec.

Ext2fs uses unsigned fields in its dinode struct.
FreeBSD can have negative values in some of those
fields and the inode is meant to interact with the
system so we have never respected the unsigned
nature of most of those fields.

Block numbers and the NFS generation number do
not need to be signed so redefine them as
unsigned to better match the on-disk information.

MFC after:	1 week
This commit is contained in:
Pedro F. Giffuni 2013-01-22 18:54:03 +00:00
parent 6f1efb0f4b
commit 1d04725a7a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245820
4 changed files with 11 additions and 9 deletions

View File

@ -169,7 +169,7 @@ ext2_reallocblks(ap)
struct inode *ip;
struct vnode *vp;
struct buf *sbp, *ebp;
int32_t *bap, *sbap, *ebap = 0;
uint32_t *bap, *sbap, *ebap = 0;
struct ext2mount *ump;
struct cluster_save *buflist;
struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;

View File

@ -69,7 +69,7 @@ ext2_balloc(ip, lbn, size, cred, bpp, flags)
struct buf *bp, *nbp;
struct vnode *vp = ITOV(ip);
struct indir indirs[NIADDR + 2];
int32_t newb, *bap, pref;
uint32_t newb, *bap, pref;
int osize, nsize, num, i, error;
*bpp = NULL;

View File

@ -119,7 +119,7 @@ ext2_truncate(vp, length, flags, cred, td)
int32_t lastblock;
struct inode *oip;
int32_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR];
int32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR];
uint32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR];
struct bufobj *bo;
struct m_ext2fs *fs;
struct buf *bp;
@ -342,7 +342,9 @@ ext2_truncate(vp, length, flags, cred, td)
*/
oip->i_size = length;
oip->i_blocks -= blocksreleased;
if (oip->i_blocks < 0) /* sanity */
if (oip->i_blocks > blocksreleased)
oip->i_blocks -= blocksreleased;
else /* sanity */
oip->i_blocks = 0;
oip->i_flag |= IN_CHANGE;
vnode_pager_setsize(ovp, length);

View File

@ -90,11 +90,11 @@ struct inode {
int32_t i_atimensec; /* Last access time. */
int32_t i_ctimensec; /* Last inode change time. */
int32_t i_birthnsec; /* Inode creation time. */
int32_t i_db[NDADDR]; /* Direct disk blocks. */
int32_t i_ib[NIADDR]; /* Indirect disk blocks. */
uint32_t i_db[NDADDR]; /* Direct disk blocks. */
uint32_t i_ib[NIADDR]; /* Indirect disk blocks. */
uint32_t i_flags; /* Status flags (chflags). */
int32_t i_blocks; /* Blocks actually held. */
int32_t i_gen; /* Generation number. */
uint32_t i_blocks; /* Blocks actually held. */
uint32_t i_gen; /* Generation number. */
uint32_t i_uid; /* File owner. */
uint32_t i_gid; /* File group. */
};
@ -162,7 +162,7 @@ struct ufid {
uint16_t ufid_len; /* Length of structure. */
uint16_t ufid_pad; /* Force 32-bit alignment. */
ino_t ufid_ino; /* File number (ino). */
int32_t ufid_gen; /* Generation number. */
uint32_t ufid_gen; /* Generation number. */
};
#endif /* _KERNEL */