debugfs: Use the hash_version from superblock if a file system is opened The debugfs program's dx_hash command computes the hash for the given filename, taking the hash_seed and hash_version (i.e hash algorithm) as arguments. So the user has to refer to the superblock to get these values used by the filesystem. So if debugfs has an opened file system, use those values from the current file system. [ Fixed patch to avoid crashing when a file system is not opened. --TYT ] Signed-off-by: Srivathsa Dara <srivathsa.d.dara@oracle.com> Link: https://lore.kernel.org/r/20230824065634.2662858-1-srivathsa.d.dara@oracle.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tune2fs: fall back to old get/set fs label on error If we fail to get/open the mount point for get/set fs label ioctl, just fall back to old method and silence the error messages. Fixes: f85b4526f ("tune2fs: implement support for set/get label iocts") Signed-off-by: Li Dongyang <dongyangli@ddn.com> Link: https://lore.kernel.org/r/20230520104329.2402182-1-dongyangli@ddn.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
ext2fs: don't retry discard/zeroout repeatedly Call safe_getenv(UNIX_IO_NOZEROOUT) once when the device is opened and set CHANNEL_FLAG_NOZEROOUT if present instead of getting uid/euid/getenv every time unix_zeroout() is called. For unix_discard() and unix_zeroout() don't continue to call them if the block device doesn't support these operations. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Link: https://lore.kernel.org/r/1683695929-26972-1-git-send-email-adilger@dilger.ca Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tune2fs/fuse2fs/debugfs: save error information during journal replay Saving error information during journal replay, as in the kernel, prevents information loss from making problems difficult to locate. We save these error information until someone uses e2fsck to check for and fix possible errors. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: zhanchengbin <zhanchengbin1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230217100922.588961-3-libaokun1@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: save EXT2_ERROR_FS flag during journal replay When repairing a file system with s_errno missing from the journal superblock but the file system superblock contains the ERROR_FS flag, the ERROR_FS flag on the file system image is overwritten after the journal replay, followed by a reload of the file system data from disk and the ERROR_FS flag in memory is overwritten. Also s_errno is not set and the ERROR_FS flag is not reset. Therefore, when checked later, no forced check is performed, which makes it possible to have some errors hidden in the disk image, which may make it read-only when using the file system. So we save the ERROR_FS flag to the superblock after the journal replay, instead of just relying on the jsb->s_errno to do this. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: zhanchengbin <zhanchengbin1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230217100922.588961-2-libaokun1@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
build: split version and release in configure Update configure.ac to separate Version from Release if there is a '-' in version.h::E2FSPROGS_VERSION (e.g. "1.46.6-rc1"). Otherwise, the '-' in the version can make RPM building unhappy. Simplify the generation of E2FSPROGS_VERESION, E2FSPROGS_DATE and E2FSPROGS_DAY to avoid multiple grep/awk/sed/tr stages. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Link: https://lore.kernel.org/r/1683694677-9366-1-git-send-email-adilger@dilger.ca Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: don't truncate the orphan file inode if it is newly allocated In ext2fs_create_orphan_file(), don't try truncating inode for the orphan file if ext2fs_create_orphan_file() allocated the inode. This avoids problems where the newly allocated inode in the inode table might contain garbage; if the metadata checksum feature is enabled, this will generally result in the function failing with a checksum invalid error, but this can cause mke2fs (which calls ext2fs_create_orphan_file) to fail. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsprogs: modify dumpe2fs to report free block ranges for bigalloc dumpe2fs has never been modified to correctly report block ranges corresponding to free clusters in block allocation bitmaps from bigalloc file systems. Rather than reporting block ranges covering all the blocks in free clusters found in a block bitmap, it either reports just the first block number in a cluster for a single free cluster, or a range beginning with the first block number in the first cluster in a series of free clusters, and ending with the first block number in the last cluster in that series. This behavior causes xfstest shared/298 to fail when run on a bigalloc file system with a 1k block size. The test uses dumpe2fs to collect a list of the blocks freed when files are deleted from a file system. When the test deletes a file containing blocks located after the first block in the last cluster in a series of clusters, dumpe2fs does not report those blocks as free per the test's expectations. Modify dumpe2fs to report full block ranges for free clusters. At the same time, fix a small bug causing unnecessary !in_use() retests while iterating over a block bitmap. Signed-off-by: Eric Whitney <enwlinux@gmail.com> Link: https://lore.kernel.org/r/20230721185506.1020225-1-enwlinux@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian: add missing copyright information When the package-specific copyright information was removed, it resulted in some information being lost. It probably makes sence to have all of the licensing information in a single file, so add it back to the debian/copyright file. Fixes: 76f2e8d11582 ("debian: remove package-specific copyright notices") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
resize2fs: use Direct I/O when reading the superblock for online resizes If the file system is mounted, the superblock can be changing while resize2fs is trying to read the superblock, resulting in checksum failures. One way of avoiding this problem is read the superblock using Direct I/O, since the kernel makes sure that what gets written to disk is self-consistent. Suggested-by: Krister Johansen <kjlx@templeofstupid.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tests: add test for handling an invalid symlink in an inline directory Add a test for the commit "e2fsck: fix handling of a invalid symlink in an inline_data directory" Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: fix handling of a invalid symlink in an inline_data directory If there is an inline directory that contains a directory entry to an invalid symlink, and that invalid symlink is the portion of the inline directory stored in an xattr portion of the inode, this can result in a buffer overrun. When check_dir_block() is handling the in-xattr portion of the inline directory, it sets the buf pointer to the beginning of that part of the inline directory. This results in the scratch buffer passed to e2fsck_process_bad_inode() to incorrect, resulting in a buffer overrun if e2fsck_pass1_check_symlink() needs to read the symlink target (when the symlink is too long to fit in the i_blocks[] space). This commit fixes this by using the original cd->buf instead of buf, since it can get modified when handling inline directories. Fixes: 0ac4b3973f31 ("e2fsck: inspect inline dir data as two directory blocks") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Merge branch 'maint' into next
libsupport: fix function prototype for quota_write_inode() Commit 2d2d799c7261 ("Clean up codes for adding new quota type") changed the second paramter of quota_write_inode() from taking a single quota type to taking a logical OR of (1 << quota_types). The one thing this commit didn't change was the function prototype for quota_write_inode() in the header file from an enum to an unsigned int. Most C compilers don't seem to mind, and omission is mostly harmless. However, mingw64 does issue a warning which gets promoted to an error. Fixes: 2d2d799c7261 ("Clean up codes for adding new quota type") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
ci.yml: test cross-compiling for Android Add jobs that cross-compile e2fsprogs for Android using the Android NDK. These use the autotools-based build system, so they're a bit different from the actual Android builds, but they should still be useful. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>