Commit Graph

6263 Commits

Author SHA1 Message Date
Theodore Ts'o
cc8df47c83 debugfs: teach set_super_value how to set the s_encoding field
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-05-02 13:19:01 -04:00
Theodore Ts'o
5a7761e88f libe2p: print the filename character encoding in list_super[2]
Also clean up some gcc -Wall warnings while we're at it.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-05-02 12:16:16 -04:00
Theodore Ts'o
3f85a4c9a8 libext2fs: remove utf8_* namespace contamination
Merge nls_utf8-norm.c and nls_utf8.c.  This also allows us to comment
out functions which we don't actually need for e2fsprogs.

Also fix some gcc -Wall complaints, including one which would have
caused utf8_casefold() to misbehave (this was fixed in the kernel, but
not carried back to e2fsprogs).

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-29 09:18:47 -04:00
Theodore Ts'o
388e1d56d9 libext2fs: remove nls_* namespace contamination
Also remove nls.h, and avoid declaring static functions and variables
in a header file, which is wasteful of space.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-29 09:18:12 -04:00
Eric Biggers
ca82f176f1 libext2fs: remove unused variable 'old_flags'
In ext2fs_write_inode2(), the 'old_flags' variable is never used.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 20:37:45 -04:00
Eric Biggers
8817d2542e debugfs: remove unused variable 'tmp_inode'
In parse_inode_csum(), the outer 'tmp_inode' variable is never used.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 20:37:21 -04:00
Eric Biggers
094507fded libext2fs: remove unused variable 'buff'
In ext2fs_dirhash2(), the outer 'buff' variable is never used.

Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 20:36:30 -04:00
Eric Biggers
a003778998 debugfs: fix encoding handling in dx_hash command
Fix the following bugs:

1. 'encoding' and 'hash_flags' are not initialized, causing a segfault.

2. 'hash_flags' incorrectly uses a __bitwise type.

3. The optstring doesn't contain "c" or "e", so the -c and -e options
   aren't recognized.

4. The code that handles the -e option always returns.

Fixes: ef733f1a97 ("debugfs: support encoding when printing the file hash")
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 20:35:25 -04:00
Eric Biggers
9033a31e26 debugfs: avoid ambiguity when printing filenames
The way debugfs escapes filenames is ambiguous because a sequence like
M-A can mean either the byte 'A' + 128 == 0xc1 or the three bytes
{'M', '-', 'A'}.  Similarly, ^A can mean either the byte
'A' ^ 0x40 == 0x01 or the two bytes {'^', 'A'}.

Fix this and simplify the code by switching to a simpler strategy where
all bytes < 32, all bytes >= 127, and backslash are encoded with C-style
hex escape sequences.  E.g., the byte 0xc1 will now be encoded as \xc1
rather than M-A as it was before, while a filename consisting of the
three bytes {'M', '-', 'A'} will continue to be shown as M-A.

I want to fix this mainly because I want to use debugfs to retrieve raw
encrypted filenames for ciphertext verification tests.  But this doesn't
work if the returned filenames are ambiguous.

Fixes: 68a1de3df3 ("debugfs: pretty print encrypted filenames in the ls command")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 19:42:41 -04:00
Gabriel Krisman Bertazi
1384050b7a ext4.5.in: document design changes on the casefold attribute
Document the fact that the encoding support is only used by directories
with the +F attribute.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 16:53:08 -04:00
Gabriel Krisman Bertazi
f61719cf47 ext2fs: drop ASCII NLS support
As agreed on the kernel side, ext4 will only support utf8 for now, and
not plain ASCII, so we don't need this anymore.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 16:52:12 -04:00
Gabriel Krisman Bertazi
1b6d59d699 ext2fs: drop Unicode normalization support
No longer necessary after +F design change.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 16:48:01 -04:00
Gabriel Krisman Bertazi
a8567fdb93 ext2fs: don't normalize names on -F directories
As agreed on the new design, even if fname_encoding is enabled,
directories entries who aren't owned by a +F directory will not be
normalized.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 16:45:41 -04:00
Gabriel Krisman Bertazi
a7fba47ef0 ext2fs: nls: Update to unicode 12.1.0
Since we didn't release a kernel version that supports version 11.0.0,
it should be safe to reuse the sb entry for version 12.1.0.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 16:39:22 -04:00
Gabriel Krisman Bertazi
6790d66c18 ext2fs: merge sparse fixes for unicode normalization
The sparse script complained about the following issues in the kernel
version of this script.  This patch port the fixes to the userspace
version.

sparse warnings: (new ones prefixed by >>)

>> fs/unicode/utf8-norm.c:41:24: sparse: non-ANSI function declaration
   of function 'utf8version_latest'

vim +/utf8version_latest +41 fs/unicode/utf8-norm.c

  40
> 41	int utf8version_latest()
  42	{
  43		return utf8vers;
  44		}
  45	EXPORT_SYMBOL(utf8version_latest);
  46

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 15:12:12 -04:00
Gabriel Krisman Bertazi
dea1e527eb ext2fs: fix potential null dereference in utf8nlookup
Delay the access of data->offset until after the null check.  This was
reported by 0-day on the kernel version of the script.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 15:10:50 -04:00
Gabriel Krisman Bertazi
3e1c513a73 ext2fs: convert unicode normalization from NFKD -> NFD
Following the kernel transition, convert the normalization format from
NFKD to NFD.  This also regenerates the utf8data.h database.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 15:08:44 -04:00
Gabriel Krisman Bertazi
0a8b31cab9 ext2fs: always attempt to load nls table when loading the filesystem
fs->encoding is exposed by the library, so we need to at least try to
load it when populating ext2_filsys.  Nevertheless, failing to do so
shouldn't be a fatal error, unless the user really needs that
information.  Thus, we ignore this failure during open/initialization
and let the user who needs it validate that field before trying to use
it.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 15:06:27 -04:00
Gabriel Krisman Bertazi
c554f5558c e2p: encoding: fix default flags lookup
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-28 15:04:33 -04:00
Elliott Hughes
eb5b037f98 AOSP: Turn off some more warnings on Windows.
Test: builds
Change-Id: Ieb0f34ba444f608ec3fdf89aa61a93b4ac312af4
From AOSP commit: 88a90b52f836bc4aaba231857f1e4facf0a25959

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-04-22 13:35:03 -04:00
Theodore Ts'o
cecc2bc78b debugfs: fix printing of xattrs with ea_in_inode values
Due to a missing "else" debugfs was printing (garbage) from the xattr
buffer which could potentially overrun the end of the buffer.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-26 09:36:53 -04:00
Theodore Ts'o
5a64e93078 tests: fix f_valid_ea_in_inode to use the ea_feature
This time for real!  The test-ea file has three very long xattrs,
description and description2 which are identical and share an inode to
store their value, and description3, which has a different value, and
thus uses another inode for storing its value.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-24 02:36:08 -04:00
Theodore Ts'o
e97d4c46a4 e2scrub,e2scrub_all: print a (more understandable) error if not run as root
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-21 18:11:37 -04:00
Darrick J. Wong
c7d6525eca e2scrub_all: refactor device probe loop
Paul Menzel reported that the e2scrub_all reaper service that runs at
startup takes a long time to run, and Ted Ts'o pointed out that we could
do a lot less work by using lvs as the outer loop in the ext4 filesystem
probe function so that we only have to lsblk the lvm devices containing
ext4 filesystems.

Therefore, refactor the loops to put lvs first, which should boost speed
a bit.

[ Made some of the further optimizations suggested by Lukas Czerner.  -- TYT ]

Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-21 18:10:50 -04:00
Theodore Ts'o
c120312253 e2scrub_all: make sure there's enough free space for a snapshot
If there isn't, skip the volume so we don't spam the system
administrator with error messages.  It's quite commkon that there is
is zero free space in the volume group.

Addresses-Debian-Bug: #924301

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-21 11:30:09 -04:00
Theodore Ts'o
fbd0c83877 e2scrub_all: add the -n option which shows what e2scrub_all would do
Also fix the copyright symbol so it is properly formatted when
processed into postscript or pdf.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-21 11:29:40 -04:00
Theodore Ts'o
02bfc2d3ff e2scrub: add the -n option which shows what commands e2scrub would execute
Also fix the copyright symbol so it is properly formatted when
processed into postscript or pdf.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-21 11:26:58 -04:00
Theodore Ts'o
e9fa167b8e e2scrub: fix up "make install-strip" support
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-17 18:50:37 -04:00
Theodore Ts'o
a7e3e13cb0 Merge branch 'old-maint' into maint 2019-03-17 18:50:20 -04:00
Theodore Ts'o
8a07e301cb Fix "make install-strip"
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-17 18:46:26 -04:00
Theodore Ts'o
212ba2a8a8 debian: drop lvm2 from the recommends line
If the user doesn't intend to use lvm2, and it's not installed,
installing e2fsprogs shouldn't drag it (and all of its dependencies)
into the system.

Addresses-Debian-Bug: 924275

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-10 20:01:58 -04:00
Theodore Ts'o
04738f2ff3 e2scrub: check to make sure lvm2 is installed
Not all systems will have the lvm2 package installed, so check for
that.  Pretty much all systems should have util-linux installed, but
check for that as well.

Of course, if lvm2 is installed we shouldn't find any LVM devices ---
but eventually the Demon Murphy will find a way to make it happen. :-)

Also, set the PATH so we don't have to worry about the script failing
due to /sbin not being in the path.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-10 19:52:25 -04:00
Theodore Ts'o
2fe97b2bd0 Merge branch 'old-maint' into maint 2019-03-07 16:18:10 -05:00
Dongyang Li
f72ea2deb0 Fix autoheader warnings
autoheader complains after 1.44.6 release:
autoheader: warning: missing template: HAVE_BLKID_PROBE_ENABLE_PARTITIONS
autoheader: Use AC_DEFINE([HAVE_BLKID_PROBE_ENABLE_PARTITIONS], [], [Description])
autoheader: warning: missing template: HAVE_BLKID_PROBE_GET_TOPOLOGY

This could fail automatic rpm builds.
Fixes: 7154d97 ("Check for the newer blkid functions without adding blkid to @LIBS@")

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-07 16:09:20 -05:00
Theodore Ts'o
68e00dc507 Update release notes, etc., for the 1.45.0 release
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-07 00:40:14 -05:00
Theodore Ts'o
e8c6459ceb e2scrub: install the crontab file in /etc/cron.d w/o the .cron extension
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-07 00:40:14 -05:00
Theodore Ts'o
48cc00797c e2scrub: make e2scrub_fail's e-mail addresses be configurable
Allow the sender and recipient e-mail addresses be configurable from
/etc/e2scrub.conf.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-07 00:12:49 -05:00
Theodore Ts'o
198cbd4595 e2scrub: add missing Documentation links to systemd unit files
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 22:20:35 -05:00
Theodore Ts'o
f680342869 misc: fix spelling error
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 22:20:31 -05:00
Theodore Ts'o
366aa03ff0 scrub/Makefile.in: install the udev rule and crontab file as data files
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 22:17:57 -05:00
Theodore Ts'o
137ef38942 Don't use a symlink for config/ltmain.sh
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 22:17:57 -05:00
Theodore Ts'o
f0fbca14e1 Fix "make clean" so it removes all generated files in the scrub directory
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 13:18:57 -05:00
Theodore Ts'o
ecf97bfbd7 Update Makefile.in files using "make depend"
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 13:14:19 -05:00
Artem Blagodarenko
4d562d94c6 tests: add test for e2image -b option
The test makes raw image from partition with broken super block
and executes e2fsck.

Signed-off-by: Artem Blagodarenko <c17828@cray.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 11:57:00 -05:00
Artem Blagodarenko
3f3e455f02 e2image: add -b and -B options to specify where to find the superblock
e2image has no ability to use superblock backup to copy metadata.
This feature can be useful if someone wants to make partition
image and fix it using e2fsck utility.

New -b option allows to pass superblock number, like e2fsck utility does.
e2image doesn't change primary superblock and store it as is, so
it can be fixed using e2fsck latter. Option -B allows setting
superblock size.

Signed-off-by: Artem Blagodarenko <c17828@cray.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-06 11:52:18 -05:00
Theodore Ts'o
731661a739 Merge branch 'maint' into next 2019-03-06 00:06:42 -05:00
Theodore Ts'o
a92fbdd9a6 Update release notes, etc., for the 1.44.6 release
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-05 15:11:11 -05:00
Yoshitaka Seto
f6f4b4b39f AOSP: misc: use scandir with alphasort instead of readdir for consistency
During the image generation, When using the e2fsdroid with src_dir,
then dir files are listed with readdir, which will not guarantee
the order across the machines/fielsystems. So instead using the
scandir with alphasort option to list the files in sorted order.

Bug: 122874817

Change-Id: I4b946c737319252b82c74a0e10360843503862a1
From AOSP commit: 4cbe059b48b46d6657e24e4cdef543da7537dba3

Reported-by: Yasuhiro Kubota <yasuhiro.1.kubota@sony.com>
Tested-by: Yasuhiro Kubota <yasuhiro.1.kubota@sony.com>
Signed-off-by: Vikram Dattu Thota <vikram.dattu@sony.com>
Signed-off-by: Takuya Ogawa <takuya.ogawa@sony.com>
Signed-off-by: Yoshitaka Seto <yoshitaka.seto@sony.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-03-05 13:06:12 -05:00
Chen Lin Z
66bae937b9 AOSP: Fix file offset overflow issue when file's size > 4G
fs->blocksize is int(4 bytes), while data is off_t(8 bytes),
'data_blk = data & ~(fs->blocksize - 1)' will cause data_blk
lose high 4 bytes of data if data > 4G and it'll cause file
inconsistent when using -d option to populate ext4 image file.

[ This was also fixed upstream via 1eec741367: "create_inode: fix
  copying large files".  This commit is just to clean up
  whitespace/formatting issues. -- tytso ]

Signed-off-by: Chen Lin Z <lin.z.chen@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
From AOSP commit: 999dd56f2586fadec7bfe846b8cb52c5e528248f
2019-03-05 12:56:45 -05:00
Darrick J. Wong
ab58911058 libext2fs: revert "try to always use PUNCH_HOLE for unix_discard"
Revert bcca9876a3, because
fallocate(PUNCH_HOLE) on block devices was changed to use zeroout
instead of discard shortly after block device fallocate was merged.
zeroout isn't necessarily a "drop storage" operation like discard is,
so we prefer to use that on block devices.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-02-14 16:02:33 -05:00