summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* tests: clean up test namesTheodore Ts'o2023-01-2820-20/+13
| | | | | | Remove trailing newlines and downcase the starting word in the names Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* e2fsck: double cast a pointer to suppress a bogus compiler warning in kfree()Theodore Ts'o2023-01-271-0/+10
| | | | | | | | | | | | | | The C standard is wrong[1] with respect to the function signature of free(), while the kernel's kfree() is correct. Unfortunately, this leads to compiler warnings. Sayeth Dennis Ritchie: "Noalias must go. This is non-negotiable"[2]. Noalias went. The confusion around const, alas, still remains. [1] https://yarchive.net/comp/const.html [2] https://www.lysator.liu.se/c/dmr-on-noalias.html Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* e2fsck: use ext2_ino_t instead of ino_tTheodore Ts'o2023-01-273-11/+11
| | | | | | | | | | | | | | The ino_t type is defined by the system header files, and may be anything from an unsigned int, unsigned long, or an unsigned long long. So where we are referring to an ext2/ext3/ext4 inode number, we should use ext2_ino_t to avoid this ambiguity, especially when passing an inode number to a printf-style function. This was detected via a compiler warning on MacOS, but it's potentially a real bug, since it can cause an error message to print a garbled inode number. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Add a configuration file for GitHub ActionsEric Biggers2023-01-271-0/+116
| | | | | | | | | | | | | | | Add a workflow file for GitHub Actions, with jobs that build and test e2fsprogs on various platforms with various options. The workflow is configured to run on pushes only, since e2fsprogs does not use GitHub pull requests. This will work on any e2fsprogs fork on Github that has GitHub Actions enabled. For example, the results for the testing I've been doing are at https://github.com/ebiggers/e2fsprogs/actions. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* resize2fs: remove unused variable from adjust_superblock()Eric Biggers2023-01-271-4/+0
| | | | | | | | | | | | | | | In adjust_superblock(), the 'group_block' variable is declared and set, but it is never actually used. Remove it. This addresses the following compiler warning with clang -Wall: blk64_t group_block; ^ resize2fs.c:1119:11: warning: variable 'group_block' set but not used [-Wunused-but-set-variable] Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/util.c: enable MinGW alarm() when building for WindowsEric Biggers2023-01-272-2/+5
| | | | | | | | | | | To compile for Windows, this file needs MinGW's implementation of alarm(). To expose that definition, some macros must be defined before including the system headers. This was done in Android.bp, but it was not done in the autotools-based build system. Define these macros in the source file itself so that all build systems work. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/mke2fs: fix a -Wunused-variable warning in PRS()Eric Biggers2023-01-271-4/+6
| | | | | | | This showed up when building for Windows. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/mke2fs: fix Windows buildEric Biggers2023-01-273-12/+9
| | | | | | | | | | unix_io_manager is no longer available on Windows. windows_io_manager must be used instead. Fixes: 86b6db9f5a43 ("libext2fs: code adaptation to use the Windows IO manager") Cc: Paulo Antonio Alvarez <pauloaalvarez@gmail.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/mk_hugefiles: simplify get_partition_start()Eric Biggers2023-01-272-132/+10
| | | | | | | | | | | | | | | | search_sysfs_block() is causing -Wformat-truncation warnings. These could be fixed by checking the return value of snprintf(), instead of doing buggy checks like 'strlen(p_de->d_name) > SYSFS_PATH_LEN - strlen(path) - 32', which has an integer underflow bug. However, the only purpose of search_sysfs_block() is to find the sysfs directory for a block device by device number. That can trivially be done using /sys/dev/block/$major:$minor. So just do that instead. Also make get_partition_start() explicitly Linux-only, as it has never worked anywhere else. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/fuse2fs: avoid error-prone strncpy() patternEric Biggers2023-01-271-2/+3
| | | | | | | | | | | | | 'strncpy(dst, src, strlen(src))' is usually wrong, as it doesn't copy the null terminator. For this reason, it causes a -Wstringop-truncation warning with gcc 8 and later. The code happens to be correct anyway, since the destination buffer is zero-initialized. But to avoid relying on this, let's just copy the terminating null. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/e4defrag: fix -Wstringop-truncation warningsEric Biggers2023-01-271-21/+9
| | | | | | | | | | | | | | | Fix two -Wstringop-truncation warnings in is_ext4() by simplifying how how mnt_type is handled and by using the correct bound for mnt_fsname. Fix a -Wstringop-truncation warning in main() by replacing the fragile pattern 'strncpy(dst, src, strnlen(src, N))', which doesn't null-terminate the destination string, with a standard string copy. (It happened to work anyway because dst happens to be zero-initialized.) These warnings showed up when building with -Wall with gcc 8 or later. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/create_inode: simplify logic in scandir()Eric Biggers2023-01-271-16/+10
| | | | | | | | | | | The control flow in scandir() (only used on Windows) confuses gcc into thinking that *name_list is not always set on success, which causes a -Wmaybe-uninitialized warning in __populate_fs(). As far as I can tell it's a false positive; however, avoid it by cleanly separating the success and failure cases in scandir(). Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/create_inode: fix -Wunused-variable warnings in __populate_fs()Eric Biggers2023-01-271-4/+6
| | | | | | | These showed up when building for Windows. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* e2fsck: use real functions for kernel slab functionsEric Biggers2023-01-271-17/+45
| | | | | | | | | | | | | | | | The macros that e2fsck uses to implement kmalloc et al. use only some of their arguments, so unlike standard function calls, they can cause compiler warnings like: ./../e2fsck/revoke.c:141:8: warning: variable 'gfp_mask' set but not used [-Wunused-but-set-variable] Fix this by providing a proper definition for each function, making sure to match the function prototypes used in the kernel. Remove the kmem_cache_t typedef, as it doesn't exist in the kernel. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/uuid: remove conflicting Windows implementation of gettimeofday()Eric Biggers2023-01-271-21/+0
| | | | | | | | | | | | | | | When building libuuid for Windows with MinGW with the default settings, there is a build error in lib/uuid/gen_uuid.c because the explicit definition of gettimeofday() conflicts with MinGW's declaration of gettimeofday(). gen_uuid.c apparently expects USE_MINGW to be defined to avoid that, but the build system doesn't actually do that. Since native Windows builds of e2fsprogs are currently only supported via MinGW anyway (in particular, Visual Studio is not supported), let's fix this by just removing our own definition of gettimeofday(). Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/support: clean up definition of flags_arrayEric Biggers2023-01-271-30/+30
| | | | | | | | | | | | | | Add braces to address the following compiler warning with gcc -Wall: print_fs_flags.c:24:42: warning: missing braces around initializer [-Wmissing-braces] 24 | static struct flags_name flags_array[] = { | ^ Also add 'const', and add an explicit NULL in the last entry. Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/support: remove unused label in get_devname()Eric Biggers2023-01-271-1/+0
| | | | | | | | | | | | | Address the following compiler warning with gcc -Wall: devname.c: In function ‘get_devname’: devname.c:61:1: warning: label ‘out_strdup’ defined but not used [-Wunused-label] 61 | out_strdup: | ^~~~~~~~~~ Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/ss: fix 'make install' by creating man1dirEric Biggers2023-01-271-2/+3
| | | | | | | | 'make install' does not work because libss tries to install a man page without creating the directory first. Fix this. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/{ext2fs,support}: fix 32-bit Windows buildEric Biggers2023-01-273-9/+9
| | | | | | | | | | | | | | | | | | | _WIN32 is the standard macro to detect (native) Windows, regardless of 32-bit or 64-bit. _WIN64 is for 64-bit Windows only. Use _WIN32 where _WIN64 was incorrectly being used. This fixes several 32-bit Windows build errors, for example this one: plausible.c: In function ‘print_ext2_info’: plausible.c:109:31: error: ‘unix_io_manager’ undeclared (first use in this function); did you mean ‘undo_io_manager’? 109 | unix_io_manager, | ^~~~~~~~~~~~~~~ | undo_io_manager Fixes: 86b6db9f5a43 ("libext2fs: code adaptation to use the Windows IO manager") Cc: Paulo Antonio Alvarez <pauloaalvarez@gmail.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/ext2fs: fix a -Wpointer-sign warning in ext2fs_mmp_start()Eric Biggers2023-01-271-1/+1
| | | | | | | This showed up when building for Windows. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/ext2fs: fix two compiler warnings in windows_io.cEric Biggers2023-01-271-11/+1
| | | | | | | | | | | init_private_data() triggers a -Wstringop-truncation warning, due to a real bug. Fix it. windows_open() has a -Wunused-variable warning because some macOS-specific code was copied there for no reason. Remove it. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/ext2fs: fix a printf format specifier in file_test()Eric Biggers2023-01-271-1/+1
| | | | | | | | size_t should be matched by %zu, not %lu. This fixes a -Wformat warning when building for 32-bit x86. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/ext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics()Eric Biggers2023-01-271-4/+2
| | | | | | | | | | | | | | | | | Since the 'now' variable is only used to calculate 'inuse', and 'inuse' is only used when defined(ENABLE_BMAP_STATS_OPS), it makes sense to guard the declaration and initialization of 'now' and 'inuse' by the same condition, just like the '*_perc' variables in the same function. This addresses the following compiler warning with clang -Wall: double inuse; ^ gen_bitmap64.c:187:9: warning: variable 'inuse' set but not used [-Wunused-but-set-variable] Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/ext2fs: remove 32-bit x86 bitops assemblyEric Biggers2023-01-272-109/+2
| | | | | | | | | | | | | | | | | The EXT2FS_ADDR() macro is causing -Warray-bounds warnings because it (sort of) dereferences past the end of the input array. It's not a "real" dereference, since the result is passed as a memory operand to inline asm. But in the C language sense, it is a dereference. Instead of trying to fix this code, let's consider that libext2fs *only* implements the bit operations in assembly for 32-bit x86, which is rarely used anymore. The fact that compilers have also improved, and no one has implemented these for another architecture, even x86_64, suggests it's not useful either. So, let's just remove this outdated code, which was maybe useful in the 90s, but now just causes problems. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/et: fix "unused variable" warnings when !HAVE_FCNTLEric Biggers2023-01-272-8/+5
| | | | | | | | | In init_debug(), avoid -Wunused-variable and -Wunused-but-set-variable warnings when HAVE_FCNTL is not defined by only declaring 'fd' and 'flags' when HAVE_FCNTL is defined. This affected Windows builds. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/{e2p,ss}: remove manual declarations of errnoEric Biggers2023-01-277-11/+0
| | | | | | | | | | | | | | | | | | | | | | | As per 'man 3 errno': On some ancient systems, <errno.h> was not present or did not declare errno, so that it was necessary to declare errno manually (i.e., extern int errno). **Do not do this**. It long ago ceased to be necessary, and it will cause problems with modern versions of the C library. One of the platforms it causes a problem on is Windows: In file included from fgetversion.c:28: fgetversion.c: In function ‘fgetversion’: fgetversion.c:68:20: warning: ‘_errno’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] 68 | extern int errno; | ^~~~~ Just remove these obsolete manual declarations of errno. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/e2p: fix a -Wunused-variable warning in getflags()Eric Biggers2023-01-271-1/+2
| | | | | | | This affected Windows builds. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup()Eric Biggers2023-01-271-0/+10
| | | | | | | | | | Unfortunately, gcc gets confused by blkid_strndup() and incorrectly thinks the destination string is not being null-terminated. This is part of -Wstringop-truncation, enabled automatically by -Wall in gcc 8 and later. Let's just suppress this warning here. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/blkid: suppress -Wunused-result warning in blkid_flush_cache()Eric Biggers2023-01-271-0/+8
| | | | | | | | | | | When _FORTIFY_SOURCE is defined, glibc annotates link() with the warn_unused_result function attribute. With gcc, that makes '(void) link()' cause a -Wunused-result warning, despite the explicit cast to void. That's annoying, since the use case in lib/blkid/save.c is legitimate (opportunistic backup). So let's suppress this warning. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/blkid: fix -Wunused-variable warning in blkid_get_dev_size()Eric Biggers2023-01-272-2/+1
| | | | | | | | This showed up when building for Windows. It's hard to conditionally define this variable, so use the 'unused' attribute. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/blkid: fix unaligned access to hfs_mdbEric Biggers2023-01-271-6/+4
| | | | | | | | | | | | | | | | | With -Wall, gcc warns: ./probe.c:1209:42: error: taking address of packed member of 'struct hfs_mdb' may result in an unaligned pointer value This seems to be a real unaligned memory access bug, as the offset of the 64-bit value from the start of the buffer is 116, which is not a multiple of 8. Fix it by using memcpy(). Do the same for hfsplus to fix the same warning, though in that case the offset is a multiple of 8 so it was defined behavior. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib/blkid: remove 32-bit x86 byteswap assemblyEric Biggers2023-01-271-43/+0
| | | | | | | | | | | | | libblkid contains 32-bit x86 assembly language implementations of 16-bit and 32-bit byteswaps. However, modern compilers can easily generate the bswap instruction automatically from the corresponding C expression. And no one ever bothered to add assembly for x86_64 or other architectures, anyway. So let's just remove this outdated code, which was maybe useful in the 90s, but is no longer useful. Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* lib, misc: eliminate dependency on WinsockEric Biggers2023-01-276-12/+5
| | | | | | | | | | | | | | Currently Windows builds of e2fsprogs rely on the Windows Socket API (Winsock) to provide htonl() and ntohl(). For this to actually work, though, HAVE_WINSOCK_H needs to be defined, and the binaries need to be linked to -lws2_32. The Android.bp files do this; however, the autotools-based build system does not. Since htonl() and ntohl() are trivial, let's instead just add a file include/mingw/arpa/inet.h with definitions for these. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* config/install-sh: update to latest versionEric Biggers2023-01-271-190/+493
| | | | | | | | | | | | The version of install-sh in the source tree is extremely old and doesn't work when passed multiple path arguments, which breaks 'make install' on macOS. Therefore, delete this file and run 'autoreconf -i' to update it to the latest version. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* configure: regenerateEric Biggers2023-01-272-52/+91
| | | | | | | Run autoreconf. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* configure.ac: automatically add include/mingw/ headersEric Biggers2023-01-271-0/+16
| | | | | | | | | Since the include/mingw/ directory needs to be on the include path when building for Windows with MinGW, add it to INCLUDES automatically, and AC_DEFINE the corresponding HAVE_*_H constants. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* configure.ac: disable tdb by default on WindowsEric Biggers2023-01-271-8/+24
| | | | | | | | The tdb support does not build for Windows, due to the use of various UNIX-isms, so disable it by default when building for Windows. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* configure.ac: only use Windows I/O manager on native WindowsEric Biggers2023-01-271-1/+1
| | | | | | | | | | | | Cygwin and MSYS2 are UNIX-compatible platforms on top of Windows, so they should use the UNIX I/O manager, not the Windows I/O manager. (Note that "cygwin" was misspelled as "cigwin", so the code did not have the intended effect anyway.) Fixes: d1d44c146a5e ("ext2fs: compile the io implementation according to os") Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* mmp: fix wrong comparison in ext2fs_mmp_stoplihaoxiang (F)2023-01-261-1/+1
| | | | | | | | | | | | | | | | | | | | | In our knowledge, ext2fs_mmp_stop use to process the rest of work when mmp will finish. Critically, it must check if the mmp block is not changed. But there exist an error in comparing the mmp and mmp_cmp. Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the superblock of disk and it copy to mmp_buf if mmp_buf is not none and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop pass the no NULL pointer fs->mmp_buf which has possed the mmp info to ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf by fs->mmp_cmp so that loss the meaning of comparing themselves after that and worse yet, couldn't judge whether the struct of mmp has changed. In fact, we only need to modify the parameter to NULL pointer for solving this problem. Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Fix various spelling typosSamanta Navarro2023-01-2626-38/+38
| | | | | | | Typos found with codespell. Signed-off-by: Samanta Navarro <ferivoz@riseup.net> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* e2fsck: optimize clone_file on large devicesLi Dongyang2023-01-252-63/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | When cloning multiply-claimed blocks for an inode, clone_file() uses ext2fs_block_iterate3() to iterate every block calling clone_file_block(). clone_file_block() calls check_if_fs_cluster(), even the block is not on the block_dup_map, which could take a long time on a large device. Only check if it's metadata block when we need to clone it. Test block_metadata_map in check_if_fs_block() and check_if_fs_cluster(), so we don't need to go over each bg every time. The metadata blocks are already marked in the bitmap. Before this patch on a 500TB device with 3 files having 3 multiply-claimed blocks between them, pass1b is stuck for more than 48 hours without progressing, before e2fsck was terminated. After this patch pass1b could finish in 180 seconds. Signed-off-by: Li Dongyang <dongyangli@ddn.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* tune2fs: check return value of ext2fs_mmp_update2 in rewrite_metadata_checksumslihaoxiang (F)2023-01-251-4/+13
| | | | | | | | | | | | | | Tune2fs hasn't consider about the result of executing ext2fs_mmp_update2 when it try to rewrite_metadata_checksums. If the ext2fs_mmp_update2 failed, multi-mount protection couldn't guard there has the only node (i.e. this program) accessing this device in the meantime. We solve this problem to verify the return value of ext2fs_mmp_update2. It terminate rewrite_metadata_checksums and exit immediately if the wrong error code returned. Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* e2scrub_all: fix typo in manpageDarrick J. Wong2023-01-251-1/+1
| | | | | | | | Fix this reported typo. Reported-by: paul kairis <kairis@gmail.com> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* libext2fs: fix ext2fs_compare_generic_bmap logicRitesh Harjani (IBM)2023-01-241-3/+7
| | | | | | | | | | Currently this function was not correctly comparing against the right length of the bitmap. Also when we compare bitarray v/s rbtree bitmap the value returned by ext2fs_test_generic_bmap() could be different in these two implementations. Hence only check against boolean value. Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* debugfs.8: fix typoUlrich Ölmann2023-01-181-1/+1
| | | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* e2fsck: don't allow journal inode to have encrypt flagEric Biggers2023-01-185-1/+51
| | | | | | | | | Since the kernel is being fixed to consider journal inodes with the 'encrypt' flag set to be invalid, also update e2fsck accordingly. Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/fsck.c: Processes may kill other processes.zhanchengbin2023-01-181-0/+2
| | | | | | | | | | | | | | | | | I find a error in misc/fsck.c, if run the fsck -N command, processes don't execute, just show what would be done. However, the pid whose value is -1 is added to the instance_list list in the execute function,if the kill_all function is called later, kill(-1, signum) is executed, Signals are sent to all processes except the number one process and itself. Other processes will be killed if they use the default signal processing function. Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com> Signed-off-by: Lukas Czerner <lczerner@redhat.com> Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* tune2fs: print error message when closing the fs failsLubomir Rintel2023-01-181-1/+9
| | | | | | | | | | | | | | | | | | | I encountered an I/O error on writing the superblock on a drive: ... pwrite64(3, ..., 114688, 97844727808) = 114688 fsync(3) = -1 EIO (Input/output error) close(3) = 0 ... The error was silently ignored, only indicated by the exit value. Let's print an error message. The error message was taken from mke2fs in order to reuse the translations. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* libext2fs: add extra checks to ext2fs_check_mount_point()zhanchengbin2023-01-171-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A pseudo-filesystem, such as tmpfs, can have anything at all in its mnt_fsname entry. Normally, it is just "tmpfs", like this: tmpfs /tmp tmpfs rw,relatime,inode64 0 0 ^^^^^ but in a pathological or malicious case, a system administrator can specify a block device as its mnt_fsname which is the same as some other block device. For example: /dev/loop0 /tmp/test-tmpfs tmpfs rw,relatime,inode64 0 0 ^^^^^^^^^^ /dev/loop0 /tmp/test-mnt ext4 rw,relatime 0 0 In this case, ext2fs_check_mount_point() may erroneously return that the mountpoint for the file system on /dev/loop0 is mounted on /tmp/test-tmpfs, instead of the correct /tmp/test-mnt. This causes problems for resize2fs, since in order to do an online resize, it needs to open the directory where the file system is mounted, and trigger the online resize ioctl. If it opens the incorrect directory, then resize2fs will fail. So we need to add some additional checking to make sure that directory's st_dev matches the block device's st_rdev field. An example shell script which reproduces the problem fixed by this commit is as follows: loop_file=/tmp/foo.img tmpfs_dir=/tmp/test-tmpfs mnt_dir=/tmp/test-mnt mkdir -p $tmpfs_dir $mnt_dir dd if=/dev/zero of=$loop_file bs=1k count=65536 test_dev=$(losetup --show -f $loop_file) mke2fs -t ext4 -F -b 1024 $test_dev 32768 mount -t tmpfs $test_dev $tmpfs_dir # create the evil /proc/mounts entry mount -t ext4 $test_dev $mnt_dir ln -f ${test_dev} ${test_dev}-ln resize2fs ${test_dev}-ln [ Fixed up the corrupted patch and rewrote the commit description to be more clear -- tytso ] Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* tune2fs: fix an error messageLubomir Rintel2022-10-201-1/+1
| | | | | | | | | | | | | | $ tune2fs -O ^has_journal -ff /dev/sdh2 Recovering journal. tune2fs: Unknown code ____ 251 while recovering journal. Before: Please run e2fsck -fy -O. After: Please run e2fsck -fy /dev/sdh2. Note this doesn't fix the "Unknown code" message, just the "Please run e2fsck" one. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>