Commit Graph

1804 Commits

Author SHA1 Message Date
Theodore Ts'o
53464654bd mke2fs: fix creating a file system image w/o a pre-existing file
The mke2fs program should allow creating a file system image when an
explicit file system size is specified, even if the file doesn't yet
exist.  By deferring the call to check_plausible() in commit
942b00cb9d ("mke2fs: do not warn about a pre-existing partition
table when using a non-zero offset") this behaviour was broken.

Fix this regression by explicitly creating the file if the file system
size is specified.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-02 21:22:41 -04:00
Theodore Ts'o
496669a290 Update release notes, etc., for the 1.46.3 release
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-27 13:38:14 -04:00
Colin Cross
59eed5421c AOSP: Move system_shared_libs into target.bionic clause
Use target.bionic.system_shared_libs when it is used to limit the
default shared libraries (as opposed to remove them completely).
This avoids attempting to add a host dependency on libc when
system_shared_libs is modified to apply to all variants.

Also remove system_shared_libs from static binaries where it has
no effect, and consolidate it into e2fsprogs-defaults.

Bug: 193559105
Test: m checkbuild
Change-Id: I2d447b006afc783f4acd6c1acd93f338a68a01ed
From AOSP commit: 48fa7248112701c30d3cabfb8d3360b2408d6491
2021-07-27 12:31:55 -04:00
Bob Badour
9c897f0103 AOSP: [LSC] Add LOCAL_LICENSE_KINDS to external/e2fsprogs
Added SPDX-license-identifier-0BSD SPDX-license-identifier-Apache-2.0
    SPDX-license-identifier-BSD SPDX-license-identifier-GPL
    SPDX-license-identifier-GPL-2.0 SPDX-license-identifier-LGPL
    SPDX-license-identifier-LGPL-2.0 SPDX-license-identifier-LGPL-2.1
    SPDX-license-identifier-LGPL-3.0 SPDX-license-identifier-MIT
    legacy_notice legacy_unencumbered
to:
  Android.bp

Added SPDX-license-identifier-0BSD SPDX-license-identifier-BSD
    SPDX-license-identifier-GPL SPDX-license-identifier-GPL-2.0
    SPDX-license-identifier-LGPL SPDX-license-identifier-LGPL-2.1
    SPDX-license-identifier-LGPL-3.0 SPDX-license-identifier-MIT
    legacy_unencumbered
to:
  lib/Android.bp

Added SPDX-license-identifier-0BSD SPDX-license-identifier-BSD
    SPDX-license-identifier-GPL-2.0 SPDX-license-identifier-MIT
to:
  lib/et/Android.bp

Added SPDX-license-identifier-0BSD SPDX-license-identifier-MIT
to:
  lib/ss/Android.bp

Added SPDX-license-identifier-Apache-2.0
to:
  contrib/android/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL
to:
  contrib/Android.bp

Added SPDX-license-identifier-BSD
to:
  lib/uuid/Android.bp

Added SPDX-license-identifier-GPL
to:
  resize/Android.bp

Added SPDX-license-identifier-GPL SPDX-license-identifier-GPL-2.0
to:
  debugfs/Android.bp

Added SPDX-license-identifier-GPL SPDX-license-identifier-GPL-2.0
    SPDX-license-identifier-LGPL
to:
  e2fsck/Android.bp

Added SPDX-license-identifier-GPL SPDX-license-identifier-GPL-2.0
    SPDX-license-identifier-LGPL SPDX-license-identifier-LGPL-2.1
    SPDX-license-identifier-LGPL-3.0 legacy_unencumbered
to:
  lib/ext2fs/Android.bp

Added SPDX-license-identifier-GPL SPDX-license-identifier-LGPL
to:
  lib/e2p/Android.bp

Added SPDX-license-identifier-GPL SPDX-license-identifier-LGPL
    SPDX-license-identifier-LGPL-2.1 SPDX-license-identifier-LGPL-3.0
to:
  lib/blkid/Android.bp
  misc/Android.bp

Added SPDX-license-identifier-GPL SPDX-license-identifier-MIT
to:
  lib/support/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I239a04a83f12ba051be911d18f6df4ae77fb3368
From AOSP commit: e86522c572b5715b85889cf8ca1c52a5cc350ca7
2021-07-27 11:14:05 -04:00
Theodore Ts'o
f158f8962e Fix miscellaneous compiler warnings using "make gcc-wall"
Address a number of signed vs. unsigned comparison errors, unused
function parameters, casts which drop const, etc.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-25 23:38:39 -04:00
Theodore Ts'o
942b00cb9d mke2fs: do not warn about a pre-existing partition table when using a non-zero offset
The existing code attempted to avoid warning about a pre-existing file
system with a non-zero offset, but because the offset was not set at
the time of the check, this intention was not actually working.  So
this commit will suppress warnings about pre-existing a partition
table as well as pre-existing file system when there is a non-zero
offset.

Addresses-Debian-Bug: #989612
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-21 16:24:15 -04:00
Theodore Ts'o
6568ba325e mke2fs: only try discarding a single block to test if discard works
Commit d2bfdc7ff1 ("Use punch hole as "discard" on regular files")
added a test to see if the storage device actually supports discard.
The intent was to try discarding the first block but since
io_channel_discard() interprets the offset and count arguments in
blocks, and not bytes, mke2fs was actually discarding the first 16
megabytes (when the block size is 4k).  This is normally not a
problem, since most file systems are larger than that, and requests to
discard beyond the end of the block device are ignored.

However, when creating a small file system as part of a image
containing multiple partitions, the initial test discard can end up
discarding data beyond the file system being created.

Addresses-Debian-Bug: #989630
Reported-by: Josh Triplett <josh@joshtriplett.org>
Fixes: d2bfdc7ff1 ("Use punch hole as "discard" on regular files")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-18 11:05:20 -04:00
Zhiqiang Liu
f9033bd2e8 misc: fix potential segmentation fault problem in scandir()
In scandir(), temp_list[num_dent] is allocated by calling
malloc(), we should check whether malloc() returns NULL before
accessing temp_list[num_dent].

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-15 23:43:37 -04:00
wuguanghao
c3215a5324 zap_sector: fix memory leak
In zap_sector(), need free buf before return,
otherwise it will cause memory leak.

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reviewed-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-15 23:20:39 -04:00
Eric Biggers
beb863f144 Fix -Wunused-variable warnings
Fix all warnings about unused variables that were introduced since
e2fsprogs v1.45.4.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-06 23:11:35 -04:00
Eric Biggers
108f3021a6 mke2fs: use ext2fs_get_device_size2() on all platforms
Since commit e8c858047b ("libext2fs: fix build issue for on
Windows/Cygwin systems"), ext2fs_get_device_size2() is available in
Windows builds of libext2fs.  So there is no need for mke2fs to call
ext2fs_get_device_size() instead.

This fixes a -Wincompatible-pointer-types warning because
ext2fs_get_device_size() was being passed a 'blk64_t *', but it expected
a 'blk_t *'.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-06 22:43:25 -04:00
Jan Kara
0af9a7e9dc tune2fs: update overhead when toggling journal feature
When adding or removing journal from a filesystem, we also need to add /
remove journal blocks from overhead stored in the superblock.  Otherwise
total number of blocks in the filesystem as reported by statfs(2) need
not match reality and could lead to odd results like negative number of
used blocks reported by df(1).

Fixes: 9046b4dfd0ce ("mke2fs: set overhead in super block")
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-07-06 19:55:09 -04:00
Andreas Dilger
612358c193 filefrag: minor usability improvements
Add '-V' to filefrag to print the installed version of the tool.

If '-V' is used twice, print out the list of supported FIEMAP flags.
This can be used to check if filefrag understands a specific feature.

Include FIEMAP in the error message printed when filefrag cannot
get the file layout. Since FIEMAP is commonly available and tried
first, it should also be mentioned in the error message unless it
was requested to only run FIBMAP.

Update filefrag.1.in man page to cover the new -V option.

Fix a formatting error with the recently added '-P' options, and
include '-E' and '-P' in the SYNOPSIS section.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-11848
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Change-Id: Ib126bdd70efa1775aef6db761f54e27a593ebbe5
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-04-02 16:04:38 -04:00
Andreas Dilger
b5bdc0432f e2image: add OPTIONS section to man page
Reorganize the e2image.8 man page so that the command-line options
are listed in a dedicated OPTIONS section, rather than being
interspersed among the text in the DESCRIPTION section.  Otherwise,
it is difficult to determine which options are available, and to
find where each option is described.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-04-02 16:02:01 -04:00
Zhiqiang Liu
e4979da45d misc: remove useless code in set_inode_xattr()
In set_inode_xattr(), there are two returns as follows,
-
  return retval;
  return 0;
-
Here, we remove useless 'return 0;' code.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-04-02 15:57:00 -04: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
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
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
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
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
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
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
67e6ae0a35 mke2fs: fix a importing a directory with an ACL and inline data
If an inode which is copied into a file system using "mke2fs -d" has
an ACL (or extended attributes) and it is also using inline data, when
the extended attribute(s) are copied in, the inline data gets dropped due to a missing call to ext2fs_xattrs_read().

Addresses-Debian-Bug: #971014
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-09 17:11:23 -05:00
Theodore Ts'o
30d07316e5 Update makefile dependencies
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-29 17:00:06 -05:00
Theodore Ts'o
e678ab3970 Merge branch 'maint' into next 2021-01-29 01:13:18 -05:00
Theodore Ts'o
5162872480 misc: fix a spelling nit in the mke2fs man page
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-28 14:21:09 -05:00
Theodore Ts'o
6be3ce7a54 Merge branch 'maint' into next 2021-01-28 00:52:22 -05:00
Yifan Hong
643ee34074 AOSP: tune2fs/resize2fs: make vendor_ramdisk_available.
The vendor_ramdisk variant is dynamic, unlike the ramdisk variant.

Test: builds
Google-Bug-Id: 173425293
Change-Id: I45547b5ea99aae98727121c038129844b7930ed6
From AOSP commit: 073ede3200afeffd82889cb61a71fa1947314476
2021-01-28 00:04:14 -05:00
Daniel Rosenberg
b22c36e60c AOSP: ANDROID: mke2fs: Support encrypt+casefold
In preparation for upcoming kernel changes that will make the kernel
support both encryption and casefolding at the same time, allow mke2fs
to enable both features at the same time.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Google-Bug-Id: 138322712
Test: Create fs with casefold and encryption enabled via mke2fs
Change-Id: I4e2350e43e21cffb3d972310cd74df1e662bf87e
From AOSP commit: f8fc427df385260f3424e1e9d5485c8640606920
2021-01-27 23:48:46 -05:00
Daniel Rosenberg
23fc0e6e46 AOSP: ANDROID: tune2fs: Support encrypt+casefold
In preparation for upcoming kernel changes that will make the kernel
support both encryption and casefolding at the same time, allow tune2fs
to enable both features at the same time.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Google-Bug-Id: 138322712
Test: Create fs with casefold and encryption enabled via tune2fs

Change-Id: I36537a8b6dc5e2997b7016212f9b574c76673067
From AOSP commit: 44ac9dccd9853cc9807f0d6ce952bdcdeb93954a
2021-01-27 23:46:39 -05:00
Daniel Rosenberg
b437e1ed5f AOSP: ANDROID: tune2fs: Allow setting the casefold feature
This allows tune2fs to enable casefolding on an existing filesystem.
At the moment, casefolding is incompatible with encryption.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Google-Bug-Id: 138322712
Test: Create fs without casefold and enable it via tune2fs
Change-Id: Ic9ed63180ef28c36e083cee85ade432e4bfcc654
From AOSP commit: eb5b168decac07058e90ead191350be80c75aff4
2021-01-27 23:35:09 -05:00
Gabriel Krisman Bertazi
4e735c502f tune2fs: fix casefold+encrypt error message
Refering to EXT4_INCOMPAT_CASEFOLD as encoding is not as meaningful as
saying casefold.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-27 22:09:34 -05:00
Gabriel Krisman Bertazi
1f9bb778a8 tune2fs: allow enabling casefold feature after fs creation
The main reason we didn't allow this before was because !CASEFOLDED
directories were expected to be normalized().  Since this is no longer
the case, and as long as the encrypt feature is not enabled, it should
be safe to enable this feature.

Disabling the feature is trickier, since we need to make sure there are
no existing +F directories in the filesystem.  Leave that for a future
patch.

Also, enabling strict mode requires some filesystem-wide verification,
so ignore that for now.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-27 22:09:31 -05:00
Theodore Ts'o
45fa214d62 Merge branch 'maint' into next 2021-01-23 01:05:43 -05:00
Theodore Ts'o
b3f288ed9f Fix clang warnings
Clang gets unhappy when passing an unsigned char to string functions.
For better or for worse we use __u8[] in the definition of the
superblock.  So cast them these to "char *" to prevent clang
build-time warnings.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-23 00:57:18 -05:00
Jan Kara
33b0356c35 mke2fs.8: Improve valid block size documentation
Explain which valid block sizes mke2fs supports in more detail.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 18:26:25 -05:00
Hauke Mehrtens
4d108756a4 build: Add SYSLIBS to e4crypt linking
The $(SYSLIBS) was missing when linking the e4crypt application. This is
available in the e4crypt.profiled variant, so I assume this was just
missing in the normal variant and is not left out intentionally.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 18:11:39 -05:00
Theodore Ts'o
f8049f9fd7 tune2fs: abort clearing the dir_index when the fs needs to be fsck'ed first
We were not checking the return value of check_fsck_needed() when
checking to clear the dir_index feature.  As a result, tune2fs would
print that the file system needed to be checked first, but then go
ahead and clear the dir_index flag.

Addresses-Coverity-Bug: 1467671
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 17:08:40 -05:00
Theodore Ts'o
32c2b19945 tune2fs: fix resource leak in handle_quota_options()
Addresses-Coverity-Bug: 1467672
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 16:07:25 -05:00
Harshad Shirwadkar
06def17e2f Make userspace tools number of fast commits blocks aware
This patch makes number of fast commit blocks configurable. Also, the
number of fast commit blocks can now be seen in dumpe2fs output.

$ ./misc/mke2fs -O fast_commit -t ext4 image
mke2fs 1.46-WIP (20-Mar-2020)
Discarding device blocks: done
Creating filesystem with 5120 1k blocks and 1280 inodes
Allocating group tables: done
Writing inode tables: done
Creating journal (1040 blocks): done
Writing superblocks and filesystem accounting information: done

$ ./misc/dumpe2fs image
dumpe2fs 1.46-WIP (20-Mar-2020)
...
Journal features:         (none)
Total journal size:       1040k
Total journal blocks:     1040
Max transaction length:   1024
Fast commit length:       16
Journal sequence:         0x00000001
Journal start:            0

$ ./misc/mke2fs -O fast_commit -t ext4 image -J fast_commit_size=256,size=1
mke2fs 1.46-WIP (20-Mar-2020)
Creating filesystem with 5120 1k blocks and 1280 inodes
Allocating group tables: done
Writing inode tables: done
Creating journal (1280 blocks): done
Writing superblocks and filesystem accounting information: done

$ ./misc/dumpe2fs image
dumpe2fs 1.46-WIP (20-Mar-2020)
...
Journal features:         (none)
Total journal size:       1280k
Total journal blocks:     1280
Max transaction length:   1024
Fast commit length:       256
Journal sequence:         0x00000001
Journal start:            0

This patch also adds information about fast commit feature in mke2fs
and tune2fs man pages.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 10:57:22 -05:00
Harshad Shirwadkar
895e8e33be ext2fs: move calculate_summary_stats to ext2fs lib
The function calculate_summary_stats sets the global metadata of the
file system. Tune2fs had this function defined statically in
tune2fs.c. Fast commit replay needs this function to set global
metadata at the end of the replay phase. So, move this function to
libext2fs.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 10:53:46 -05:00
Theodore Ts'o
37d5686405 Enable threaded support for e2fsprogs' applications.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 10:50:40 -05:00
Theodore Ts'o
0d47f5ab05 Merge branch 'maint' into next 2021-01-19 23:58:57 -05:00
Lukas Czerner
6fa8edd0fd mke2fs: Escape double quotes when parsing mke2fs.conf
Currently, when constructing the <default> configuration pseudo-file using
the profile-to-c.awk script we will just pass the double quotes as they
appear in the mke2fs.conf.

This is problematic, because the resulting default_profile.c will either
fail to compile because of syntax error, or leave the resulting
configuration invalid.

It can be reproduced by adding the following line somewhere into
mke2fs.conf configuration and forcing mke2fs to use the <default>
configuration by specifying nonexistent mke2fs.conf

MKE2FS_CONFIG="nonexistent" ./misc/mke2fs -T ext4 /dev/device

default_mntopts = "acl,user_xattr"
^ this will fail to compile

default_mntopts = ""
^ this will result in invalid config file

Syntax error in mke2fs config file (<default>, line #4)
       Unknown code prof 17

Fix it by escaping the double quotes with a backslash in
profile-to-c.awk script.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-19 23:56:20 -05:00
Luis Henriques
c57857a514 filefrag: handle invalid st_dev and blksize cases
It is possible to crash filefrag with a "Floating point exception" in
two different scenarios:

1. When fstat() returns a device ID set to 0
2. When FIGETBSZ ioctl returns a blocksize of 0

In both scenarios a divide-by-zero will occur in frag_report() because
variable blksize will be set to zero.

I've managed to trigger this crash with an old CephFS kernel client,
using xfstest generic/519.  The first scenario has been fixed by kernel
commit 75c9627efb72 ("ceph: map snapid to anonymous bdev ID").  The
second scenario is also fixed with commit 8f97d1e99149 ("vfs: fix
FIGETBSZ ioctl on an overlayfs file").

However, it is desirable to handle these two scenarios gracefully by
checking these conditions explicitly.

Signed-off-by: Luis Henriques <lhenriques@suse.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-19 23:43:29 -05:00