New upstream release 1.44.2

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
This commit is contained in:
Lukas Czerner 2018-05-18 13:15:13 +02:00
parent 98ca3072d4
commit 51ff4b6539
6 changed files with 4 additions and 312 deletions

1
.gitignore vendored
View File

@ -32,3 +32,4 @@ e2fsprogs-1.41.12.tar.gz
/e2fsprogs-1.43.9.tar.xz
/e2fsprogs-1.44.0.tar.xz
/e2fsprogs-1.44.1.tar.xz
/e2fsprogs-1.44.2.tar.xz

View File

@ -1,225 +0,0 @@
From eb8758e89150306a0c699ab7ad3d774ca38d0363 Mon Sep 17 00:00:00 2001
From: Lukas Czerner <lczerner@redhat.com>
Date: Thu, 5 Apr 2018 16:02:28 +0200
Subject: [PATCH] e2fsprogs: fix metadata image handling on big endian systems
Currently e2image metadata image handling and creating is completely
broken on big endian systems. It just does not care about endianness at
all. This was uncovered With addition of i_bitmaps test, which is the
first test that actually tests e2image metadata image.
Fix it by making sure that all on-disk metadata that we write and read
to/from the metadata image is properly converted.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
lib/ext2fs/imager.c | 41 +++++++++++++++++++++++++++++++++++++++++
lib/ext2fs/inode.c | 2 +-
lib/ext2fs/openfs.c | 4 ++--
lib/ext2fs/rw_bitmaps.c | 4 ++--
misc/e2image.c | 22 +++++++++++-----------
5 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index efb85b9..7fd06f7 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -195,6 +195,11 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
char *buf, *cp;
ssize_t actual;
errcode_t retval;
+#ifdef WORDS_BIGENDIAN
+ unsigned int groups_per_block;
+ struct ext2_group_desc *gdp;
+ int j;
+#endif
buf = malloc(fs->blocksize);
if (!buf)
@@ -204,7 +209,17 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
* Write out the superblock
*/
memset(buf, 0, fs->blocksize);
+#ifdef WORDS_BIGENDIAN
+ /*
+ * We're writing out superblock so let's convert
+ * it to little endian and then back if needed
+ */
+ ext2fs_swap_super(fs->super);
memcpy(buf, fs->super, SUPERBLOCK_SIZE);
+ ext2fs_swap_super(fs->super);
+#else
+ memcpy(buf, fs->super, SUPERBLOCK_SIZE);
+#endif
actual = write(fd, buf, fs->blocksize);
if (actual == -1) {
retval = errno;
@@ -218,8 +233,34 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
/*
* Now write out the block group descriptors
*/
+
cp = (char *) fs->group_desc;
+
+#ifdef WORDS_BIGENDIAN
+ /*
+ * Convert group descriptors to little endian and back
+ * if needed
+ */
+ groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
+ gdp = (struct ext2_group_desc *) cp;
+ for (j=0; j < groups_per_block*fs->desc_blocks; j++) {
+ gdp = ext2fs_group_desc(fs, fs->group_desc, j);
+ ext2fs_swap_group_desc2(fs, gdp);
+ }
+#endif
+
actual = write(fd, cp, fs->blocksize * fs->desc_blocks);
+
+
+#ifdef WORDS_BIGENDIAN
+ groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
+ gdp = (struct ext2_group_desc *) cp;
+ for (j=0; j < groups_per_block*fs->desc_blocks; j++) {
+ gdp = ext2fs_group_desc(fs, fs->group_desc, j);
+ ext2fs_swap_group_desc2(fs, gdp);
+ }
+#endif
+
if (actual == -1) {
retval = errno;
goto errout;
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index ad01a9f..015cfe4 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -770,7 +770,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
}
if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super);
- block_nr = fs->image_header->offset_inode / fs->blocksize;
+ block_nr = ext2fs_le32_to_cpu(fs->image_header->offset_inode) / fs->blocksize;
block_nr += (ino - 1) / inodes_per_block;
offset = ((ino - 1) % inodes_per_block) *
EXT2_INODE_SIZE(fs->super);
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 385d6e8..532e70f 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -185,10 +185,10 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
fs->image_header);
if (retval)
goto cleanup;
- if (fs->image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE)
+ if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE)
return EXT2_ET_MAGIC_E2IMAGE;
superblock = 1;
- block_size = fs->image_header->fs_blocksize;
+ block_size = ext2fs_le32_to_cpu(fs->image_header->fs_blocksize);
}
/*
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 0b532db..e86bacd 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -253,7 +253,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
ext2fs_free_mem(&buf);
if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
- blk = (fs->image_header->offset_inodemap / fs->blocksize);
+ blk = (ext2fs_le32_to_cpu(fs->image_header->offset_inodemap) / fs->blocksize);
ino_cnt = fs->super->s_inodes_count;
while (inode_bitmap && ino_cnt > 0) {
retval = io_channel_read_blk64(fs->image_io, blk++,
@@ -270,7 +270,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
ino_itr += cnt;
ino_cnt -= cnt;
}
- blk = (fs->image_header->offset_blockmap /
+ blk = (ext2fs_le32_to_cpu(fs->image_header->offset_blockmap) /
fs->blocksize);
blk_cnt = EXT2_GROUPS_TO_CLUSTERS(fs->super,
fs->group_desc_count);
diff --git a/misc/e2image.c b/misc/e2image.c
index 5a18bb4..83ae633 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -240,7 +240,7 @@ static void write_image_file(ext2_filsys fs, int fd)
write_header(fd, NULL, sizeof(struct ext2_image_hdr), fs->blocksize);
memset(&hdr, 0, sizeof(struct ext2_image_hdr));
- hdr.offset_super = seek_relative(fd, 0);
+ hdr.offset_super = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_super_write(fs, fd, 0);
if (retval) {
com_err(program_name, retval, "%s",
@@ -248,7 +248,7 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.offset_inode = seek_relative(fd, 0);
+ hdr.offset_inode = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_inode_write(fs, fd,
(fd != 1) ? IMAGER_FLAG_SPARSEWRITE : 0);
if (retval) {
@@ -257,7 +257,7 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.offset_blockmap = seek_relative(fd, 0);
+ hdr.offset_blockmap = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_bitmap_write(fs, fd, 0);
if (retval) {
com_err(program_name, retval, "%s",
@@ -265,7 +265,7 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.offset_inodemap = seek_relative(fd, 0);
+ hdr.offset_inodemap = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_bitmap_write(fs, fd, IMAGER_FLAG_INODEMAP);
if (retval) {
com_err(program_name, retval, "%s",
@@ -273,23 +273,23 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.magic_number = EXT2_ET_MAGIC_E2IMAGE;
+ hdr.magic_number = ext2fs_cpu_to_le32(EXT2_ET_MAGIC_E2IMAGE);
strcpy(hdr.magic_descriptor, "Ext2 Image 1.0");
gethostname(hdr.fs_hostname, sizeof(hdr.fs_hostname));
strncpy(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name)-1);
hdr.fs_device_name[sizeof(hdr.fs_device_name) - 1] = 0;
- hdr.fs_blocksize = fs->blocksize;
+ hdr.fs_blocksize = ext2fs_cpu_to_le32(fs->blocksize);
if (stat(device_name, &st) == 0)
- hdr.fs_device = st.st_rdev;
+ hdr.fs_device = ext2fs_cpu_to_le32(st.st_rdev);
if (fstat(fd, &st) == 0) {
- hdr.image_device = st.st_dev;
- hdr.image_inode = st.st_ino;
+ hdr.image_device = ext2fs_cpu_to_le32(st.st_dev);
+ hdr.image_inode = ext2fs_cpu_to_le32(st.st_ino);
}
memcpy(hdr.fs_uuid, fs->super->s_uuid, sizeof(hdr.fs_uuid));
- hdr.image_time = time(0);
+ hdr.image_time = ext2fs_cpu_to_le32(time(0));
write_header(fd, &hdr, sizeof(struct ext2_image_hdr), fs->blocksize);
}
@@ -1423,7 +1423,7 @@ static void install_image(char *device, char *image_fn, int type)
ext2fs_rewrite_to_io(fs, io);
- seek_set(fd, fs->image_header->offset_inode);
+ seek_set(fd, ext2fs_le32_to_cpu(fs->image_header->offset_inode));
retval = ext2fs_image_inode_read(fs, fd, 0);
if (retval) {
--
2.7.5

View File

@ -1,35 +0,0 @@
Index: e2fsprogs-1.41.5/e2fsck/super.c
===================================================================
--- e2fsprogs-1.41.5.orig/e2fsck/super.c
+++ e2fsprogs-1.41.5/e2fsck/super.c
@@ -869,7 +869,11 @@ void check_super_block(e2fsck_t ctx)
* unfortunately, we shouldn't ignore it since if it's not set in the
* backup, the extended attributes in the filesystem will be stripped
* away.
+ *
+ * Well, I'm still going that route for now, 'til I do something
+ * better. Full-fsck after a fresh install is just no good. -ERS
*/
+#define FEATURE_COMPAT_IGNORE (EXT2_FEATURE_COMPAT_EXT_ATTR)
#define FEATURE_RO_COMPAT_IGNORE (EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
#define FEATURE_INCOMPAT_IGNORE (EXT3_FEATURE_INCOMPAT_EXTENTS| \
@@ -921,6 +925,9 @@ int check_backup_super_block(e2fsck_t ct
(EXT2_INODE_SIZE(backup_sb) < EXT2_GOOD_OLD_INODE_SIZE))
continue;
+#define SUPER_COMPAT_DIFFERENT(x) \
+ ((fs->super->x & ~FEATURE_COMPAT_IGNORE) != \
+ (backup_sb->x & ~FEATURE_COMPAT_IGNORE))
#define SUPER_INCOMPAT_DIFFERENT(x) \
((fs->super->x & ~FEATURE_INCOMPAT_IGNORE) != \
(backup_sb->x & ~FEATURE_INCOMPAT_IGNORE))
@@ -930,7 +937,7 @@ int check_backup_super_block(e2fsck_t ct
#define SUPER_DIFFERENT(x) \
(fs->super->x != backup_sb->x)
- if (SUPER_DIFFERENT(s_feature_compat) ||
+ if (SUPER_COMPAT_DIFFERENT(s_feature_compat) ||
SUPER_INCOMPAT_DIFFERENT(s_feature_incompat) ||
SUPER_RO_COMPAT_DIFFERENT(s_feature_ro_compat) ||
SUPER_DIFFERENT(s_blocks_count) ||

View File

@ -1,41 +0,0 @@
tests: use mke2fs and debugfs from the build tree
The tests f_bigalloc_badinode and f_bigalloc_orphan_list were not
using the version of mke2fs and debugfs from the build tree, and if
mke2fs and debugfs are not in the user's PATH, these tests would fail.
Fix this.
Reported-by: Somchai Smythe <buraphalinuxserver@xxxxxxxxx>
Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
--
diff --git a/tests/f_bigalloc_badinode/script b/tests/f_bigalloc_badinode/script
index 9113e9c..e58910f 100644
--- a/tests/f_bigalloc_badinode/script
+++ b/tests/f_bigalloc_badinode/script
@@ -6,8 +6,8 @@ TEST_DATA="$test_name.tmp"
dd if=$TEST_BITS of=$TEST_DATA bs=4k count=2 seek=1> /dev/null 2>&1
touch $TMPFILE
-mke2fs -Fq -t ext4 -O bigalloc -C 16384 $TMPFILE 1M > /dev/null 2>&1
-debugfs -w $TMPFILE << EOF > /dev/null 2>&1
+$MKE2FS -Fq -t ext4 -O bigalloc -C 16384 $TMPFILE 1M > /dev/null 2>&1
+$DEBUGFS -w $TMPFILE << EOF > /dev/null 2>&1
write $TEST_DATA testfile
set_inode_field testfile i_mode 0120000
quit
diff --git a/tests/f_bigalloc_orphan_list/script b/tests/f_bigalloc_orphan_list/script
index 1508bf1..af9d753 100644
--- a/tests/f_bigalloc_orphan_list/script
+++ b/tests/f_bigalloc_orphan_list/script
@@ -6,8 +6,8 @@ TEST_DATA="$test_name.tmp"
dd if=$TEST_BITS of=$TEST_DATA bs=28k count=1 > /dev/null 2>&1
touch $TMPFILE
-mke2fs -Fq -t ext4 -O bigalloc $TMPFILE 1M > /dev/null 2>&1
-debugfs -w $TMPFILE << EOF > /dev/null 2>&1
+$MKE2FS -Fq -t ext4 -O bigalloc $TMPFILE 1M > /dev/null 2>&1
+$DEBUGFS -w $TMPFILE << EOF > /dev/null 2>&1
write $TEST_DATA testfile
set_inode_field testfile links_count 0
set_inode_field testfile bmap[0] 0

View File

@ -1,7 +1,7 @@
Summary: Utilities for managing ext2, ext3, and ext4 file systems
Name: e2fsprogs
Version: 1.44.1
Release: 1%{?dist}
Version: 1.44.2
Release: 0%{?dist}
# License tags based on COPYING file distinctions for various components
License: GPLv2
@ -9,9 +9,6 @@ Group: System Environment/Base
Source0: https://www.kernel.org/pub/linux/kernel/people/tytso/%{name}/v%{version}/%{name}-%{version}.tar.xz
Source1: ext2_types-wrapper.h
Patch1: e2fsprogs-1.44.1-tests_use_mke2fs_and_debugfs_from_the_build_tree.patch
Patch2: 0001-e2fsprogs-fix-metadata-image-handling-on-big-endian-.patch
Url: http://e2fsprogs.sourceforge.net/
Requires: e2fsprogs-libs%{?_isa} = %{version}-%{release}
Requires: libcom_err%{?_isa} = %{version}-%{release}
@ -146,11 +143,6 @@ It was originally inspired by the Multics SubSystem library.
%prep
%setup -q
# tests: use mke2fs and debugfs from the build tree
%patch1 -p1
# e2fsprogs: fix metadata image handling on big endian systems
%patch2 -p1
%build
%configure CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" \

View File

@ -1 +1 @@
SHA512 (e2fsprogs-1.44.1.tar.xz) = 88dc96c1420ab7b958c7b49179524f34db4073f865414a121d898ac347fae9182f757314653861f4aa8324bb49f944f0648840c704d124dee22c06ba0406ee55
SHA512 (e2fsprogs-1.44.2.tar.xz) = db34be8c2b606da565a46635d9ed859ccc28921c9a494dd90fbe461a400d0411b0ec6582d3a858adc916d68ec5e835814da798f1cb44710b75fc4efe0145eb90