Commit Graph

6709 Commits

Author SHA1 Message Date
Paulo Antonio Alvarez
d1d44c146a ext2fs: compile the io implementation according to os
In mingw and cygwin, compile the windows_io manager, compile the unix_io
everywhere else.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-03-31 16:09:23 -04:00
Paulo Antonio Alvarez
86b6db9f5a libext2fs: code adaptation to use the Windows IO manager
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-03-31 16:09:14 -04:00
Paulo Antonio Alvarez
d04f34a050 libext2fs: add a Windows implementation of the IO manager
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-03-31 16:08:52 -04:00
Theodore Ts'o
772734c413 resize2fs: close the file system on errors or early exits
When resize2fs exits early, perhaps because of an error, we should
free the file system so that if MMP is in use, the MMP block is reset.
This also releases the memory to avoid memory leak reports.

Addresses-Debian-Bug: #984472
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-03-06 23:54:33 -05:00
Theodore Ts'o
3042900ae8 resize2fs: avoid allocating over the MMP block
When resizing past the point where the reserve inode has reserved
space for the block group descriptors to expand, and resize2fs (in an
offline resize) needs to move the allocation bitmaps and/or inode
table around, it's possible for resize2fs to allocate over the MMP
block, which would be bad.

Prevent this from happening by reserving the MMP block as a file
system metadata block (which it is) in resize2fs's accounting.

Addresses-Debian-Bug: #984472
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-03-06 23:08:12 -05:00
Theodore Ts'o
67f2b54667 Update release notes, etc., for the 1.46.2 release
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-28 21:46:44 -05:00
Theodore Ts'o
d557b9659b libext2fs: fix potential races in unix_io
When unix_io does not use pread/pread64 (which is the case the bounce
buffer is in use, either when Direct I/O is in use or the
IO_FLAG_FORCE_BOUNCE in enabled), there are races between the llseek
and and read or write system calls.  Fix this by using the BOUNCE_MTX
so only one thread is using the file descriptor at a time.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-28 19:33:31 -05:00
Theodore Ts'o
e1af249aba libext2s: fix unix_io with IO_FLAG_FORCE_BOUNCE flag set
The bounce read/write code would crash with a floating point exception
if alignment is set to 0.

Fixes: c001596110 ("libext2fs: fix unix_io's Direct I/O support")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-28 09:27:27 -05:00
Antonio Ceballos
8895443d25 po: update es.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-27 10:24:06 -05:00
Theodore Ts'o
c001596110 libext2fs: fix unix_io's Direct I/O support
The previous Direct I/O support worked on HDD's with 512 byte logical
sector sizes, and on FreeBSD which required 4k aligned memory buffers.
However, it was incomplete and was not correctly working on HDD's with
4k logical sector sizes (aka Advanced Format Disks).

Based on a patch from Alexey Lyashkov <alexey.lyashkov@hpe.com> but
rewritten to work with the latest e2fsprogs and to minimize changes to
make it easier to review.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reported-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
2021-02-26 18:01:41 -05:00
Theodore Ts'o
c176c240cb iscan: fix the test program iscan so it builds again
The iscan program program isn't built by default, and was relying on
e2fsck's util.c, so it had suffered bitrot as e2fsck/util.c had
evolved.  Fix it so that iscan builds correct.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-26 17:18:48 -05:00
Lukas Czerner
76a6c8788c mmp: do not use O_DIRECT when working with regular file
Currently the mmp block is read using O_DIRECT to avoid any caching that
may be done by the VM. However when working with regular files this
creates alignment issues when the device of the host file system has
sector size larger than the blocksize of the file system in the file
we're working with.

This can be reproduced with t_mmp_fail test when run on the device with
4k sector size because the mke2fs fails when trying to read the mmp
block.

Fix it by disabling O_DIRECT when working with regular files. I don't
think there is any risk of doing so since the file system layer, unlike
shared block device, should guarantee cache consistency.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-25 23:55:00 -05:00
Theodore Ts'o
bb2349c518 resize2fs: prevent block bitmap warnings when doing extreme fs expansions
This commit fixes a bug where if a small file system is resized to
ridiculous sizes, such that the size of the resized block group
descriptor blocks exceed the original file system, and this would
result in resize2fs triggering a large number of scary warning
messages:

   Illegal block number passed to ext2fs_test_block_bitmap #12440
   for block bitmap for broken.img

This can be replicated via:

   ./misc/mke2fs broken.img -b 1024 -T default
   truncate -s +1500G broken.img
   ./resize/resize2fs broken.img

Fortunately, aside from triggering these warning messages, the bug had
no other bad effects.

https://github.com/tytso/e2fsprogs/issues/60

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-25 21:40:27 -05:00
Theodore Ts'o
37c2008f13 debugfs: fix rdump and ls to handle uids and gids > 65536 correctly
https://github.com/tytso/e2fsprogs/issues/63

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-25 17:26:07 -05:00
Theodore Ts'o
d6d69857e7 Remove superfluous break statements
https://github.com/tytso/e2fsprogs/pull/45
https://github.com/tytso/e2fsprogs/pull/46

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-25 12:39:01 -05:00
Lennart Poettering
1f4a5aba59 chattr/lsattr: expose FS_NOCOMP_FL (aka EXT2_NOCOMPR_FL)
This adds support for setting/querying the FS_NOCOMP_FL/EXT2_NOCOMPR_FL
file flag to chattr/lsattr. I picked the character "m" because it was
so far unused and all other characters that were more obvious candidates
were already taken.

The flag is available on btrfs, and with this patch it is possible to
manage it correctly.

Signed-off-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-25 12:34:40 -05:00
Zhiqiang Liu
989a418969 debugfs: fix memory leak problem in read_list()
In read_list func, if strtoull() fails in while loop,
we will return the error code directly. Then, memory of
variable lst will be leaked without setting to *list.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: linfeilong <linfeilong@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-25 12:02:24 -05:00
Theodore Ts'o
ed907b1df2 libe2p: remove nested #ifdefs in fgetflags.c and fsetflags.c
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-24 00:08:07 -05:00
Theodore Ts'o
7e8d22814c debugfs: fix file descriptor leak on error path in do_logdump()
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 23:57:10 -05:00
Theodore Ts'o
4537f8aa80 misc/Makefile.in: add rules to build static versions of lsattr and chattr
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 22:03:59 -05:00
Theodore Ts'o
40ea4628ba libe2p: skip unneeded lstat(2) in fgetflags() and fsetflags()
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 21:25:46 -05:00
Theodore Ts'o
7fc56dd147 debugfs: fix uninitialized variable es in do_logdump()
Fixes: d96064e982 ("debugfs: simplify the do_logdump() function")

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 20:58:31 -05:00
Theodore Ts'o
d96064e982 debugfs: simplify the do_logdump() function
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 16:19:00 -05:00
Theodore Ts'o
03130cc27f Add checks for fs->blocksize == 0 which could cause some crashes
This should never happeb, but some checks is useful, and also fixes
some Coverity warnings.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 16:02:42 -05:00
Theodore Ts'o
61ec4fba1d e2fsck: fix miscellaneous clang warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 13:03:37 -05:00
Harshad Shirwadkar
5ba3e1644c e2fsck: initialize variable before first use in fast commit replay
Initialize ext2fs_ex variable in ext4_fc_replay_scan() before first
use.  Also make sure ext2fs_decode_extent() completely overwrites the
extent structure passed to it as argument to prevent potential future
bugs for the users of the function.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 12:58:16 -05:00
Harshad Shirwadkar
11797844f4 e2fsck: add fallthrough comment in fc replay switch case
During fast commit replay scan phase, in ext4_fc_replay_scan(), we
want to fallthrough in switch case for EXT4_FC_TAG_ADD_RANGE case. Add
a comment for that.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 12:58:03 -05:00
Harshad Shirwadkar
c5ff455e42 ext2fs: don't ignore return value in ext2fs_count_blocks
Don't ignore return value of ext2fs_get_array() in
ext2fs_count_blocks().

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 12:58:03 -05:00
Harshad Shirwadkar
1e616535bc e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree
Don't ignore return values of library function calls in
e2fsck_rewrite_extent_tree.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 12:58:03 -05:00
Theodore Ts'o
1dba260cef create_inode: fix potential file descriptor leak on an error path
Addresses-Coverity-Bug: 1473307
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-23 12:56:01 -05:00
Andreas Dilger
bd36e7d14f misc: replace remaining loff_t with ext2_loff_t
Replace the remaining loff_t uses with ext2_loff_t, as
was done in patch 1df6a4555, since loff_t is a GCC'ism
and is not portable.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-22 21:53:53 -05:00
Akatsuki Rui
da3b6c27d2 chattr.1: improve attributes description to btrfs
- c: for btrfs, compression are conflicts with nodatacow and nodatasum
- C: for btrfs, nodatacow is conflict with compression

ref:
- https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs(5)#MOUNT_OPTIONS
- https://www.spinics.net/lists/linux-btrfs/msg103219.html

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-22 11:42:38 -05:00
Earl Chew
bc50f5abd7 create_inode: Find subdirectory in do_write_internal
Follow the example in do_mkdir_internal, and do_symlink_internal,
and find the correct parent directory if the destination
is not just a plain basename.

https://github.com/tytso/e2fsprogs/issues/61

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-22 11:27:14 -05:00
Theodore Ts'o
ea82add307 debugfs: fix dump_metadata_block() for block sizes > 8192
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-16 00:30:24 -05:00
Theodore Ts'o
71f9bf7b08 libext2fs: fix crash when ext2fs_mmp_stop() is called before MMP is initialized
The fatal_error() function in e2fsck can call ext2fs_mmp_stop() on a
file system where MMP hasn't yet been initialized.  When that happens,
instead of crashing, have ext2fs_mmp_stop() return success, since mmp
doesn't need to be stopped if it hasn't even been initialized yet.

Addresses-Debian-Bug: #696609
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-14 23:51:45 -05:00
Theodore Ts'o
e3a13a47e6 tune2fs: teach tune2fs to use a random value for "-c random"
Addresses-Debian-Bug: #926293
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-14 10:37:00 -05:00
Theodore Ts'o
ff9b039b1f debugfs: clamp journal s_maxlen value when dumping the journal log
Addresses-Coverity-Bug: 1432478
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-13 11:54:58 -05:00
Theodore Ts'o
28e22540e2 debugfs: fix logdump on file systems with block sizes > 8192
Addresses-Coverity-Bug: 1472879
Addresses-Coverity-Bug: 1472880
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-13 10:35:50 -05:00
Theodore Ts'o
462c424500 debugfs: fix memory allocation failures when parsing journal_write arguments
Fix double-free issues when parsing an invalid journal_write command,
such as: "journal_write -b 12 -b BAD -b 42".

Addresses-Coverity-Bug: 1464571
Addresses-Coverity-Bug: 1464575
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-12 21:43:00 -05:00
Theodore Ts'o
eef68a593f debugfs: fix header checks in logdump
Fixes: bd9ac48c92 ("debugfs: add journal header checks in logdump")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-12 16:50:07 -05:00
Theodore Ts'o
4d8169ad2a e2fsck: fix error code return in e2fsck_read_extents()
Addresses-Coverity-Bug: 1472586
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-12 15:12:42 -05:00
Theodore Ts'o
1b25ea248c libext2fs: fix incorrect error code return in ext2fs_add_jounral_inode3()
Addresses-Coverity-Bug: 1472255
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-12 15:10:11 -05:00
Theodore Ts'o
bd9ac48c92 debugfs: add journal header checks in logdump
Addresses-Coverity-Bug: 1431466
Addresses-Coverity-Bug: 1432478
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-12 12:04:21 -05:00
Theodore Ts'o
10f9b11b76 badblocks: add error checking for command-line arguments for -b and -c
Also remove a dead assignment (the value of try is overwritten after
the continue statement).

Addresses-Coverity-Bug: 1297515
Addresses-Coverity-Bug: 1464573
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-12 11:53:23 -05:00
Theodore Ts'o
46fcf7087b ext2_fs.h: use the ext2fs_has_feature_64bits() instead of open coded check
This makes the code a bit cleaner and fixes a false positive warning by
Coverity.  (CID #1464576)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-12 00:10:06 -05:00
Theodore Ts'o
ea41284998 e2fsck: add error checking for ext2fs_extent_get_info()
This function can't actually fail today, but in the future it could
return an error, so it's better to add the appropriate error check.

Addresses-Coverity-Bug: #1464579
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-11 23:47:32 -05:00
Theodore Ts'o
33b9a60c36 Fix clang warnings on architectures with a 64-bit long
On most systems where we compile e2fsprogs, the u64 type is an
unsigned long long.  However, there are platforms (such as the
PowerPC) where a long 64-bits and so u64 is typedef'ed to be unsigned
long instead of a unsigned long long.  Fix this by using explicit
casts in printf statements.  For scanf calls, we need to receive the
value into a unsigned long long, and then assign it to a u64, after
doing range checks.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-11 10:55:21 -05:00
Theodore Ts'o
fb874e6ff4 mke2fs: fix resource leak on error path when creating inodes
Addresses-Coverity-Bug: 1472856
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-11 10:45:13 -05:00
Theodore Ts'o
b79f56ce5d tests: fix environmental dependency in m_rootdir_acl
The test script had a dependency on the group id for the "adm" group
being 4.  Fixed by hard-coding the group id for the default acl for
the acl_dir directory.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-10 11:12:49 -05:00
Theodore Ts'o
df0fe7c9a3 Update release notes, etc., for the 1.46.1 release
(Also update some inaccuracies in the 1.46.0 release.)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-09 18:36:32 -05:00