Commit Graph

1934 Commits

Author SHA1 Message Date
Theodore Ts'o
915c3c1e05 Merge branch 'maint' into next 2022-08-13 23:50:46 -04:00
Theodore Ts'o
dc79c2ad59 e2image: checking the retval for the last update_refcount() is unnecessary
Addresses-Coverity-Bug: 709478
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-08-13 23:46:06 -04:00
Slava Bacherikov
47f9c3c00b tune2fs: allow disabling casefold feature
Casefold can be safely disabled if there are no directories with +F
attribute ( EXT4_CASEFOLD_FL ). This checks all inodes for that flag and in
case there isn't any, it disables casefold FS feature. When FS has
directories with +F attributes, user could convert these directories,
probably by mounting FS and executing some script or by doing it
manually. Afterwards, it would be possible to disable casefold FS flag
via tune2fs.

Link: https://lore.kernel.org/r/20220708122658.17907-1-slava@bacher09.org
Signed-off-by: Slava Bacherikov <slava@bacher09.org>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-08-12 22:38:35 -04:00
Theodore Ts'o
d05a33bd3e Merge branch 'maint' into next 2022-08-12 22:34:57 -04:00
Lukas Czerner
18ebcf26f4 e2fsprogs: fix device name parsing to resolve names containing '='
Currently in varisous e2fsprogs tools, most notably tune2fs and e2fsck
we will get the device name by passing the user provided string into
blkid_get_devname(). This library function however is primarily intended
for parsing "NAME=value" tokens. It will return the device matching the
specified token, NULL if nothing is found, or copy of the string if it's
not in "NAME=value" format.

However in case where we're passing in a file name that contains an
equal sign blkid_get_devname() will treat it as a token and will attempt
to find the device with the match. Likely finding nothing.

Fix it by checking existence of the file first and then attempt to call
blkid_get_devname(). In case of a collision, notify the user and
automatically prefer the one returned by blkid_get_devname(). Otherwise
return either the existing file, or NULL.

We do it this way to avoid some existing file in working directory (for
example LABEL=volume-name) masking an actual device containing the
matchin LABEL. User can specify full, or relative path (e.g.
./LABEL=volume-name) to make sure the file is used instead.

Link: https://lore.kernel.org/r/20220812130122.69468-1-lczerner@redhat.com
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Daniel Ng <danielng@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-08-12 22:32:14 -04:00
Theodore Ts'o
068eadd2c4 Merge branch 'maint' into next 2022-08-11 23:51:03 -04:00
Theodore Ts'o
7bb8da77e8 Avoid potential NULL dereference when argv[0]
Addresses-Coverity-Bug: 1500772
Addresses-Coverity-Bug: 1500769
Addresses-Coverity-Bug: 1500767
Addresses-Coverity-Bug: 1500758
Addresses-Coverity-Bug: 1500756
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-08-11 23:49:14 -04:00
Theodore Ts'o
6b3edcd191 Fix Coverity unintentional integer overflow warnings
Neither of these two warnings can actually happen (other limits will
be hit first), but widening the integer to a 64-bit unsigned integer
is an cheap and effective way to silence the Coverity warnings.

Addresses-Coverity-Bug: 1500760
Addresses-Coverity-Bug: 1507886
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-08-11 22:03:08 -04:00
Theodore Ts'o
350fcf8d6c Merge branch 'maint' into next 2022-08-07 21:31:18 -04:00
Theodore Ts'o
5cfdceb490 Fix UBSAN if s_log_groups_per_flex is 31
It is logal (albeit rare) for the number of block groups per flex_bg
to 2**31 (which effectively means to put all of the block groups into
a single flex_bg).  However, in that case "1 << 31" is undefined on
architectures with a 32-bit integer.  Fix this UBSAN complaint by
using "1U << 31" instead.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-08-07 19:49:33 -04:00
Theodore Ts'o
88ac43ed6a Merge branch 'maint' into next 2022-08-06 02:37:24 -04:00
zhanchengbin
ba18f6efec dumpe2fs, resize2fs: avoid memory leak on error path
Link: https://lore.kernel.org/r/cbfd9852-bc89-1e83-f101-36fd29a0e70e@huawei.com
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-05-11 20:56:17 -04:00
Andreas Dilger
63f265c857 misc: fix chattr usage message for project ID
Fix the "chattr -h" usage message to properly document that the
"-p" option takes a project argument, like "-v" takes a version.

Update the man page formatting to emphasize literal strings.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-05-02 20:22:02 -04:00
Lukas Czerner
f85b4526f6 tune2fs: implement support for set/get label iocts
Implement support for FS_IOC_SETFSLABEL and FS_IOC_GETFSLABEL ioctls.
Try to use the ioctls if possible even before we open the file system
since we don't need it. Only fall back to the old method in the case the
file system is not mounted, is mounted read only in the set label case,
or the ioctls are not suppported by the kernel.

The new ioctls can also be supported by file system drivers other than
ext4. As a result tune2fs and e2label will work for those file systems
as well as long as the file system is mounted. Note that we still truncate
the label exceeds the supported lenghth on extN file system family, while
we keep the label intact for others.

Update tune2fs and e2label as well.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-12-31 00:34:29 -05:00
Theodore Ts'o
8adeabeec7 Merge branch 'maint' into next 2021-12-30 10:59:52 -05:00
Theodore Ts'o
a01bb72980 mke2fs.conf.5: fix spelling errors in man page
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-12-29 21:33:27 -05:00
Sarthak Kukreti
bd2e72c5c5 mke2fs: add extended option for prezeroed storage devices
This patch adds an extended option "assume_storage_prezeroed" to
mke2fs. When enabled, this option acts as a hint to mke2fs that the
underlying block device was zeroed before mke2fs was called.  This
allows mke2fs to optimize out the zeroing of the inode table and the
journal, which speeds up the filesystem creation time.

Additionally, on thinly provisioned storage devices (like Ceph,
dm-thin, newly created sparse loopback files), reads on unmapped
extents return zero. This property allows mke2fs (with
assume_storage_prezeroed) to avoid pre-allocating metadata space for
inode tables for the entire filesystem and saves space that would
normally be preallocated for zero inode tables.

Tests
-----
1) Running 'mke2fs -t ext4' on 10G sparse files on an ext4
filesystem drops the time taken by mke2fs from 0.09s to 0.04s
and reduces the initial metadata space allocation (stat on
sparse file) from 139736 blocks (545M) to 8672 blocks (34M).

2) On ChromeOS (running linux kernel 4.19) with dm-thin
and 200GB thin logical volumes using 'mke2fs -t ext4 <dev>':

- Time taken by mke2fs drops from 1.07s to 0.08s.
- Avoiding zeroing out the inode table and journal reduces the
  initial metadata space allocation from 0.48% to 0.01%.
- Lazy inode table zeroing results in a further 1.45% of logical
  volume space getting allocated for inode tables, even if no file
  data is added to the filesystem. With assume_storage_prezeroed,
  the metadata allocation remains at 0.01%.

[ Fixed regression test to work on newer versions of e2fsprogs -- TYT ]

Signed-off-by: Sarthak Kukreti <sarthakkukreti@chromium.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-10-25 00:14:26 -04:00
Jan Kara
a8f525888f dumpe2fs, debugfs, e2image: Add support for orphan file
Print inode number of orphan file in outputs, dump e2image file to
filesystem image.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-09-30 21:59:09 -04:00
Jan Kara
795101dd0f tune2fs: Add support for orphan_file feature
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-09-30 21:59:09 -04:00
Jan Kara
818da4a904 mke2fs: Add support for orphan_file feature
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-09-30 21:59:09 -04:00
Jan Kara
d9612de393 tune2fs: Fix conversion of quota files
When tune2fs is enabling quota feature, it looks for old-style quota
files and tries to transfer limits stored in these files into newly
created hidded quota files. However the code doing the transfer setups
the quota scan wrongly and instead of transferring limits we transfer
usage. So not only quota limits are lost (at least they can still be
recovered from the old quota files) but also usage information may be
wrong if the accounting in e2fsprogs does not exactly match the
accounting in quota-tools (which is actually the case). Fix the setup of
the quota scan.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-09-03 14:34:58 -04:00
Jan Kara
5c87a5c54c quota: Rename quota_update_limits() to quota_read_all_dquots()
quota_update_limits() is a misnomer because what it actually does is
that it updates 'usage' counters and leaves 'limit' counters intact.
Rename quota_update_limits() to quota_read_all_dquots() and while
changing prototype also add a flags argument so that callers can control
which quota information is actually updated from the disk.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-09-03 14:34:58 -04:00
Theodore Ts'o
a64e0fd238 Fix miscellaneous spelling errors in man pages, and release notes
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-15 19:36:07 -04:00
Theodore Ts'o
e87bb84b4f Change "filesystem" to "file system" in the man pages
To improve consistency, use "file system" in all of the man pages in
preference over "filesystem".

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-15 19:36:06 -04:00
Theodore Ts'o
c6325aa8fe mke2fs: allow the default creator os to be specified in /etc/mke2fs.conf
This is useful for keeping the regression test results consistent
when run on non-Linux systems, especially on GNU Hurd.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-15 18:58:35 -04:00
Theodore Ts'o
e732c9fa1c mke2fs: warn that bigalloc is experimental only for large cluster sizes
Since we have done a lot of testing with a cluster size equal to 64k
(or 16 times the default 4k block size), mke2fs will only warn for
bigalloc file systems where the cluster size is greater than 16 times
the block size.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-14 15:16:09 -04:00
Darrick J. Wong
a23b50cdb5 mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
Filesystems with 128-byte inodes do not support timestamps beyond the
year 2038.  Since we're now less than 16.5 years away from that point,
it's time to start warning users about this lack of support when they
format an ext4 filesystem with small inodes.

(Note that even for ext2 and ext3, we changed the default for
non-small file systems in 2008 in commit commit b1631cce64 ("Create
new filesystems with 256-byte inodes by default").)

So change the mke2fs.conf file to specify 256-byte inodes even for
small filesystems, and then add a warning to mke2fs itself if someone
is trying to make us format a file system with 128-byte inodes.  This
can be suppressed by setting the boolean option warn_y2038_dates in
the mke2fs.conf file to false, which we do in the case of GNU Hurd,
since it only supports 128 byte inodes as of this writing.

[ Patch reworked by tytso to only warn in the case of GNU Hurd, since
  the default for ext2/ext3 was changed for all but small file systems
  in 2008. ]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-14 15:10:42 -04:00
Theodore Ts'o
838f94f263 mke2fs: fix a file descriptor leak when creating a file system image file
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-03 23:54:06 -04:00
Jan Kara
abbc58381d e2image: Dump quota files
Dump quota files to resulting filesystem image. They are fs metadata.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-08-03 11:50:32 -04:00
Zhiqiang Liu
c8e9e0135b lsattr: check whether path is NULL in lsattr_dir_proc()
In lsattr_dir_proc(), if malloc() return NULL, it will cause
a segmentation fault problem.

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-08-02 22:35:02 -04:00
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
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
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
7b8253ba09 Merge branch 'maint' into next 2020-10-01 17:13:27 -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
Eric Biggers
9a32973bd1 tune2fs.8: document the stable_inodes feature
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-04-10 11:23:12 -04:00
Eric Biggers
919003ba75 ext4.5: document the stable_inodes feature
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-04-10 11:23:12 -04:00
Eric Biggers
950002f7ce tune2fs: prevent stable_inodes feature from being cleared
Similar to encrypt and verity, once the stable_inodes feature has been
enabled there may be files anywhere on the filesystem that require this
feature.  Therefore, in general it's unsafe to allow clearing it.  Don't
allow tune2fs to do so.  Like encrypt and verity, it can still be
cleared with debugfs if someone really knows what they're doing.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-04-10 11:23:12 -04:00
Eric Biggers
b88883f787 tune2fs: prevent changing UUID of fs with stable_inodes feature
The stable_inodes feature is intended to indicate that it's safe to use
IV_INO_LBLK_64 encryption policies, where the encryption depends on the
inode numbers and thus filesystem shrinking is not allowed.  However
since inode numbers are not unique across filesystems, the encryption
also depends on the filesystem UUID, and I missed that there is a
supported way to change the filesystem UUID (tune2fs -U).

So, make 'tune2fs -U' report an error if stable_inodes is set.

We could add a separate stable_uuid feature flag, but it seems unlikely
it would be useful enough on its own to warrant another flag.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-04-10 11:23:12 -04:00
Theodore Ts'o
93df80d240 Teach makefiles to build all static programs using the target all-static
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-04-10 00:10:53 -04:00
Theodore Ts'o
1df6a45550 Use ext2_loff_t instead of loff_t
The loff_t type is a glibc'ism and is not fully portable.  Use
ext2_loff_t instead.

Fixes: 382ed4a1c2 ("e2fsck: use proper types for variables")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reported-by: Matthias Andree <matthias.andree@gmx.de>
2020-03-23 21:21:00 -04:00
Theodore Ts'o
8fd92e9af0 v1.45.6
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEK2m5VNv+CHkogTfJ8vlZVpUNgaMFAl52vlgACgkQ8vlZVpUN
 gaNKAAf+MBJpherF2KBs6F5ZMPJnhaansMHZ8EMsBoBvquxk7k2qf/28dVPt68gE
 qimIrbuvba2DDtpgxp5bbHE2mvsIW8uKolH9K3Py2zUk3f7L/3HLCdBiBhT6vLlm
 a2p7Bhsk9lDohE3TaBrfTl6oFfjThYM+sTc7tN6c9Nf7mZrJFPjACtZXlf3A7C8/
 PT8VmmKKSJUIw1zUObiWiOxtyCo8u/S3eJZlu1KeZv+i/MSBSJkmSYI/3nRVTuCe
 VCOuIcl9hzwZFZOAkvQUtZZJ+i89nYj8byKEDNK5hlhubx4J5v4yxFafJqychtc1
 CtERG4PdGAqZtp+YjhhJ3dNvkZxRAg==
 =5Fdh
 -----END PGP SIGNATURE-----

Merge tag 'v1.45.6' into next

v1.45.6
2020-03-21 22:34:30 -04:00
Jaegeuk Kim
247973bcc4 AOSP: tune2fs, resize2fs: make ramdisk binaries.
Bug: 149391799
Change-Id: I5183755915710e28a603e3f718f16813ea9991a0
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
From AOSP commit: a13a88d0d557a396f63702fb8db008487e2384d7
2020-03-20 23:19:24 -04:00
Alessio Balsini
d4197585fa AOSP: Build e2freefrag
Enable the build of e2freefrag to monitor the free space fragmentation
in ext2/3/4 filesystems.

Bug: 146078546
Test: m + e2freefrag on device
Change-Id: Ia56e443a789ae881a03bdaeae1093567e1736c4c
Signed-off-by: Alessio Balsini <balsini@google.com>
From AOSP commit: ab77f6c79f3dab697cd56ad3b793e7d555ac9415
2020-03-20 23:13:52 -04:00
Elliott Hughes
470e78ae21 AOSP: Add -e2fsprogs to the e2fsprogs chattr and lsattr.
We want to start shipping the toybox chattr and lsattr on the device all
the time, so the build system rightly complains that then we'd have two
modules with the same name.

I went with a suffix rather than a prefix so that tab completion works
for folks still wanting to use the e2fsprogs versions.

Bug: http://b/147769529
Test: builds
Change-Id: Ib904fa6c709d29ce709302c61e452383c02cb9a3
From AOSP commit: 8525a455e7410461560a99a42feb0dbfabab5c8e
2020-03-20 23:12:24 -04:00
Theodore Ts'o
4346f675bf misc: add text describing the impact of an inode size < 128 bytes in man pages
Addresses-Debian-Bug: #953493
Addresses-Debian-Bug: #953494
Addresses-Debian-Bug: #951808
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-03-20 21:35:03 -04:00
Theodore Ts'o
1126208873 Merge branch 'maint' into next 2020-03-16 07:59:08 -04:00
Jan Kara
514fde0296 tune2fs: update dir checksums when clearing dir_index feature
When clearing dir_index feature while metadata_csum is enabled, we have
to rewrite checksums of all indexed directories to update checksums of
internal tree nodes.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-03-15 12:52:52 -04:00
Sawood Alam
6e315c931f misc: fix typos in chattr's man page
Plural form "directories" should be used along with "files".
"id's" should be "ids" (i.e., plural form, not apostrophe).
"much" should "must".

Signed-off-by: Sawood Alam <ibnesayeed@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-03-10 11:52:27 -04:00
Pino Toscano
693e05942a mke2fs.conf: remove options.fname_encoding
Introduced with commit e7236a9476,
it was later renamed to encoding, and turned into a fs_type-only
option with commit 28887533bb.

Hence, remove an option that does not exist in the default
configuration.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-03-09 12:36:10 -04:00
Theodore Ts'o
b84a5568c7 Merge branch 'maint' into next 2020-03-07 13:13:55 -05:00
Theodore Ts'o
f106b01c98 mke2fs: fix permissions setting with "mke2fs -d /path/files"
Set the directory for directories in cases where the owner permissions
is not rwx.  This was reported[1] by Robert Yang but we are using a
different approach to fixing the issue.

[1] https://lore.kernel.org/r/1582542522-97508-1-git-send-email-liezhi.yang@windriver.com

Also set the permissions in a more portable way by making a
distinction between the host OS's permissions stats and Linux's
permissions.  We still assume the low 12 bits are the historical Unix
assignments, but we don't assume ST_IFMT bits are the same as Linux's.

Reported-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-03-07 12:42:39 -05:00
Andreas Dilger
e08226c708 misc: handle very large files with filefrag
Avoid overflowing the column-width calc printing files over 4B blocks.

Document the [KMG] suffixes for the "-b <blocksize>" option.

The blocksize is limited to at most 1GiB blocksize to avoid shifting
all extents down to zero GB in size.  Even the use of 1GB blocksize
is unlikely, but non-ext4 filesystems may use multi-GB extents.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-03-04 18:26:09 -05:00
Andreas Dilger
102993ec1c e2fsck: fix overflow if more than 4B inodes
Even though we don't have support for filesystems with over 4B inodes
in the current e2fsprogs, this may happen in the future.  There are
latent overflow bugs when calculating the number of inodes in the
filesystem that can trivially be fixed now, rather than waiting for
them to be hit at some point in the future.  The block number calcs
are already correct in this code.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-02-29 18:34:54 -05:00
Andreas Dilger
382ed4a1c2 e2fsck: use proper types for variables
Use ext2_ino_t instead of ino_t for referencing inode numbers.
Use loff_t for for file offsets, and dgrp_t for group numbers.

Cast products to ssize_t before multiplication to avoid overflow.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Shilong Wang <wshilong@ddn.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-02-29 18:26:38 -05:00
Jeremy Visser
a5676f8da7 chattr.1: improve attribute formatting with labels and indented paragraphs
By convention, lists of options in man pages use a label followed by an
indented description, such as this example from the Options section:

     -R     Recursively change attributes of directories and
            their contents.

But the Attributes section places the available attributes mid-sentence,
which makes it visually more difficult to parse:

     A file with the 'a' attribute set can only be opened
     in append mode for writing.  [...]

     When a file with the 'A' attribute set is accessed, its
     atime record is not modified.  [...]

This patch places a label beside each attribute description, which (in
my opinion) improves readability, especially when visually skimming the
list.  For example:

     a      A file with the 'a' attribute set can only be
            opened in append mode for writing.

     A      When a file with the 'A' attribute set is accessed,
            its atime record is not modified.

Signed-off-by: Jeremy Visser <jeremyvisser@google.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-02-24 15:31:16 -05:00
Li Dongyang
59037c5357 mke2fs: set overhead in super block
If overhead is not recorded in the super block, it is calculated
during mount in kernel, for bigalloc file systems it takes
O(groups**2) in time.  For a 1PB device with 32K cluster size it takes
~12 mins to mount, with most of the time spent on figuring out
overhead.

While we can not improve the overhead algorithm in kernel due to the
nature of bigalloc, we can work out the overhead during mke2fs and set
it in the super block, avoiding calculating it every time when it
mounts.

Overhead is s_first_data_block plus internal journal blocks plus the
block and inode bitmaps, inode table, super block backups and group
descriptor blocks for every group.  This patch introduces
ext2fs_count_used_clusters(), which calculates the clusters used in
the block bitmap for the given range.

When bad blocks are involved, it gets tricky because the blocks
counted as overhead and the bad blocks can end up in the same
allocation cluster.  In this case we will unmark the bad blocks from
the block bitmap, convert to cluster bitmap and get the overhead, then
mark the bad blocks back in the cluster bitmap.

Reset the overhead to zero when resizing, we can not simply count the
used blocks as overhead like we do when mke2fs.  The overhead can be
calculated by kernel side during mount.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-01-26 23:10:05 -05:00
Theodore Ts'o
0b47dde9fd Merge branch 'maint' into next 2020-01-25 03:07:05 -05:00
Andreas Dilger
bc56227376 mmp: abstract out repeated 'sizeof(buf), buf' usage
The printf("%.*s") format requires both the buffer size and buffer
pointer to be specified for each use.  Since this is repeatedly given
as "(int)sizeof(buf), (char *)buf" for mmp_nodename and mmp_bdevname
fields, with typecasts to avoid compiler warnings.

Add a helper macro EXT2_LEN_STR() to avoid repeated boilerplate code.

This can also be used for other superblock buffer fields that may not
have NUL-terminated strings (e.g. s_volume_name, s_last_mounted,
s_{first,last}_error_func, s_mount_opts) to simplify code and avoid
the need for temporary buffers for NUL-termination.

Annotate the superblock string fields that may not be NUL-terminated.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-01-24 23:06:58 -05:00
Andreas Dilger
6b430d60ca mmp: don't assume NUL termination for MMP strings
Don't assume that mmp_nodename and mmp_bdevname are NUL terminated,
since very long node/device names may completely fill the buffers.

Limit string printing to the maximum buffer size for safety, and
change the field definitions to __u8 to make it more clear that
they are not NUL-terminated strings, as is done with other strings
in the superblock that do not have NUL termination.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-01-24 23:06:58 -05:00
Theodore Ts'o
a320a1c6a0 filefrag: add -E option to display the extent status cache
Ext4 has an extent status cache; add the fiemap extensions so we can
query the kernel for the extent status cache information.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-01-23 10:46:10 -05:00
Theodore Ts'o
32d33132a8 Merge branch 'maint' into next 2020-01-02 10:59:13 -05:00
Li Dongyang
d23f88ebaa mke2fs: fix setting bad blocks in the block bitmap
We mark the bad blocks as used on fs->block_map before allocating
group tables.  Don't translate the block number to cluster number when
doing this, the fs->block_map is still a block-granularity allocation
map, it will be coverted later by ext2fs_convert_subcluster_bitmap().

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-01-01 13:41:35 -05:00
Benno Schulenberg
6607eaad26 e2image: remove redundant -fr from man page and usage message
Also, add a missing dash and two missing brackets and two missing
spaces, and remove three excess spaces.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-01-01 13:41:35 -05:00
Theodore Ts'o
3a15d85bfb ext2fs: add ext2fs_get_stat_i_blocks() function
The function ext2fs_inode_i_blocks() is a bit confusing whether it is
returning the inode's i_blocks value, or whether it is returning the
value ala the stat(2) system call, which returns i_blocks in units of
512 byte sectors.  This caused ext2fs_inode_i_blocks() to be
incorrectly used in fuse2fs and the function quota_compute_usage().

To address this, we add a new function, ext2fs_get_stat_i_blocks()
which is clearly labelled what it is returning, and use it in fuse2fs
and quota_compute_usage().  It's also a bit more convenient to use it
in e2fsck, so use it there too.

Reported-by: Wang Shilong <wangshilong1991@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2020-01-01 13:41:28 -05:00
Theodore Ts'o
dae1ecc244 fuse2fs: add support for 32-bit uids and gids
Previously, uids were truncated at 16 bits because we weren't properly
handling i_uid_high and i_gid_high.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-12-20 15:16:09 -05:00
Theodore Ts'o
23f94dde25 mke2fs: fix "mke2fs -d /path/to/files" to support 32-bit uids and gids
https://github.com/tytso/e2fsprogs/issues/29

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-12-20 14:58:41 -05:00
Theodore Ts'o
523219f20a Merge branch 'maint' into next 2019-11-22 23:30:37 -05:00
Theodore Ts'o
bb7a3dc251 Add a program to test images provided by UBSAN fuzzing reports
This program calls a few ext2fs library functions used by the current
generation of libext2fs fuzzers, and is helpful in reproducing UBSAN
failures reported externally.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-22 23:27:47 -05:00
Darrick J. Wong
3f21d82395 tune2fs: prohibit toggling uninit_bg on live filesystems
An internal customer followed an erroneous AskUbuntu article[1] to try to
change the UUID of a live ext4 filesystem.  The article claims that you
can work around tune2fs' "cannot change UUID on live fs" error by
disabling uninit_bg, changing the UUID, and re-enabling the feature.

This led to metadata corruption because tune2fs' journal descriptor
rewrite races with regular filesystem writes.  Therefore, prevent
administrators from turning on or off uninit_bg on a mounted fs.

[1] https://askubuntu.com/questions/132079/how-do-i-change-uuid-of-a-disk-to-whatever-i-want/195839#459097

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-20 22:58:55 -05:00
Eric Biggers
446483e398 chattr.1: say "cleared" instead of "reset"
Setting a bit to 0 is normally called "clearing", not "resetting"; and
chattr.1 already says "clear" in some places.  Use "clear" consistently.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-18 12:14:33 -05:00
Eric Biggers
f08f1c6492 chattr.1: clarify that ext4 doesn't support tail-merging either
This old text was never updated to mention ext4 in addition to ext2 and
ext3.  Do so now.  Also don't bother to mention old unmerged patches.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-18 12:14:33 -05:00
Eric Biggers
26d6e57c5c chattr.1: fix some grammatical errors
- "can only be open" => "can only be opened"
- "is not candidate" => "is not a candidate"
- "written ... on the disk" => "written ... to the disk"

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-18 12:14:33 -05:00
Eric Biggers
6e58704680 chattr.1: add casefold attribute to mode string
When the casefold attribute ('F') was added to the chattr man page, it
was forgotten to add it to the mode string.  Add it.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-18 12:14:33 -05:00
Eric Biggers
93cea43534 chattr.1: adjust documentation for encryption attribute
Adjust the documentation for the encryption attribute ('E') to clarify
that encryption isn't experimental anymore and isn't restricted to
regular files, and that the encryption is done by the filesystem.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-18 12:14:33 -05:00
Eric Biggers
be335e31e7 chattr.1: document the verity attribute
Document the verity file attribute ('V').

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-18 12:14:33 -05:00
Theodore Ts'o
8335d3c57e Rename functions, types, constants to reflect jbd2 usage
We had previously stuck to using the names from ext3/jbd kernel files,
and used a script in contrib/jbd2-resync.sh to convert the kernel
files to use the ext3/jbd conventions so we could keep the files
e2fsck/recovery.c and e2fsck/revoke.c in sync with jbd2/recovery.c and
jbd2/revoke.c, respectively.

This has been getting harder and harder, so let's make a global sweep
through e2fsprogs to use the jbd2 names.  Fortunately none of the
ext3/jbd names had leaked out into publically exported header files,
so this is only an internal change.  Which looks scary, but it's
basically a search and replace, so if it compiles it's going to be
correct.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-09 01:55:14 -05:00
Theodore Ts'o
c74660ceee Merge branch 'maint' into next 2019-11-06 22:33:11 -05:00
Theodore Ts'o
6dac306792 Fix UBSan when shifting (1LL << 63)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-11-04 21:22:54 -05:00
Eric Biggers
2d2d00c6c6 AOSP: support the stable_inodes feature
Reserve the codepoint for EXT4_FEATURE_COMPAT_STABLE_INODES, allow it to
be set and cleared, and teach resize2fs to forbid shrinking the
filesystem if it is set.

This feature will allow the use of encryption policies where the inode
number is included in the IVs (initialization vectors) for encryption,
so data would be corrupted if the inodes were to be renumbered.

For more details, see the kernel patchset:
https://lkml.kernel.org/linux-fsdevel/20191021230355.23136-1-ebiggers@kernel.org/T/#u

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
From AOSP commit: 9aa30c254dd57df54f00c5d520b7ac867ad7ca68
2019-10-31 19:32:27 -04:00
Theodore Ts'o
e6069a05da Teach ext2fs_open2() to honor the EXT2_FLAG_SUPER_ONLY flag
Opening the file system with EXT2_FLAG_SUPER_ONLY will leave
fs->group_desc to be NULL and modify "dumpe2fs -h" and tune2fs when it
is emulating e2label to use this flag.  This speeds up "dumpe2fs -h"
and "e2label" when operating on very large file systems.

To allow other libext2fs functions to work without too many surprises,
ext2fs_group_desc() will read in the block group descriptors on
demand.  This allows "dumpe2fs -h" to be able to read the journal
inode, for example.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cray-bug-id: LUS-5777
2019-10-22 18:55:06 -04:00
Theodore Ts'o
26aa2f1774 Enable support for the fast_commit compat feature
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-10-03 22:17:18 -04:00
Theodore Ts'o
601daaf985 v1.45.4
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEK2m5VNv+CHkogTfJ8vlZVpUNgaMFAl2JP+oACgkQ8vlZVpUN
 gaMx9Qf5AQQ6azsqvTr2e2ptgMafguY103Yi9ebefA1l4l4UISyE0tHYABpuyzfx
 4YoGUIR2QRff6XPyAmO9ADcePNOE2b6X6Xco+D5wZy1qZ+KgGjNO1gfALvH6JjSr
 f8inw437ub1kthzSyLBmc3MkjDQOsWSTInbVxgJkGG97zt0vx0tX4bEh95O/BbeX
 5ZjItbhZp16ecAOhwBTEoDoXXeKOKNOTv9p6vkbgbyuh0RjdkZ5/l/y9ZHZXywnV
 qK8DmmHQw2KC0vbmUOFO7nV+MQh1dhMNaDRRrwLv+Mf22Jd4PzpWG11uti49+fF3
 Qrct65kSMcqtBmYTQ34XHlot3lEpFw==
 =LqKO
 -----END PGP SIGNATURE-----

Merge tag 'v1.45.4' into next

v1.45.4
2019-09-23 18:29:14 -04:00
Eric Biggers
040cd2479d tune2fs.8: tweak the documentation for the encrypt feature
Try to make it clearer that enabling 'encrypt' just enables *support*
for encryption; it doesn't actually encrypt anything by itself.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-09-23 13:28:36 -04:00
Eric Biggers
5f1e5f5e88 tune2fs.8: document the verity feature
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-09-23 13:28:36 -04:00
Eric Biggers
4ef530d95a ext4.5: tweak the documentation for the encrypt feature
Try to make it clearer that enabling 'encrypt' just enables *support*
for encryption; it doesn't actually encrypt anything by itself.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-09-23 13:28:36 -04:00
Eric Biggers
4cc90574e4 ext4.5: document the verity feature
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-09-23 13:28:36 -04:00
Eric Biggers
4ecbee2cfd ext4.5: document first kernel version to support casefold feature
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-09-23 13:28:36 -04:00
Eric Biggers
fea937ee09 ext4.5: move casefold feature to correct position
The features are listed in alphabetic order, so put the casefold feature
in the right place.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-09-23 13:28:36 -04:00
Theodore Ts'o
75e3a9ef4c fuse2fs: add a norecovery option which suppresses journal replay
Teach fuse2fs the "-o norecovery" option, which will suppress any
journal replay that might be necessary, and mounts the file system
read-only.

Addresses-Debian-Bug: #878927

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-08-18 20:25:53 -04:00
Theodore Ts'o
aa6d326079 fuse2fs: stop using the nonempty option by default
The nonempty option isn't supported by fuse3, and so if fusermount is
from fuse3, having fuse2fs specify nonempty automatically will prevent
fuse2fs from working correctly.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-07-14 12:03:29 -04:00
Theodore Ts'o
b71150355d fuse2fs: install fuse2fs in /usr/bin instead of /usr/sbin
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-07-14 11:05:47 -04:00
Theodore Ts'o
c2eedf431e Fix posix_memalign and posix_fadvise calls.
Almost all posix_ functions return a positive errno value (without
setting errno) rather than -1 and setting errno. Most calls in this
project were correct, but these two weren't.

Reported-by: Hughes <enh@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-06-07 13:07:12 -04:00
Theodore Ts'o
0e0dad426a mke2fs: accept the english yes character to the proceed question
In some cases if the translation file is missing some translations,
mke2fs can end up printing an English message, e.g.:

% LANG=it_IT.UTF-8 ./mke2fs /tmp/foo.img 8M
mke2fs 1.45.1 (12-May-2019)
/tmp/foo.img contiene un file system ext4
	created on Mon May 27 19:35:48 2019
Proceed anyway? (y,N)

However, if there is a translation for string to match with "yY"
(e.g., to "sS" for Italian), then 'y' won't work.  Fix this by falling
back to the english 'yY' characters.

Addresses-Debian-Bug: #907034
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-05-27 19:36:15 -04:00
Theodore Ts'o
6cfb145e34 mke2fs: fix memory leak when parsing encoding flags
Also fix extended-options usage string.

Addresses-Coverity-Bug: 1444984
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-05-12 02:23:08 -04:00
Andreas Dilger
f6cf3e6193 mke2fs: fix check for absurdly large devices
The check in mke2fs is intended to be for the number of blocks in the
filesystem exceeding the maximum number of addressable blocks in 2^32
bitmaps, which is (2^32 * 8 bits/byte * blocksize) = 2^47 blocks,
or 2^59 bytes = 512PiB for the common 4KiB blocksize.

However, s_log_blocksize holds log2(blocksize_in_kb), so the current
calculation is a factor of 2^10 too small.  This caused mke2fs to fail
while trying to format a 900TB filesystem.

Fixes: 101ef2e93c ("mke2fs: Avoid crashes / infinite loops for absurdly large devices")
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-05-06 10:15:41 -04:00
Theodore Ts'o
28887533bb Rename the feature "fname_encoding" to be "casefold".
Also change mke2fs so that the encoding and encoding flags are
specified in mke2fs.conf in the fs_types and defaults stanzas instead
of the options stanza.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-05-03 13:16:29 -04:00