Upendra [Thu, 1 Mar 2018 08:15:48 +0000 (17:15 +0900)]
AOSP: blkid: Correct the label name for exfat
Volume label name is 16 bit unicode string according to spec.
Currently blkid labels the device without converting it to
utf-8 chars due to which incorrect label is displayed.
Theodore Ts'o [Sat, 18 Aug 2018 15:19:25 +0000 (11:19 -0400)]
Drop subset tarball and replace it with "configure --enable-subset"
There's no point creating two separate tarfiles. It's not clear
anyone was actually using the subset tarball --- and if they are, they
can replace it by the full source distribution and using the
--enable-subset option.
Theodore Ts'o [Sat, 18 Aug 2018 13:55:26 +0000 (09:55 -0400)]
Remove obsolete files from the repository
They are removed when we generate the tarball, and they serve no
useful purpose, so let's remove them. This will be help us to create
the tarball using git archive more easily.
Theodore Ts'o [Sat, 18 Aug 2018 04:06:40 +0000 (00:06 -0400)]
gen-tarball: handle symlinks correctly in the created the tar file
Now that we use a symlink for the top-level RELEASE-NOTES file, the
previous strategy of using a symlink to force the prefix in the tar
file and then using tar -h won't work. So change how we generate the
tar file to take advantage of GNU tar's --transform option.
Lukas Czerner [Wed, 8 Aug 2018 11:52:56 +0000 (13:52 +0200)]
e2fsck: remove resize inode if both resize_inode and meta_bg are enabled
Previous e2fsprogs versions allowed to create a file system with both
resize_inode and meta_bg enabled. This was fixed by upstream commit 42e77d5d ("libext2fs: don't create filesystems with meta_bg and resize_inode")
However e2fsck still does not recognize the conflict and will attempt to
clear and recreate resize_inode if it's corrupted due to this incompatible
feature combination, though it will create it in the same wrong layout.
Fix it by teaching e2fsck to recognize resize_inode and meta_bg
conflict and fixing it by disabling and clearing resize inode.
David Anderson [Thu, 12 Jul 2018 23:55:08 +0000 (16:55 -0700)]
AOSP: Update Android.bp files.
debugfs now links to a new libext2_support library, which only includes
cstring.c (Android separates other pieces of libsupport into separate
libraries).
Jaco Kroon [Thu, 2 Aug 2018 18:06:46 +0000 (20:06 +0200)]
debugfs: fix ncheck so it handles hard links correctly
Due to hard links inodes can have multiple names (except for folders),
ncheck should find all of the names (equal to the number of links to the
inodes, directories excepted), not names to the count of the provided
inodes.
Theodore Ts'o [Sun, 5 Aug 2018 01:06:19 +0000 (21:06 -0400)]
debian: stop using symlinks to save space on *-dev packages
Using symlinks to save space on duplicate copies of the
/usr/share/doc/*/changelog.Debian.gz is a bit of a mess, since when
the foo-dev package is removed, the files in /usr/share/doc/libfoo/*
get removed, which means the copyright file gets removed.
So stop doing this altogether, and set up maintainer scripts to clean
up the mess so that the symlinks are removed when the packages get
upgraded.
resize2fs: Remove the real kilobytes rant from man page
Remove the rant about the "real" kilobytes from the man page and just
make it more clear that the suffixed units are representing power-of-two
units as we do in mke2fs man page. Also add terabytes to the list.
Li Dongyang [Sat, 14 Jul 2018 00:42:48 +0000 (18:42 -0600)]
Fix compile error and warnings for old gcc versions
-Wimplicit-fallthrough option was added in gcc7 and
-Wpedantic was added in gcc4.8, while #pragma GCC diagnostic
support was not available until gcc4.6
We got following warnings:
../lib/ext2fs/fiemap.h:35: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
../lib/ext2fs/fiemap.h:36: warning: unknown option after ‘#pragma GCC diagnostic’ kind
../lib/ext2fs/fiemap.h:38: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
and error:
filefrag.c: In function ‘main’:
filefrag.c:577: error: #pragma GCC diagnostic not allowed inside functions
filefrag.c:578: error: #pragma GCC diagnostic not allowed inside functions
filefrag.c:595: error: #pragma GCC diagnostic not allowed inside functions
when compiling latest e2fsprogs with a gcc older than 4.6
e.g. on CentOS 6.9
Signed-off-by: Li Dongyang <dongyangli@ddn.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: call fsync(2) to clear stale errors for a new a unix I/O channel
Newer versions of Linux will retain errors and allow them to be
returned by fsync() or close(), even if the error happened before the
file descriptor was opened. This was to accomodate Postgres's
"interesting" method of error collection.
Unfortunately, for e2fsck, we never want to see stale errors, as this
can cause xfstests (such generic/347) to fail with a false positive.
e2fsck: fix kernel compat functions to use kernel error return conventions
Fix journal_bmap() and sync_blockdev() to use the kernel error
convetions (e.g., -EIO instead of EIO) since they are called by
reovery.c, which is shared userspace / kernel code.
Without this, e2fsck might print an error message like this:
/sbin/e2fsck: Unknown code ____ 251 while recovering journal of /dev/mapper/thin-vol
instead of what it should have printed which was this:
/sbin/e2fsck: Input/output error while recovering journal of /dev/mapper/thin-vol
Andreas Dilger [Mon, 2 Jul 2018 21:06:32 +0000 (17:06 -0400)]
tests: make generated test scripts read-only
Make generated test scripts read-only, to avoid errors by developers
editing the generated test scripts and then having them accidentally
clobbered when "make" is run again.
Change-Id: I60d417b816b7c559b5e05baf4167fc2cf2a871cf Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Fri, 29 Jun 2018 15:35:58 +0000 (11:35 -0400)]
e2fsck: if user declines to fix s_inodes_acount, abort
A recent commit, d74eb7ef: "e2fsck: handle s_inodes_count corruption
properly" tries to fix s_inodes_count. However, if the user declines
to fix the invalid s_inodes_count, e2fsck needs to abort since
otherwise we can crash due to the insane s_inodes_count.
Theodore Ts'o [Thu, 28 Jun 2018 15:10:58 +0000 (11:10 -0400)]
e2fsck: fix hang in readahead code if last block in fs is metadata
If the last block the file system is metadata (very rare, but it can
happen, especially if e2fsck needs to relocate a bitmap block), e2fsck
will hang while trying to do readahead.
Theodore Ts'o [Tue, 26 Jun 2018 19:21:28 +0000 (15:21 -0400)]
tests, mke2fs: add option to suppress xattr copying to fix f_extent_htree
If the developer is running with SELinux enabled on /tmp, the
f_extent_htree regression test will fail because mke2fs by default
copies the extended attributes into the newly created file system (if
a directory hierarchy is specified via the -d option).
Fix this by adding a new extended option to mke2fs, -E no_copy_xattrs
and using it in f_extent_htree's test script.
Theodore Ts'o [Tue, 26 Jun 2018 13:59:19 +0000 (09:59 -0400)]
tests: explicitly force resize2fs's use of lazy (or not)
Resize2fs will not enable lazy_itable if the kernel apparently does
not support that feature. This will cause spurious test failures when
the tests are running on such a system (or where sysfs is not
mounted).
So for the purposes of the regression test we need to force the use of
lazy_itable so that the results conform to expected golden output.
Theodore Ts'o [Tue, 26 Jun 2018 13:02:46 +0000 (09:02 -0400)]
debugfs: fix mknod command on some 32-bit platforms due to LFS
On some platforms the layout of struct stat changes if
_FILE_OFFSET_BITS is set to 64 (which force the use of 64-bit types
and 64-bit variants for system calls such as stat, lseek, etc.)
This is not true (mercifully) on i386, but it is true for the 32-bit
mips platform on Linux. This caused debugfs's mknod command to fail,
since it used struct stat to pass the desired st_mode and st_rdev
fields for the to-be-created device file or FIFO, and this would be
different for create_inode.c and debugfs.c.
Linking together different object files together compiled with
different values of _FILE_OFFSET_BITS is perilous, but for now, let's
fix the specific problem by passing the two fields in the stat
structure that we really care about. This fixes two regression tests
on the 32-bit MIPS platform: d_special_files and r_move_itable.
Theodore Ts'o [Mon, 25 Jun 2018 01:09:59 +0000 (21:09 -0400)]
e2fsck: only retry to open the file system when the superblock is corrupt
Previously we were always retrying the ext2fs_open2() call with the
EXT2_FLAG_IGNORE_SB_ERRORS flag. It only makes sense to do this if
the superblock is reported as corrupt. Otherwise, it's a waste of
time, and results in printing an extra set of error messages to annoy
the user.
Theodore Ts'o [Sun, 24 Jun 2018 22:30:50 +0000 (18:30 -0400)]
tests: fix i_qcow test to properly test e2image's qcow-to-raw functionality
The test script was not properly checking e2image's ability to convert
a qcow2 image back to a raw image. Fix this, and also change it to
use /tmp for the temporary files to speed things up systems with a
ramdisk for /tmp.
Theodore Ts'o [Sun, 24 Jun 2018 04:32:51 +0000 (00:32 -0400)]
e2image: calculate progress rate using floating point
One of the divisions used when caluclate the progress rate was being
done as an integer instead of floating-point operation. This could
cause the end result to not be as accurate as we would like.
This change ensures that the root inode has the correct uid/gid by
calling androidify_inode() on it. It also sets android_configure = 1
when the u/gid mapping is provided.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Google-Bug-Id: 78561186
Google-Bug-Id: 110415537
Test: $ m # With BOARD_SYSTEMIMAGE_UID_MAP=655360 0 5000
$ simg2img ${OUT}/{system.img,system.raw.img}
$ mkdir tmp
$ sudo mount -o loop ${OUT}/system.raw.img tmp
$ stat --format="%u %g" tmp
655360 655360
Change-Id: I842a32b6d64439f9f16b9c6b66de20d4e4418aa8
From AOSP commit: ee3f0f37c34d68aa7a96a36dea369acae312772c
Eric Sandeen [Sat, 23 Jun 2018 22:04:19 +0000 (18:04 -0400)]
libext2fs: remove c99 idiom to fix build
hashmap.c: In function ‘ext2fs_hashmap_free’:
hashmap.c:72:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < h->size; ++i) {
^
hashmap.c:72:2: note: use option -std=c99 or -std=gnu99 to compile your code
make[2]: *** [hashmap.o] Error 1
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Sat, 23 Jun 2018 20:26:41 +0000 (16:26 -0400)]
tests: PAGE_SIZE larger than blocksize with hole
Verify correct operation in the case of writing files with allocated
blocks at the end of the file beyond i_size. This can happen for
PAGE_SIZE > blocksize, or through fallocate().
The f_eofblocks thest checks quite the same situation, but for broken
file system. This test is about correct file.
Theodore Ts'o [Sat, 23 Jun 2018 03:05:49 +0000 (23:05 -0400)]
libext2fs: simplify extent_fallocate()
The goal_distance variable is used in only one place in the
extent_fallocate() function, so set it right before it is used, and
eliminate one assignment of goal_distance which is never used before
it gets overwritten.
Theodore Ts'o [Sat, 23 Jun 2018 02:53:00 +0000 (22:53 -0400)]
libsupport: fix (very potential) NULL dereference
It's a very rare set of circumstances (requiring deleting profile
sections, which e2fsprogs doesn't do) that might trigger a NULL
derference, but fix it for robustness's sake, maybe some day someone
will use that functionality.
Theodore Ts'o [Sat, 23 Jun 2018 02:33:39 +0000 (22:33 -0400)]
libext2fs: fix uninitialized variable dereference in extent_bmap()
The code path was failing to initialize the logial block number hint
in the allocation context. It's not currently being used, but it
might be in the future, and it trips warnings in static code
analyzers.
Shuichi Ihara [Wed, 2 May 2018 04:26:06 +0000 (22:26 -0600)]
misc: add e2mmpstatus utility via dumpe2fs
e2mmpstatus is a Multi-Mount Protection (MMP) helper utility to read
an MMP block to see if it is being updated. It can also output the
latest update time, nodename, and device from the MMP block.
This is useful for HA and other maintenance scripts to determine if
the filesystem is in use on another node, and which node it is.
Signed-off-by: Shuichi Ihara <sihara@ddn.com> Signed-off-by: Li Xi <lixi@ddn.com> Signed-off-by: Wang Shilong <wshilong@ddn.com>
Moved e2mmpstatus checking/dumping code to be part of dumpe2fs rather
than a standalone program, using the "-m" option to check MMP status,
and "-i" to dump info. If dumpe2fs is called as "e2mmpstatus" (and
also "mmpstatus" for compatibility reasons), assume "-m" is specified.
Re-use the existing MMP block handing routines (with some changes) to
check and dump the MMP block, rather than adding duplicate versions.
Modify dumpe2fs to exit with a non-zero error code if there is an
error while reading the filesystem metadata or MMP block, or if
"-m" is used with the "mmp" feature and is in use by another node.
Add a configure check for gethostname() rather than depending on
_BSD_SOURCE or _XOPEN_SOURCE to be set.
Update the f_mmp, m_mmp, m_mmp_bad_csum, and m_mmp_bad_magic tests
to use e2mmpstatus to check and dump the MMP state before and after
e2fsck is run to verify that the tool is working correctly.
Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Fri, 22 Jun 2018 22:08:54 +0000 (18:08 -0400)]
e2fsck: set dir_nlink feature if large dir exists
If there is a directory with more than EXT2_LINK_MAX (65000)
subdirectories, but the DIR_NLINK feature is not set in the
superblock, the feature should be set before continuing on
to change the on-disk directory link count to 1.
While most filesystems should have DIR_NLINK set (it was set
by default for all ext4 filesystems, and all kernels between
2.6.23 and 4.12 automatically set it if the directory link
count grew too large), it is possible that this flag is lost
due to disk corruption or for an upgraded filesystem. We no
longer want kernels to automatically enable features.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=196405 Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Fri, 22 Jun 2018 21:54:50 +0000 (17:54 -0400)]
tests: remove pre-generated f_extent_htree image
The f_extent_htree test depends on the "mke2fs -d" functionality
that did not exist in the maint branch when the patch was landed.
On master this functionality exists and should be used instead of
a pre-generated image. That exercises the "mke2fs -d" functionality
as well as e2fsck better.
[ Fixed to add missing expect.pre.? files --tytso ]
Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Wed, 2 May 2018 04:26:03 +0000 (22:26 -0600)]
tests: don't run sed multiple times on test output
Don't call sed multiple times on the output, and avoid the use
of temporary files, or if possible. It would be convenient to
use "sed -i" to only update the output file once, but this is
not portable to all platforms.
[ Fixed a few test regression failures --tytso ]
Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Wed, 2 May 2018 04:26:02 +0000 (22:26 -0600)]
tests: remove redundant sed filtering
Now that the majority of device name filtering is in filter.sed,
it does not need to be specified explicitly for every test.
Fix the error message printed in debugfs when opening the device
to match that used in other tools. This simplifies the filtering,
and will be helpful if debugfs messages are internationalized.
[ Fixed up some test failures in m_hugefile t_uninit_bg_rm --tytso ]
Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Fri, 22 Jun 2018 15:43:54 +0000 (11:43 -0400)]
tests: clean up $DEBUGFS_EXE usage in scripts
Instead of putting the entire test script under an implicit
"if test -x $DEBUGFS_EXE" conditional (sometimes indenting
the code, and sometimes not), rather check for the reverse
and exit the test script early if $DEBUGFS_EXE is missing.
In some places, tests were running $DEBUGFS_EXE directly,
when they should be running $DEBUGFS (which will run with
Fortify, or other options).
[ Fixed up missing exit statement in f_detect_junk. --tytso ]
Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Fri, 22 Jun 2018 15:42:14 +0000 (11:42 -0400)]
tests: don't use a sparse test file
If the TEST_BITS file is sparse, then the "debugfs -R write"
command may skip holes in the file when copying it into the
test image (depending on whether SEEK_HOLE/SEEK_DATA and/or
FIEMAP are available in the copy_file() function).
This was causing test failures on MacOS in the f_dup_resize
and d_loaddump tests because the TEST_BITS file was the
compiled "debugfs" binary, which apparently has holes when
built on MacOS, and the number of blocks allocated in the
test image was reduced as a result. This caused the expect
output to differ in the summary line and resulted in failure.
Instead of using the debugfs binary for TEST_BITS, generate
a temporary file using /dev/urandom, if available. If not,
fall back to the old behaviour or using debugfs.
[ Fixed up use of non-POSIX /bin/sh constructs and add test_data.tmp to
.gitignore and files to be deleted on a make clean. --tytso ]
Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Fri, 22 Jun 2018 14:46:52 +0000 (10:46 -0400)]
libext2fs: don't corrupt an blkmap64_rb when marking a range of size zero
Calling ext2fs_mark_block_bitmap_range2() with a count of zero can end
up corrupting the red-black block bitmap structure, since a an entry
in the rbtree with zero-length extent can end up causing the
find_first_{zero,set} operations to return incorrect results.
This was found by Adam Buchbinder, who created a fuzzed file system
using which AFL that caused e2fsck to hang in an infinite loop in in
e2fsck's readahead code.