Whamcloud - gitweb
tools/e2fsprogs.git
3 years agodebian: update changelog for buster-backports release 1.46.1-1~bpo10+1 archive/debian/1.46.1-1_bpo10+1 debian/1.46.1-1_bpo10+1
Theodore Ts'o [Tue, 16 Feb 2021 18:48:45 +0000 (13:48 -0500)]
debian: update changelog for buster-backports release 1.46.1-1~bpo10+1

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoMerge branch 'debian/master' into debian/backports
Theodore Ts'o [Tue, 16 Feb 2021 18:46:09 +0000 (13:46 -0500)]
Merge branch 'debian/master' into debian/backports

3 years agoMerge tag 'v1.46.1' into debian/master archive/debian/1.46.1-1 debian/1.46.1-1
Theodore Ts'o [Tue, 9 Feb 2021 23:47:24 +0000 (18:47 -0500)]
Merge tag 'v1.46.1' into debian/master

v1.46.1

3 years agoUpdate release notes, etc., for the 1.46.1 release v1.46.1
Theodore Ts'o [Tue, 9 Feb 2021 22:50:25 +0000 (17:50 -0500)]
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>
3 years agopo: update uk.po (from translationproject.org)
Yuri Chornoivan [Tue, 9 Feb 2021 22:37:28 +0000 (17:37 -0500)]
po: update uk.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update sv.po (from translationproject.org)
Göran Uddeborg [Tue, 9 Feb 2021 22:37:28 +0000 (17:37 -0500)]
po: update sv.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update pt.po (from translationproject.org)
Pedro Albuquerque [Tue, 9 Feb 2021 22:37:28 +0000 (17:37 -0500)]
po: update pt.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update pl.po (from translationproject.org)
Jakub Bogusz [Tue, 9 Feb 2021 22:37:28 +0000 (17:37 -0500)]
po: update pl.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update ms.po (from translationproject.org)
Sharuzzaman Ahmat Raslan [Tue, 9 Feb 2021 22:37:28 +0000 (17:37 -0500)]
po: update ms.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update fr.po (from translationproject.org)
Samuel Thibault [Tue, 9 Feb 2021 22:37:28 +0000 (17:37 -0500)]
po: update fr.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update cs.po (from translationproject.org)
Petr Pisar [Tue, 9 Feb 2021 22:37:28 +0000 (17:37 -0500)]
po: update cs.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agomke2fs: fix a importing a directory with an ACL and inline data
Theodore Ts'o [Tue, 9 Feb 2021 22:11:23 +0000 (17:11 -0500)]
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>
3 years agodebian: add build profiles noudeb and pkg.e2fsprogs.no-static
Theodore Ts'o [Tue, 9 Feb 2021 20:56:12 +0000 (15:56 -0500)]
debian: add build profiles noudeb and pkg.e2fsprogs.no-static

Addresses-Debian-Bug: #966686
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoconfigure.ac: convert all help strings to use AS_HELP_STRING
Theodore Ts'o [Tue, 9 Feb 2021 20:54:12 +0000 (15:54 -0500)]
configure.ac: convert all help strings to use AS_HELP_STRING

Some help strings were using the deprecated AC_HELP_STRING, and others
were completely hard-coded.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoProvide and use sort_r() instead of qsort_r() for portability reasons
Theodore Ts'o [Tue, 9 Feb 2021 20:27:51 +0000 (15:27 -0500)]
Provide and use sort_r() instead of qsort_r() for portability reasons

The qsort_r() function is specific to glibc.  It is not present in the
musl C library.  Worse, FreeBSD supports qsort_r, but with an
incompatible interface.  So use sort_r() from commit c8c65c1e183d
from the git repository: https://github.com/noporpoise/sort_r

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

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: endianness fixes for fast commit replay
Harshad Shirwadkar [Thu, 4 Feb 2021 23:36:01 +0000 (15:36 -0800)]
e2fsck: endianness fixes for fast commit replay

There are a few places where the endianness conversion wasn't done
right. This patch fixes that. Verified that after this patch,
j_recover_fast_commit passes on big endian qemu VM.

root@debian-powerpc:~/e2fsprogs/tests# make j_recover_fast_commit
j_recover_fast_commit: : ok

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoext2fs: initialize handle to NULL in ext2fs_count_blks
Harshad Shirwadkar [Thu, 4 Feb 2021 23:35:59 +0000 (15:35 -0800)]
ext2fs: initialize handle to NULL in ext2fs_count_blks

Initialize the handle to NULL to ensure that in error cases,
ext2fs_free_mem can be called on it.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: fix check of directories over 4GB
Andreas Dilger [Tue, 2 Feb 2021 08:25:49 +0000 (01:25 -0700)]
e2fsck: fix check of directories over 4GB

If directories grow larger than 4GB in size with the large_dir
feature, e2fsck will consider them to be corrupted and clear
the high bits of the size.

Since it isn't very common to have directories this large, and
unlike sparse files that don't have ill effects if the size is
too large, an too-large directory will have all of the sparse
blocks filled in by e2fsck, so huge directories should still
be viewed with suspicion.  Check for consistency between two of
the three among block count, inode size, and superblock large_dir
flag before deciding whether the directory inode should be fixed
or cleared, or if large_dir should be set in the superblock.

Update the f_recnect_bad test case to match new output.

Fixes: 49f28a06b738 ("e2fsck: allow to check >2GB sized directory")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-14345
Change-Id: I1b898cdab95d239ba1a7b37eb96255acadce7057
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agolibext2fs: fix more compiler warnings
Theodore Ts'o [Mon, 8 Feb 2021 04:27:56 +0000 (23:27 -0500)]
libext2fs: fix more compiler warnings

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agolibext2fs: fix segault when setting an xattr with an unknown prefix
Theodore Ts'o [Mon, 8 Feb 2021 04:21:58 +0000 (23:21 -0500)]
libext2fs: fix segault when setting an xattr with an unknown prefix

Also avoid unnecessary calls to find_ea_index() by caching the short
name and name index in the ext2_attr structure.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agomisc: fix minor llvm warnings
Andreas Dilger [Sun, 24 Jan 2021 23:20:06 +0000 (16:20 -0700)]
misc: fix minor llvm warnings

Fix a couple minor type mismatch warnings.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agodebian: drop transitional packages
Theodore Ts'o [Sat, 30 Jan 2021 04:35:38 +0000 (23:35 -0500)]
debian: drop transitional packages

We renamed the libcomerr2, e2fslibs, and e2fslibs-dev packages to
match Debian package naming convetions in Debian 10 (Buster).  Now
that Debian 11 (Bullseye) is about to be released, we no longer need
the transitional packages.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoconfigure.ac: fix build failure on systems with pthreads && !fuse support
Theodore Ts'o [Sat, 30 Jan 2021 03:28:31 +0000 (22:28 -0500)]
configure.ac: fix build failure on systems with pthreads && !fuse support

The configure script checks for pthread.h as part of double-checking
that the FUSE support works correctly, which implicitly defined
HAVE_PHREAD_H.  If the FUSE libraries are not present (or fuse support
is explicitly disabled), this check doesn't happen and so
HAVE_PTHREAD_H is not defined, and this causes a build failure.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoUpdate release notes, etc., for the 1.46.0 release v1.46.0
Theodore Ts'o [Fri, 29 Jan 2021 21:28:44 +0000 (16:28 -0500)]
Update release notes, etc., for the 1.46.0 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoUpdate makefile dependencies
Theodore Ts'o [Fri, 29 Jan 2021 19:45:44 +0000 (14:45 -0500)]
Update makefile dependencies

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoUpdate debian/libext2fs2.symbols with the additions to the shared library
Theodore Ts'o [Fri, 29 Jan 2021 06:56:41 +0000 (01:56 -0500)]
Update debian/libext2fs2.symbols with the additions to the shared library

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoMerge branch 'maint' into next
Theodore Ts'o [Fri, 29 Jan 2021 06:13:18 +0000 (01:13 -0500)]
Merge branch 'maint' into next

3 years agoe2fsck: drop use of sysctl(2)
Theodore Ts'o [Fri, 29 Jan 2021 06:03:36 +0000 (01:03 -0500)]
e2fsck: drop use of sysctl(2)

Remove the use of the binary interface using the sysctl(2) system call
since sys/sysctl.h has been deprecated.  We can find the total memory
available in the system using the POSIX standard sysconf(2) interface.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoconfigure.ac: add substitution for @mkdir_p@ since po/Makefile.in.in uses it
Theodore Ts'o [Fri, 29 Jan 2021 04:16:46 +0000 (23:16 -0500)]
configure.ac: add substitution for @mkdir_p@ since po/Makefile.in.in uses it

Fixes: e598c29b4d38 ("Update gettext files to version 0.19.8")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoMerge tag 'v1.45.7' into debian/master archive/debian/1.45.7-1 debian/1.45.7-1
Theodore Ts'o [Fri, 29 Jan 2021 05:54:39 +0000 (00:54 -0500)]
Merge tag 'v1.45.7' into debian/master

v1.45.7

3 years agoUpdate release notes, etc., for the 1.45.7 release v1.45.7
Theodore Ts'o [Fri, 29 Jan 2021 05:27:17 +0000 (00:27 -0500)]
Update release notes, etc., for the 1.45.7 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update sr.po (from translationproject.org)
Мирослав Николић [Thu, 28 Jan 2021 19:27:00 +0000 (14:27 -0500)]
po: update sr.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update nl.po (from translationproject.org)
Benno Schulenberg [Thu, 28 Jan 2021 19:27:00 +0000 (14:27 -0500)]
po: update nl.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agopo: update ms.po (from translationproject.org)
Sharuzzaman Ahmat Raslan [Thu, 28 Jan 2021 19:27:00 +0000 (14:27 -0500)]
po: update ms.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agomisc: fix a spelling nit in the mke2fs man page
Theodore Ts'o [Thu, 28 Jan 2021 19:21:09 +0000 (14:21 -0500)]
misc: fix a spelling nit in the mke2fs man page

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoUpdate Makefile dependencies for lib/e2p and lib/ext2fs
Theodore Ts'o [Thu, 28 Jan 2021 06:31:21 +0000 (01:31 -0500)]
Update Makefile dependencies for lib/e2p and lib/ext2fs

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoMerge branch 'maint' into next
Theodore Ts'o [Thu, 28 Jan 2021 05:52:22 +0000 (00:52 -0500)]
Merge branch 'maint' into next

3 years agoAOSP: Add assemble_cvd to com.android.virt
Jiyong Park [Tue, 5 Jan 2021 05:43:46 +0000 (14:43 +0900)]
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

3 years agoAOSP: tune2fs/resize2fs: make vendor_ramdisk_available.
Yifan Hong [Thu, 19 Nov 2020 02:52:13 +0000 (18:52 -0800)]
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

3 years agoAOSP: Make libext2_uuid and e2fsprogs headers vendor_ramdisk_available.
David Anderson [Tue, 17 Nov 2020 07:19:04 +0000 (23:19 -0800)]
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

3 years agoAOSP: Add "product_available" to product available modules
Justin Yun [Wed, 11 Nov 2020 07:15:33 +0000 (16:15 +0900)]
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

3 years agoAOSP: ANDROID: e2fsck: Handle casefolded encryption
Daniel Rosenberg [Fri, 13 Mar 2020 23:08:52 +0000 (16:08 -0700)]
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

3 years agoAOSP: ANDROID: mke2fs: Support encrypt+casefold
Daniel Rosenberg [Thu, 11 Jun 2020 04:22:05 +0000 (21:22 -0700)]
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

3 years agoAOSP: ANDROID: tune2fs: Support encrypt+casefold
Daniel Rosenberg [Thu, 11 Jun 2020 04:21:42 +0000 (21:21 -0700)]
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

3 years agoAOSP: ANDROID: e2fsck: Do not mutate encrypted names
Daniel Rosenberg [Fri, 12 Jun 2020 11:11:38 +0000 (04:11 -0700)]
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: dbff534ec685 ("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

3 years agoAOSP: ANDROID: tune2fs: Allow setting the casefold feature
Daniel Rosenberg [Thu, 11 Jun 2020 04:18:44 +0000 (21:18 -0700)]
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

3 years agoAOSP: Make e2fsck depends on badblocks
Howard Chen [Fri, 29 May 2020 04:26:54 +0000 (12:26 +0800)]
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

3 years agotests: test case-folding checks in e2fsck
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:44 +0000 (18:35 +0100)]
tests: test case-folding checks in e2fsck

Add the test f_bad_fname which test fixes of invalid filenames and
duplicates.

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>
3 years agoe2fsck.8.in: document check_encoding extended option
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:43 +0000 (18:35 +0100)]
e2fsck.8.in: document check_encoding extended option

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>
3 years agoe2fsck: add option to force encoded filename verification
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:42 +0000 (18:35 +0100)]
e2fsck: add option to force encoded filename verification

This is interesting for !strict filesystems as part of the encoding
update procedure. Once the filesystem is known to not have badly encoded
filenames, the update is trivial, thanks to the stability of assigned
code points in the unicode specification.

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>
3 years agoe2fsck: detect duplicated casefolded direntries for rehash
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:41 +0000 (18:35 +0100)]
e2fsck: detect duplicated casefolded direntries for rehash

On pass2, support casefolded directories when looking for duplicated
entries.

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>
3 years agodict: support comparison with context
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:40 +0000 (18:35 +0100)]
dict: support comparison with context

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>
3 years agoe2fsck: support casefold directories when rehashing
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:39 +0000 (18:35 +0100)]
e2fsck: support casefold directories when rehashing

When rehashing a +F directory, the casefold comparison needs to be
performed, in order to identify duplicated filenames.  Like the -F
version, This is done in two steps, first adapt the qsort comparison to
consider casefolded directories, and then iterate over the sorted list
fixing dups.

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>
3 years agoe2fsck: fix entries with invalid encoded characters
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:38 +0000 (18:35 +0100)]
e2fsck: fix entries with invalid encoded characters

On strict mode, invalid Unicode sequences are not permited.  This patch
adds a verification step to pass2 to detect and modify the entries with
the same replacement char used for non-encoding directories '.'.

After the encoding test, we still want to check the name for usual
problems, '\0', '/' in the middle of the sequence.

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>
3 years agoe2fsck: add new problem for encoded name check
Arnaud Ferraris [Thu, 17 Dec 2020 17:35:37 +0000 (18:35 +0100)]
e2fsck: add new problem for encoded name check

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoext2fs: implement faster CI comparison of strings
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:36 +0000 (18:35 +0100)]
ext2fs: implement faster CI comparison of strings

Instead of calling casefold two times and memcmp the result, which
require allocating a temporary buffer for the casefolded version, add a
strcasecmp-like method to perform the comparison of each code-point
during the casefold itself.

This method is exposed because it needs to be used directly by fsck.

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>
3 years agoext2fs: add method to validate casefolded strings
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:35 +0000 (18:35 +0100)]
ext2fs: add method to validate casefolded strings

This is exported to be used by fsck.

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>
3 years agotune2fs: fix casefold+encrypt error message
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:34 +0000 (18:35 +0100)]
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>
3 years agotune2fs: allow enabling casefold feature after fs creation
Gabriel Krisman Bertazi [Thu, 17 Dec 2020 17:35:33 +0000 (18:35 +0100)]
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>
3 years agotests: add fast commit recovery tests
Harshad Shirwadkar [Fri, 22 Jan 2021 05:45:04 +0000 (21:45 -0800)]
tests: add fast commit recovery tests

Add j_recover_fast_commit test that ensure that e2fsck is able to
recover a disk from fast commit log.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: add replay for add_range, del_range, and inode tags
Harshad Shirwadkar [Fri, 22 Jan 2021 05:45:03 +0000 (21:45 -0800)]
e2fsck: add replay for add_range, del_range, and inode tags

Add replay for inode's extent trees and inode itself.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: add fc replay for link, unlink, creat tags
Harshad Shirwadkar [Fri, 22 Jan 2021 05:45:02 +0000 (21:45 -0800)]
e2fsck: add fc replay for link, unlink, creat tags

Add fast commit replay for directory entry updates.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: add fast commit replay skeleton
Harshad Shirwadkar [Fri, 22 Jan 2021 05:45:01 +0000 (21:45 -0800)]
e2fsck: add fast commit replay skeleton

This function adds the skeleton for the replay path. Following patches
in the series implement the handling for individual tags.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: add fast commit scan pass
Harshad Shirwadkar [Fri, 22 Jan 2021 05:45:00 +0000 (21:45 -0800)]
e2fsck: add fast commit scan pass

Add fast commit scan pass. Scan pass is responsible for following
things:

* Count total number of fast commit tags that need to be replayed
  during the replay phase.

* Validate whether the fast commit area is valid for a given
  transaction ID.

* Verify the CRC of fast commit area.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: add fast commit setup code
Harshad Shirwadkar [Fri, 22 Jan 2021 05:44:59 +0000 (21:44 -0800)]
e2fsck: add fast commit setup code

Introduce "e2fsck_fc_replay_state" structure which is needed for ext4
fast commit replay.

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>
3 years agoe2fsck: add function to rewrite extent tree
Harshad Shirwadkar [Fri, 22 Jan 2021 05:44:58 +0000 (21:44 -0800)]
e2fsck: add function to rewrite extent tree

Fast commit replay needs to rewrite the entire extent tree for inodes
found in fast commit area. This patch makes e2fsck's rewrite extent
tree path visible.

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>
3 years agoext2fs: add new APIs needed for fast commits
Harshad Shirwadkar [Fri, 22 Jan 2021 05:44:57 +0000 (21:44 -0800)]
ext2fs: add new APIs needed for fast commits

This patch adds the following new APIs:

Count the total number of blocks occupied by inode including
intermediate extent tree nodes.
extern errcode_t ext2fs_count_blocks(ext2_filsys fs, ext2_ino_t ino,
                                     struct ext2_inode *inode,
     blk64_t *ret_count);

Convert the on-disk reputation of an extent to the in-memory
representation.
extern errcode_t ext2fs_decode_extent(struct ext2fs_extent *to, void *from,
                                     int len);

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: declare the size of bh->b_data to be 4096 in jfs_user.h
Theodore Ts'o [Wed, 27 Jan 2021 21:41:05 +0000 (16:41 -0500)]
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>
3 years agoMerge branch 'maint' into next
Theodore Ts'o [Sat, 23 Jan 2021 06:05:43 +0000 (01:05 -0500)]
Merge branch 'maint' into next

3 years agoInclude PTHREAD_CFLAGS in LDFLAGS* macros
Theodore Ts'o [Sat, 23 Jan 2021 06:02:19 +0000 (01:02 -0500)]
Include PTHREAD_CFLAGS in LDFLAGS* macros

PTHREAD_CFLAGS is set by AX_PTHREADS, and these flags need to be
included when linking executables.

Fixes: bdcd5f22203f ("Add configure and build support for the pthreads library")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoFix clang warnings
Theodore Ts'o [Sat, 23 Jan 2021 05:57:18 +0000 (00:57 -0500)]
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>
3 years agolibext2fs: use compiler built-in offsetof() if available
Theodore Ts'o [Sat, 23 Jan 2021 05:55:25 +0000 (00:55 -0500)]
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>
3 years agoOnly build resize2fs.static when running "make all-static"
Theodore Ts'o [Sat, 23 Jan 2021 05:34:54 +0000 (00:34 -0500)]
Only build resize2fs.static when running "make all-static"

Fixes: 93df80d2409d ("Teach makefiles... the target all-static")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agolibext2fs: fix UBSAN warning in ext2fs_mmp_new_seq()
Theodore Ts'o [Fri, 22 Jan 2021 04:27:00 +0000 (23:27 -0500)]
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>
3 years agomke2fs.8: Improve valid block size documentation
Jan Kara [Thu, 21 Jan 2021 23:26:25 +0000 (18:26 -0500)]
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>
3 years agobuild: Add SYSLIBS to e4crypt linking
Hauke Mehrtens [Thu, 21 Jan 2021 23:11:30 +0000 (18:11 -0500)]
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>
3 years agotune2fs: abort clearing the dir_index when the fs needs to be fsck'ed first
Theodore Ts'o [Thu, 21 Jan 2021 22:08:40 +0000 (17:08 -0500)]
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>
3 years agoe2fsck: remove dead code when recreating the journal
Theodore Ts'o [Thu, 21 Jan 2021 21:51:45 +0000 (16:51 -0500)]
e2fsck: remove dead code when recreating the journal

params.num_journal_blocks is an unsigned value so it can never be less
than zero.

Addresses-Coverity-Bug: 1472250
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agodebugfs: fix the printf specifier when dumping a fast commit block
Theodore Ts'o [Thu, 21 Jan 2021 21:44:39 +0000 (16:44 -0500)]
debugfs: fix the printf specifier when dumping a fast commit block

Addresses-Coverity-Bug: 1472249
Addresses-Coverity-Bug: 1472253
Addresses-Coverity-Bug: 1472254
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agolibext2fs: fix minor Coverity nits in ext2fs_rw_bitmaps()
Theodore Ts'o [Thu, 21 Jan 2021 21:34:57 +0000 (16:34 -0500)]
libext2fs: fix minor Coverity nits in ext2fs_rw_bitmaps()

Addresses-Coverity-Bug: 1472252
Addresses-Coverity-Bug: 1472253
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agotune2fs: fix resource leak in handle_quota_options()
Theodore Ts'o [Thu, 21 Jan 2021 21:07:25 +0000 (16:07 -0500)]
tune2fs: fix resource leak in handle_quota_options()

Addresses-Coverity-Bug: 1467672
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agodebugfs: fix double free in realloc() error path in read_list()
Theodore Ts'o [Thu, 21 Jan 2021 21:01:14 +0000 (16:01 -0500)]
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>
3 years agolibext2fs: fix incorrect negative error return in unix and sparse io managers
Theodore Ts'o [Thu, 21 Jan 2021 21:00:01 +0000 (16:00 -0500)]
libext2fs: fix incorrect negative error return in unix and sparse io managers

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agolibext2fs: fix incorrect negative error return in ext2fs_rw_bitmaps()
Theodore Ts'o [Thu, 21 Jan 2021 20:20:45 +0000 (15:20 -0500)]
libext2fs: fix incorrect negative error return in ext2fs_rw_bitmaps()

Fixes: e2e58d312804 ("ext2fs: parallel bitmap loading")
Fixes-Coverity-Bug: 147255
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agodebugfs: add fast commit support to logdump
Harshad Shirwadkar [Wed, 20 Jan 2021 21:26:39 +0000 (13:26 -0800)]
debugfs: add fast commit support to logdump

Add fast commit support for debugfs logdump.

This commit also adds fast_commit.h that contains the necessary
helpers needed for fast commit replay. Note that this file is also
byte by byte identical with kernel's fast_commit.h.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoext4: fix tests to account for new dumpe2fs output
Harshad Shirwadkar [Wed, 20 Jan 2021 21:26:41 +0000 (13:26 -0800)]
ext4: fix tests to account for new dumpe2fs output

dumpe2fs tool now is capable of reporting number of fast commit
blocks. There were slight changes in the output of dumpe2fs outside of
fast commits. This patch fixes the regression tests to expect the new
output.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoMake userspace tools number of fast commits blocks aware
Harshad Shirwadkar [Wed, 20 Jan 2021 21:26:31 +0000 (13:26 -0800)]
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>
3 years agolibext2fs: provide APIs to configure fast commit blocks
Harshad Shirwadkar [Wed, 20 Jan 2021 21:26:30 +0000 (13:26 -0800)]
libext2fs: provide APIs to configure fast commit blocks

This patch adds new libext2fs that allow configuring number of fast
commit blocks in journal superblock. We also add a struct
ext2fs_journal_params which contains number of fast commit blocks and
number of normal journal blocks. With this patch, the preferred way
for configuring number of blocks with and without fast commits is:

struct ext2fs_journal_params params;

ext2fs_get_journal_params(&params, ...);
params.num_journal_blocks = ...;
params.num_fc_blocks = ...;
ext2fs_create_journal_superblock2(..., &params, ...);
         OR
ext2fs_add_journal_inode3(..., &params, ...);

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoe2fsck: port fc changes from kernel's recovery.c to e2fsck
Harshad Shirwadkar [Wed, 20 Jan 2021 21:26:29 +0000 (13:26 -0800)]
e2fsck: port fc changes from kernel's recovery.c to e2fsck

This patch makes recovery.c identical with fast commit kernel changes.

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>
3 years agoe2fsck: add kernel endian-ness conversion macros
Harshad Shirwadkar [Wed, 20 Jan 2021 21:26:28 +0000 (13:26 -0800)]
e2fsck: add kernel endian-ness conversion macros

In order to make recovery.c identical with kernel, we need endianness
conversion macros (such as cpu_to_be32 and friends) defined in
e2fsprogs. This patch defines these macros and also fixes recovery.c
to use these. These macros are also needed for fast commit recovery
patches later in this series.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoext2fs: move calculate_summary_stats to ext2fs lib
Harshad Shirwadkar [Wed, 20 Jan 2021 21:26:27 +0000 (13:26 -0800)]
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>
3 years agoEnable threaded support for e2fsprogs' applications.
Theodore Ts'o [Thu, 14 Jan 2021 00:27:23 +0000 (16:27 -0800)]
Enable threaded support for e2fsprogs' applications.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoext2fs: parallel bitmap loading
Wang Shilong [Thu, 14 Jan 2021 00:27:22 +0000 (16:27 -0800)]
ext2fs: parallel bitmap loading

In our benchmarking for PiB size filesystem, pass5 takes
10446s to finish and 99.5% of time takes on reading bitmaps.

It makes sense to reading bitmaps using multiple threads,
a quickly benchmark show 10446s to 626s with 64 threads.

[ This has all of many bug fixes for rw_bitmaps.c from the original
  luster patch set collapsed into a single commit.   In addition it has
  the new ext2fs_rw_bitmaps() api proposed by Ted. ]

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Saranya Muruganandam <saranyamohan@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agolibext2fs: allow the unix_io manager's cache to be disabled and re-enabled
Theodore Ts'o [Thu, 14 Jan 2021 00:27:21 +0000 (16:27 -0800)]
libext2fs: allow the unix_io manager's cache to be disabled and re-enabled

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agolibext2fs: add threading support to the I/O manager abstraction
Theodore Ts'o [Thu, 14 Jan 2021 00:27:20 +0000 (16:27 -0800)]
libext2fs: add threading support to the I/O manager abstraction

Add initial implementation support for the unix_io manager.
Applications which want to use threading should pass in
IO_FLAG_THREADS when opening the channel.  Channels which support
threading (which as of this commit is unix_io and test_io if the
backing io_manager supports threading) will set the
CHANNEL_FLAGS_THREADS bit in io->flags.  Library code or applications
can test if threading is enabled by checking this flag.

Applications using libext2fs can pass in EXT2_FLAG_THREADS to
ext2fs_open() or ext2fs_open2() to request threading support.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoAdd configure and build support for the pthreads library
Theodore Ts'o [Thu, 14 Jan 2021 00:27:19 +0000 (16:27 -0800)]
Add configure and build support for the pthreads library

Support for pthreads can be forcibly disabled by passing
"--without-pthread" to the configure script.

The actual changes in this commit are in configure.ac and MCONFIG.in;
the other files were generated as a result of running aclocal,
autoconf, and autoheader on a Debian testing system.

Note: the autoconf-archive package must now be installed before
rerunning aclocal, to supply the AX_PTHREAD macro.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 years agoMerge branch 'maint' into next
Theodore Ts'o [Wed, 20 Jan 2021 04:58:57 +0000 (23:58 -0500)]
Merge branch 'maint' into next

3 years agomke2fs: Escape double quotes when parsing mke2fs.conf
Lukas Czerner [Mon, 2 Nov 2020 14:26:31 +0000 (15:26 +0100)]
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>
3 years agolibext2fs: add gnu.translator support
Romain Naour [Mon, 2 Nov 2020 13:03:19 +0000 (14:03 +0100)]
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>
3 years agofilefrag: handle invalid st_dev and blksize cases
Luis Henriques [Wed, 28 Oct 2020 15:55:50 +0000 (15:55 +0000)]
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>