debugfs now links to a new libext2_support library, which only includes
cstring.c (Android separates other pieces of libsupport into separate
libraries).
e2fsck now builds with -Wno-unused-variable to work around an unused
variable introduced by cabde4999d.
libext_e2p builds the new ljs.c file, and links to ws2_32 on Windows for
ntohl().
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Change-Id: I42edce0478f1529f44acdbef1495ec5270e3a61e
From AOSP commit: af14814afe0cb3389ecc4b9e9422bd7e8962e0ed
Due to hard links inodes can have multiple names (except for folders),
ncheck should find all of the names (equal to the number of links to the
inodes, directories excepted), not names to the count of the provided
inodes.
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-Wimplicit-fallthrough option was added in gcc7 and
-Wpedantic was added in gcc4.8, while #pragma GCC diagnostic
support was not available until gcc4.6
We got following warnings:
../lib/ext2fs/fiemap.h:35: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
../lib/ext2fs/fiemap.h:36: warning: unknown option after ‘#pragma GCC diagnostic’ kind
../lib/ext2fs/fiemap.h:38: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
and error:
filefrag.c: In function ‘main’:
filefrag.c:577: error: #pragma GCC diagnostic not allowed inside functions
filefrag.c:578: error: #pragma GCC diagnostic not allowed inside functions
filefrag.c:595: error: #pragma GCC diagnostic not allowed inside functions
when compiling latest e2fsprogs with a gcc older than 4.6
e.g. on CentOS 6.9
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the developer is running with SELinux enabled on /tmp, the
f_extent_htree regression test will fail because mke2fs by default
copies the extended attributes into the newly created file system (if
a directory hierarchy is specified via the -d option).
Fix this by adding a new extended option to mke2fs, -E no_copy_xattrs
and using it in f_extent_htree's test script.
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
On some platforms the layout of struct stat changes if
_FILE_OFFSET_BITS is set to 64 (which force the use of 64-bit types
and 64-bit variants for system calls such as stat, lseek, etc.)
This is not true (mercifully) on i386, but it is true for the 32-bit
mips platform on Linux. This caused debugfs's mknod command to fail,
since it used struct stat to pass the desired st_mode and st_rdev
fields for the to-be-created device file or FIFO, and this would be
different for create_inode.c and debugfs.c.
Linking together different object files together compiled with
different values of _FILE_OFFSET_BITS is perilous, but for now, let's
fix the specific problem by passing the two fields in the stat
structure that we really care about. This fixes two regression tests
on the 32-bit MIPS platform: d_special_files and r_move_itable.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The case is one that should never happen (and indicates a bug if it
does), but in that case, we should still avoid an undefiniced C
expression.
Fixes-Coverity-Bug: 1297494
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Now that the majority of device name filtering is in filter.sed,
it does not need to be specified explicitly for every test.
Fix the error message printed in debugfs when opening the device
to match that used in other tools. This simplifies the filtering,
and will be helpful if debugfs messages are internationalized.
[ Fixed up some test failures in m_hugefile t_uninit_bg_rm --tytso ]
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Open filesystem with EXT2_FLAG_IGNORE_SB_ERRORS flag in catastrophic
mode so that superblock errors can be fixed in debugfs.
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Allow filesystem to be open read-write in catastrophic mode so that one
can fixup e.g. superblock breakage. The CHECK_FS_BITMAPS flag to
common_args_process() still guards us from doing operations on bitmaps
which we don't load in this mode.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Teach the inode_dump and block_dump commands the -x option, which
tries to interpret the data structures as xattr data strucgtures.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Teach the inode_dump command to dump out just the i_block array and
the extra space in the inode, as a convenience to someone
investigating a corrupted inode.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
While killing file by inode in debugfs (kill_file_by_inode), if
bigalloc feature is turned on, release clusters only once. We do it by
remembering the last released cluster while releasing blocks. We
release a cluster only if it is not already released.
Signed-off-by: Harshad Shirwadkar <harshads@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
It is more efficient to use ext2fs_read_bitmaps() than to read the
inode and block bitmaps separately, since extra seeks.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
From AOSP commit: 2002d7f1fc: Use -Werror in external/e2fsprogs
... which got reverted and reapplied in a confusing way.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the file system needs to have the journal replayed, but definition
it can't be freshly checked. So if the time when the file system was
last checked (s_lastcheck) is before the time it was last mounted
(s_mtime), force s_lastcheck to be before s_mtime.
This is necessary to make sure some of tune2fs's safety checks work
correctly after replaying the journal, since some of tune2fs's
operations really require that the file system be self-consistent or
grave damage can result.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This message was inadvertently copied from the version of do_dump_mmp
that is used when CONFIG_MMP is disabled.
Signed-off-by: Tyson Nottingham <tgnottingham@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Add descriptions for dump_unused, get_quota, list_quota,
set_current_time, show_debugfs_params, and supported_features
commands to debugfs man page. Add various missing command
arguments and correct a few typos in man page and usage texts.
Signed-off-by: Tyson Nottingham <tgnottingham@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix the bug that print the inode number not the program name
when reporting bad inode name during checking in ncheck.
Minor bug fix: it should reduce iw->inodes_left when found
matched inode number.
Signed-off-by: Qian Yingjin <qian@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Currently, debugfs does not print the Xst high-order mode bits
in the "stat" output. While "ls -l" shows these bits are set:
# ls -il /mnt/tmp/O/0/d2/406306
1588 0 -rwSrwSrw- 1 root root 0 Dec 31 1969 /mnt/tmp/O/0/d2/406306
debugfs currently only prints the low nine "ugo" mode bits:
# debugfs -c -R "stat O/0/d2/406306" /dev/vgmyth/lvmythost4
Inode: 1588 Type: regular Mode: 0666 Flags: 0x80000
Fix debugfs so that the high-order mode bits are also printed,
if available, otherwise only print the standard low mode bits.
# debugfs -c -R "stat O/0/d2/406306" /dev/vgmyth/lvmythost4
Inode: 1588 Type: regular Mode: 06666 Flags: 0x80000
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The ext2fs_run_ext3_journal() function is in debugfs/journal.c, and in
some error conditions cases may close the passed-in file system handle.
Clean up the both the function so that it reliably clears the file
system handle if it has been freed, and its callers so that they do
not crash by dereferencing a null pointer if it has been freed.
Reported-by: Erkki Ruohtula <eru@netti.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
In commit 68a1de3df3 (debugfs: pretty print encrypted filenames in the
ls command), a change was introduced in debugfs/ls.c which instead of
copying dirent->name and 0-terminating it, dirent->name is used
directly in printf.
However, instead of using the precision to limit the number of
characters output, the code uses the field width. As a result,
characters are output until a 0 is read, which results in garbage
after the file name.
Also fix two other instances of this in debugging messages that aren't
used, but fixing them will avoid potential future copypasta bugs.
Reported-by: Christian Gabriel <ch_gabriel@web.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch is a major update to how we decide where to put extended
attributes. The main motivation is to enable creating values in
extended attribute inodes. While doing this, we want to implement a
behavior that is as close to kernel as possible.
Existing set ea code deviates from kernel behavior which makes it harder
to implement ea_inode feature:
- kernel only sorts ea entries in xattr block, e2fsprogs implementation
sorts all entries on every update.
- e2fsprogs implementation shuffled things on every update so the order
of updates does not matter. Kernel does not reshuffle things.
- e2fsprogs could evacuate entries from inode body to xattr block and
vice versa. This behavior does not exist in kernel.
Such differences could lead to inconsistent behavior between fuse2fs and
a kernel mount.
With ea_inode feature, we also need to decide whether to put a value
in an inode or keep it 'inline'. In kernel implementation this
depends on current placement of entries.
To close the behavioral gap, ext2fs_xattr_set() now takes over the
decision about where to place ea values. This also allows it to raise
errors early instead of delaying them to a separate
ext2fs_xattrs_write() call later.
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Otherwise it's possible for a corrupt file system or bad user input to
cause debugfs to crash if the resulting inode number is insanely
large.
This problem was found using American Fuzzy Lop.
Reported-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Current way of determining whether a symlink is in fast symlink
format is to call ext2fs_inode_data_blocks2(). If number of data
blocks is zero and EXT4_INLINE_DATA_FL flag is not set, then symlink
data must be in inode->i_block.
This heuristic is becoming increasingly hard to maintain because
inode->i_blocks count can also be incremented for blocks used by
extended attributes. Before ea_inode feature, extra block could come
from xattr block, now more blocks can be added because of xattr
inodes.
To address the issue, add a ext2fs_is_fast_symlink() function that
gives a direct answer based on inode->i_size field. This is
equivalent to kernel's ext4_inode_is_fast_symlink() function.
This patch also fixes a few issues related to fast symlink handling:
- Both rdump_symlink() and follow_link() interpreted symlinks with
0 data blocks to always mean fast symlinks. This is incorrect
because symlinks that are stored as inline data also have
0 data blocks. Thus, they try to read everything from
inode->i_block and miss the symlink suffix in inode extra area.
- e2fsck_pass1_check_symlink() had code to handle inode with
EXT4_INLINE_DATA_FL flag twice. The first if block always returns
from the function so the second one is unreachable code.
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Also remove a duplicate copy of misc/create_inode.c that isn't upstream.
Bug: https://github.com/android-ndk/ndk/issues/398
Test: builds
Change-Id: Ibc475c82aa21f063673cb68bcf6e41ad9d821cd3
From AOSP commit: 37f805a9571cf33c95080c3dbd65c7a4e46fcd71
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The new kernel headers do:
#define __bitwise __bitwise__
However, the code redefines __bitwise without undef'ing it first.
This is a temporary fix, b/35721782 filed to fix this.
Change-Id: I2c6a64146966f1737835f012d24ccc844570d02b
Test: Builds without warningers/errors.
From AOSP commit: commit 91581e8f15b8a29aedea3e7c11162301c7e66ec3
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When building a static exectuable for "arm", the libgcc is automatically
included by the build system *after* libc, but libgcc has some symbol
dependencies on "libc", like for example the "raise" symbol.
libgcc, libatomic and libcompiler_rt-extras are passed in a group
(enclosed by --start-group and --end-group) so they all are included
regardless of the order inside that group. Nevertheless libc only
appears outside this group and before them, so the undefined references
from libgcc are not resolved.
This patch adds "libc" as a explicit static_libs dependency to
static_executable targets forcing it to be included in the group.
Bug: 34220783
Test: mmma external/e2fsprogs
Change-Id: Ia18db10da0f18494600d7e0c870291902d71b287
From AOSP commit: b799ad178fa18c2925a283206496d3f5d6e87f35
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch also removes all the "-host" and "_static" suffix from all
the libraries adding "unique_host_soname: true". This prevents
confusions with the host installed libraries.
A new "libext2_misc" library is introduced to export some files from
the misc/ directory to other binaries in this project.
Bug: 34220783
Test: mmma external/e2fsprogs
Change-Id: Ia1b689991346b11f8cb38f7c6ee356e666e01d6d
From AOSP commit: 7a9e1a96766d31a41b88f0a539fcc3d532b5c530
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The minor/major/makedev macros are not entirely standard. glibc has had
the definitions in sys/sysmacros.h since the start, and wants to move away
from always defining them implicitly via sys/types.h (as this pollutes the
namespace in violation of POSIX). Other C libraries have already dropped
them. Since the configure script already checks for this header, use that
to pull in the header in files that use these macros.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Don't run tests which take longer than 20 seconds to run (especially
f_large_dir, whose run time is well over ten minutes) for "make
check". The new "make fullcheck" will run all of the regression tests
for e2fsprogs.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch removes i_dir_acl macros and macros users.
Now stucture field can be accessed as i_size_high. This field
is useful for largedir feature.
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@seagate.com>
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@seagate.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix the various compiler warnings that have crept in, and only define
__bitwise if the system headers haven't already done so. Linux 4.10
changes the __bitwise definition so that our redefinition here is
just different enough that gcc complains.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Allow debugfs to open file systems with a bad checksum, and teach the
show_super_stats command to print the expected checksum value.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>