Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libsa Sync with sys/ufs/ext2fs/ext2fs_bswap.c.
details: https://anonhg.NetBSD.org/src/rev/510c255ab904
branches: trunk
changeset: 346817:510c255ab904
user: nonaka <nonaka%NetBSD.org@localhost>
date: Thu Aug 04 06:58:41 2016 +0000
description:
Sync with sys/ufs/ext2fs/ext2fs_bswap.c.
diffstat:
sys/lib/libsa/ext2fs.c | 43 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 38 insertions(+), 5 deletions(-)
diffs (69 lines):
diff -r 4dbc7dcd123d -r 510c255ab904 sys/lib/libsa/ext2fs.c
--- a/sys/lib/libsa/ext2fs.c Thu Aug 04 06:54:47 2016 +0000
+++ b/sys/lib/libsa/ext2fs.c Thu Aug 04 06:58:41 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs.c,v 1.22 2016/08/04 03:16:00 nonaka Exp $ */
+/* $NetBSD: ext2fs.c,v 1.23 2016/08/04 06:58:41 nonaka Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -939,9 +939,13 @@
}
}
-void e2fs_i_bswap(struct ext2fs_dinode *old, struct ext2fs_dinode *new)
+void e2fs_i_bswap(struct ext2fs_dinode *old, struct ext2fs_dinode *new,
+ size_t isize)
{
+ /* preserve non-swapped and unused fields */
+ memcpy(new, old, isize);
+ /* swap what needs to be swapped */
new->e2di_mode = bswap16(old->e2di_mode);
new->e2di_uid = bswap16(old->e2di_uid);
new->e2di_gid = bswap16(old->e2di_gid);
@@ -953,12 +957,41 @@
new->e2di_dtime = bswap32(old->e2di_dtime);
new->e2di_nblock = bswap32(old->e2di_nblock);
new->e2di_flags = bswap32(old->e2di_flags);
+ new->e2di_version = bswap32(old->e2di_version);
new->e2di_gen = bswap32(old->e2di_gen);
new->e2di_facl = bswap32(old->e2di_facl);
new->e2di_dacl = bswap32(old->e2di_dacl);
- new->e2di_obso_faddr = bswap32(old->e2di_obso_faddr);
- memcpy(&new->e2di_blocks[0], &old->e2di_blocks[0],
- (EXT2FS_NDADDR + EXT2FS_NIADDR) * sizeof(uint32_t));
+ new->e2di_nblock_high = bswap16(old->e2di_nblock_high);
+ new->e2di_facl_high = bswap16(old->e2di_facl_high);
+ new->e2di_uid_high = bswap16(old->e2di_uid_high);
+ new->e2di_gid_high = bswap16(old->e2di_gid_high);
+ new->e2di_checksum_low = bswap16(old->e2di_checksum_low);
+
+ /*
+ * Following fields are only supported for inode sizes bigger
+ * than the old ext2 one
+ */
+ if (isize == EXT2_REV0_DINODE_SIZE)
+ return;
+
+ new->e2di_extra_isize = bswap16(old->e2di_extra_isize);
+ new->e2di_checksum_high = bswap16(old->e2di_checksum_high);
+
+ /* Following fields are ext4, might not be actually present */
+ if (EXT2_DINODE_FITS(new, e2di_ctime_extra, isize))
+ new->e2di_ctime_extra = bswap32(old->e2di_ctime_extra);
+ if (EXT2_DINODE_FITS(new, e2di_mtime_extra, isize))
+ new->e2di_mtime_extra = bswap32(old->e2di_mtime_extra);
+ if (EXT2_DINODE_FITS(new, e2di_atime_extra, isize))
+ new->e2di_atime_extra = bswap32(old->e2di_atime_extra);
+ if (EXT2_DINODE_FITS(new, e2di_crtime, isize))
+ new->e2di_crtime = bswap32(old->e2di_crtime);
+ if (EXT2_DINODE_FITS(new, e2di_crtime_extra, isize))
+ new->e2di_crtime_extra = bswap32(old->e2di_crtime_extra);
+ if (EXT2_DINODE_FITS(new, e2di_version_high, isize))
+ new->e2di_version_high = bswap32(old->e2di_version_high);
+ if (EXT2_DINODE_FITS(new, e2di_projid, isize))
+ new->e2di_projid = bswap32(old->e2di_projid);
}
#endif
Home |
Main Index |
Thread Index |
Old Index