Commit Graph

6521 Commits

Author SHA1 Message Date
Benno Schulenberg
1a5205df40 mke2fs.8: fix various formatting issues, and sort the synopsis
Also, delete the sentence that says that the inode size cannot
be changed after creating the file system, as tune2fs acquired
the -I option.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-02 22:52:22 -05:00
Benno Schulenberg
5d974351d5 tune2fs.8: fix various wording and formatting issues
For example: the argument of -c had a mistaken plural "s", the argument
of -o was misformatted, the main description spoke of "options" instead
of "parameters" and used a mistaken "i.e." instead of "e.g.", and so on.

Also, sort the options in the synopsis alphabetically, to make it easier
to find a specific one and to match the order in which they are listed
further down.  Also, remove some excess spaces, harmonize the style of
some decriptions, sort d, w, m in the order of ascending duration, and
for consistency use hyphens instead of underscores in option arguments.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-02-02 22:51:34 -05:00
Theodore Ts'o
fa86b5c2aa Update release notes, etc., for the 1.45.7 release
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-29 00:51:02 -05:00
Мирослав Николић
37226f12ba po: update sr.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-28 14:27:00 -05:00
Benno Schulenberg
43d9f902b8 po: update nl.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-28 14:27:00 -05:00
Sharuzzaman Ahmat Raslan
d863dafb60 po: update ms.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-28 14:27:00 -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
7f69ca1757 Update Makefile dependencies for lib/e2p and lib/ext2fs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-28 01:31:21 -05:00
Jiyong Park
e1af9546e6 AOSP: Add assemble_cvd to com.android.virt
assemble_cvd directly or indirectly depends on these modules. To add
assemble_cvd to the com.anroid.virt APEX, these modules are marked as
being available to the APEX.

Google-Bug-Id: 174639526
Test: m com.android.virt
Change-Id: Ibc28d24abd358fb1f8608b3f3d6d06c2746f2d72
From AOSP commit: e70718ecae3cf1e2a26af800734130e003186e7e
2021-01-28 00:05:08 -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
David Anderson
851d899646 AOSP: Make libext2_uuid and e2fsprogs headers vendor_ramdisk_available.
This is needed to build snapuserd into the vendor ramdisk.

Google-Bug-Id: 173463595
Test: snapuserd builds
Change-Id: I05d85357ebf47abd0d82e9c6211e854bdf0d5ae9
From AOSP commit: b28c0ef21cf8ebd172a07cfd09551af38366a5a7
2021-01-28 00:01:54 -05:00
Justin Yun
d89e06515b AOSP: Add "product_available" to product available modules
"vendor_available" modules were available to product modules.
However, not all "vendor_available" modules are required to be
available to product modules. Some modules want to be available only
to product modules but not vendor modules.

To cover the requirement, we separate "product_available" from
"vendor_available".
"vendor_available" will not provide product available module.

Google-Bug-Id: 150902910
Test: build
Change-Id: I316da0d24bde8b6231114aa80841c59547691152
From AOSP commit: df51b0de40581f52c6515f8775ecd84dc4a50bb0
2021-01-27 23:59:58 -05:00
Daniel Rosenberg
61421ee588 AOSP: ANDROID: e2fsck: Handle casefolded encryption
Adds support for EXT2_HASH_SIPHASH, and reading the hash from disk in
that case. We cannot compute the siphash without the key, so we must
not modify the names of any encrypted and casefolded directories,
which limits some recovery options, and we must assume the hashes
stored in dirents are correct.
This is in preparation for upcoming kernel support for encryption and
casefolding at the same time.

Google-Bug-Id: 138322712
Test: Create fs with casefold and encryption enabled via mke2fs and
      tune2fs, run fsck after creating casefolded + encrypted folder

Change-Id: Icca32d7d9dd3c7f52da03d60e4d89273cbec0a7d
From AOSP commit: 67eae926bdac1a54dbb8335731c5e1581f93e4bb
2021-01-27 23:53:36 -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
79661036b4 AOSP: ANDROID: e2fsck: Do not mutate encrypted names
We can't mutate a name without the key, as this will at best cause the
name to become gibberish, and at worst may introduce invalid characters
or even fail to be unique after decoding, so drop duplicates instead.
Files lost in this way will be reconnected to lost+found

Fixes: dbff534ec6 ("e2fsck: suppress bad name checks for encrypted directories")
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Google-Bug-Id: 138322712
Test: f_dup_de_crypt
Change-Id: I8d6cc3984872868a845fafabc554abdd86351fcc
From AOSP commit: 80b85f8a0b2ba7090a927f692ff9d2097ffd8d1f
2021-01-27 23:35:15 -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
Howard Chen
0ea0a9e790 AOSP: Make e2fsck depends on badblocks
The e2fsck may invoke the badblocks when -c is specified.
Also the badblocks is required by Mediatek devices. Add it for
completeness.

Test: compile wembley-userdebug
Google-Bug-Id: 157393160

Change-Id: I1163129c925e93ef386e86a60c93e9c314397134
From AOSP commit: dffec44dd56175b80810657f95f8e09a7e3ab0bf
2021-01-27 23:34:30 -05:00
Theodore Ts'o
865221f5aa e2fsck: declare the size of bh->b_data to be 4096 in jfs_user.h
When allocating buffer_heads in e2fsck and debugfs the actual size of
the memory which is requested is based on the file system block size.
So the actual size of b_data in struct buffer_head doesn't actually
matter, except that it can triggers a UBSAN error when running the
e2fsck regression test.  So change it to be 4096 to avoid this false
positive.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-27 16:41:05 -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
Theodore Ts'o
b1b864b398 libext2fs: use compiler built-in offsetof() if available
This avoids UBSAN sanitizer warnings, since &(0->member) is
technically undefined per the C standard.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-23 00:55:25 -05:00
Theodore Ts'o
c3c41d4ffb libext2fs: fix UBSAN warning in ext2fs_mmp_new_seq()
Left shifting the pid by 16 bits can cause a UBSAN warning if the pid
is greater than or equal to 2**16.  It doesn't matter since we're just
using the pid to seed for a pseudo-random number generator, but
silence the warning by just swapping the high and low 16 bits of the
pid instead.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 23:27:00 -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
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
Theodore Ts'o
12c415fb0b debugfs: fix double free in realloc() error path in read_list()
Fixes-Coverity-Bug: 1464575
Fixes-Coverity-Bug: 1464571
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 16:01:14 -05:00
Theodore Ts'o
dd2ed58ab1 libext2fs: fix incorrect negative error return in unix and sparse io managers
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-21 16:00:01 -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
Romain Naour
3ec53092dd libext2fs: add gnu.translator support
The support of setting (and reading) of passive translators from
GNU/Linux has been added to the Linux kernel by the commit [1].
The name index '10' has been reserved for GNU/Hurd.

Hurd passive translators are stored as a xattr value with name
"gnu.translator" [2].

If "gnu.translator" xattr value has been set before calling
mkfs.ext2, it will segfault since "gnu." is not present in
ea_names[].

$ setfattr -n gnu.translator -v "/hurd/exec\0" ${TARGET_DIR}/servers/exec
$ mkfs.ext2 -d ${TARGET_DIR} -o hurd -O ext_attr rootfs.ext2 "1G"

Adding "gnu." to ea_names[], allow to create ext2 filesystem
for GNU/Hurd with passive translator already set.

[1] https://git.savannah.gnu.org/cgit/hurd/hurd.git/commit/?id=a04c7bf83172faa7cb080fbe3b6c04a8415ca645
[2] https://lists.gnu.org/archive/html/bug-hurd/2016-08/msg00075.html

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-01-19 23:54:51 -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
Antoine Tenart
7616fd6a59 create_inode: set xattrs to the root directory as well
populate_fs do copy the xattrs for all files and directories, but the
root directory is skipped and as a result its extended attributes aren't
set. This is an issue when using mkfs to build a full system image that
can be used with SElinux in enforcing mode without making any runtime
fix at first boot.

This patch adds logic to set the root directory's extended attributes.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-12-15 13:38:28 -05:00
Benno Schulenberg
af1a882fd2 release notes: delete two files that are fully contained within v1.41.txt
They are pure duplicates.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-27 23:41:06 -04:00
Theodore Ts'o
5b44781e2a debugfs: fix parse_uint for 64-bit fields
The logic for handling 64-bit structure elements was reversed, which
caused attempts to set fields like kbytes_written to fail:

    % debugfs -w /tmp/foo.img
    debugfs 1.45.6 (20-Mar-2020)
    debugfs:  set_super_value kbytes_written 1024
    64-bit field kbytes_written has a second 64-bit field
    defined; BUG?!?

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

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-06 08:29:09 -04:00
Theodore Ts'o
3ab2fd4e23 Define MKDIR_P in the Makefile.in files instead in MCONFIG.in
In the case where mkdir -p is not thread-safe (for example, if the
build environment is using busybox's mkdir) the configure script will
fall back to the slow (but safe) install-sh script.  In that case
MKDIR_P will be using a relative pathname; so we can't use speed
optimization of defining configure substitutions in MCONFIG.in, since
the substitution will be different depending on depth of the
subdirectory in the Makefile.in file.

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

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-04 23:05:01 -04:00
Theodore Ts'o
21bad2b679 resize2fs: prevent block group descriptors from overflowing the first bg
For 1k block file systems, resizing a file system larger than
1073610752 blocks will result in the size of the block group
descriptors to be so large that it will overlap with the backup
superblock in block group #1.   This problem can be reproduced via:

    mke2fs -t ext4 /tmp/foo.img 200M
    resize2fs /tmp/foo.img 1T
    e2fsck -f /tmp/foo.img

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

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-02 14:47:25 -04:00
Yi Kong
b1a780ed7b AOSP: Fix a trivial type error
Comparing unsigned int with ULONG_MAX is always false.

Signed-off-by: Yi Kong <yikong@google.com>
Change-Id: Iae02aad1bcb271d3468828977be288ad04333821
From AOSP commit: 757a4d672dae1a15c57f5f0705ba90ed007da7e6
2020-10-01 17:42:28 -04:00
Tom Cherry
694b1400f2 AOSP: Include private/fs_config.h directly when needed
This is no longer a transitive include of android_filesystem_config.h

Bug: 149785767
Test: build
Change-Id: I954adf7879fa811eb2b290a0983c84d47ecae26c
From AOSP commit: 9fa6bed983d5ddd7226af647a0c4c0d922227be4
2020-10-01 17:36:44 -04:00
Xiao Yang
1dd48bc23c chattr/lsattr: Support dax attribute
Use the letter 'x' to set/get dax attribute on a directory/file.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:55:16 -04:00
Hongxu Jia
4baaa1fcad mke2fs: fix up check for hardlinks always false if inode > 0xFFFFFFFF
While file has a large inode number (> 0xFFFFFFFF), mkfs.ext4 could
not parse hardlink correctly.

Prepare three hardlink files for mkfs.ext4

$ ls -il rootfs_ota/a rootfs_ota/boot/b rootfs_ota/boot/c
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/a
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/b
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/c

$ truncate -s 1M rootfs_ota.ext4

$ mkfs.ext4 -F -i 8192 rootfs_ota.ext4 -L otaroot -U fd5f8768-c779-4dc9-adde-165a3d863349 -d rootfs_ota

$ mkdir mnt && sudo mount rootfs_ota.ext4 mnt

$ ls -il mnt/a mnt/boot/b mnt/boot/c
12 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/a
14 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/b
15 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/c

After applying this fix
$ ls -il mnt/a mnt/boot/b mnt/boot/c
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/a
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/b
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/c

Since commit [382ed4a1 e2fsck: use proper types for variables][1]
applied, it used ext2_ino_t instead of ino_t for referencing inode
numbers, but the type of is_hardlink's `ino' should not be instead,
The ext2_ino_t is 32bit, if inode > 0xFFFFFFFF, its value will be
truncated.

Add a debug printf to show the value of inode, when it check for hardlink
files, it will always return false if inode > 0xFFFFFFFF
|--- a/misc/create_inode.c
|+++ b/misc/create_inode.c
|@@ -605,6 +605,7 @@ static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino)
| {
|        int i;
|
|+       printf("%s %d, %lX, %lX\n", __FUNCTION__, __LINE__, hdlinks->hdl[i].src_ino, ino);
|        for (i = 0; i < hdlinks->count; i++) {
|                if (hdlinks->hdl[i].src_dev == dev &&
|                    hdlinks->hdl[i].src_ino == ino)

Here is debug message:
is_hardlink 608, 2913DB886, 913DB886

The length of ext2_ino_t is 32bit (typedef __u32 __bitwise ext2_ino_t;),
and ino_t is 64bit on 64bit system (such as x86-64), recover `ino' to ino_t.

[1] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?id=382ed4a1c2b60acb9db7631e86dda207bde6076e

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:51:46 -04:00
Jan Kara
f4979dd566 mke2fs: Warn if fs block size is incompatible with DAX
If we are creating filesystem on DAX capable device, warn if set block
size is incompatible with DAX to give admin some hint why DAX might not
be available.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:51:46 -04:00
Florian Schmaus
30e3dfb330 e4crypt: if salt is explicitly provided to add_key, then use it
Providing -S and a path to 'add_key' previously exhibited an
unintuitive behavior: instead of using the salt explicitly provided by
the user, e4crypt would use the salt obtained via
EXT4_IOC_GET_ENCRYPTION_PWSALT on the path. This was because
set_policy() was still called with NULL as salt.

With this change we now remember the explicitly provided salt (if any)
and use it as argument for set_policy().

Eventually

e4crypt add_key -S s:my-spicy-salt /foo

will now actually use 'my-spicy-salt' and not something else as salt
for the policy set on /foo.

Signed-off-by: Florian Schmaus <flo@geekplace.eu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:51:46 -04:00
Andreas Dilger
a2292f8a51 tune2fs: reset MMP state on error exit
If tune2fs cannot perform the requested change, ensure that the MMP
block is reset to the unused state before exiting.  Otherwise, the
filesystem will be left with mmp_seq = EXT4_MMP_SEQ_FSCK set, which
prevents it from being mounted afterward:

    EXT4-fs warning (device dm-9): ext4_multi_mount_protect:311:
        fsck is running on the filesystem

Add a test to try some failed tune2fs operations and verify that the
MMP block is left in a clean state afterward.

Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13672
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:51:46 -04:00
Lukas Czerner
4d13e6a57e ext2fs: remove unused variable 'left'
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:51:46 -04:00
Lukas Czerner
c7271494ce e2fsck: use the right conversion specifier in e2fsck_allocate_memory()
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:51:46 -04:00
Lukas Czerner
0c6fe31f32 e2fsck: use size_t instead of int in string_copy()
len argument in string_copy() is int, but it is used with malloc(),
strlen(), strncpy() and some callers use sizeof() to pass value in. So
it really ought to be size_t rather than int. Fix it.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-10-01 16:51:46 -04:00
Theodore Ts'o
acc9058451 tests: remove unnecessary uncompressed image file
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-09-30 17:18:35 -04:00
Theodore Ts'o
7b63656df9 libext2fs: fix potential buffer overrun in __get_dirent_tail()
If the file system is corrupted, there is a potential of a read-only
buffer overrun.  Fortunately, we don't actually use the result of that
pointer dereference, and the overrun is at most 64k.

Google-Bug-Id: #158564737
Fixes: eb88b75174 ("libext2fs: make ext2fs_dirent_has_tail() more strict")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-08-26 16:29:29 -04:00
Theodore Ts'o
6cdd4b9309 debugfs: fix building rdebugfs (with READ_ONLY define)
Fix bitrot for building a restricted version of debugfs, which does
not require read/write access to the file system, and which only
allows access to the file system metadata.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-06-17 21:43:37 -04:00
Theodore Ts'o
6338a84675 libext2fs: retry reading superblock on open when checksum is bad
When opening a file system which is mounted, it's possible that when
ext2fs_open2() is racing with the kernel modifying the orphaned inode
list, the superblock's checksum could be incorrect.  So retry reading
the superblock in the hopes that the problem will self-correct.

Google-Bug-Id: 151453112
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-05-17 23:05:11 -04:00
Theodore Ts'o
86d6153417 libext2fs: batch calls to ext2fs_zero_blocks2()
When allocating blocks for an indirect block mapped file, accumulate
blocks to be zero'ed and then call ext2fs_zero_blocks2() to zero them
in large chunks instead of block by block.

This significantly speeds up mkfs.ext3 since we don't send a large
number of ZERO_RANGE requests to the kernel, and while the kernel does
batch write requests, it is not batching ZERO_RANGE requests.  It's
more efficient to batch in userspace in any case, since it avoids
unnecessary system calls.

Reported-by: Mario Schuknecht <mario.schuknecht@dresearch-fe.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-04-25 11:46:07 -04:00