Commit Graph

619 Commits

Author SHA1 Message Date
Theodore Ts'o
9b96524174 debugfs: clean up gcc -Wall warning from using snprintf
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-07-14 10:41:36 -04:00
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
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
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
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
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
a935b93dca Merge branch 'maint' into next 2019-02-10 21:50:26 -05:00
Artem Blagodarenko
453a2f6175 debugfs: output large directory size
large_dir option allows to create directory with size > 2GB.
debugfs utility outputs negative size value for large directories
and ignores high part of directory size.

Fix debugfs to use high part of directory size in debugfs output
and use appropriate output format.

Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-02-05 17:11:26 -05:00
Theodore Ts'o
32917350a4 debugfs: fix set_inode_field so it can set the checksum field
Previously, setting the inode field was a no-op, since the library
function ext2fs_write_inode_full() would override whatever value was
set by debugfs.  Use the new ext2fs_write_inode2() interface so we can
in fact set the checksum to a potentially wrong value.  Also, ignore
the inode checksum failures if we are setting the checksum, and if the
checksum value is "calc", set the inode checksum to the correct value.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-12-15 18:31:40 -05:00
Gabriel Krisman Bertazi
ef733f1a97 debugfs: support encoding when printing the file hash
Implement two parameters -e and -c, to specify encoding and casefold
when printing the hash of a given file.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-12-02 23:59:12 -05:00
Theodore Ts'o
29d78e01ef Merge branch 'maint' into next 2018-10-14 12:31:06 -04:00
David Anderson
c4ef5b4f6b AOSP: Fix debugfs clang build.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

Change-Id: Ic4de282039524e1858bbd288e2b85be30d843f40
From AOSP commit: 7e9e2ca4b08aab41b28e57d0c9b840b8b9e6466d
2018-10-12 22:55:57 -04:00
Theodore Ts'o
f7260c1974 debugfs: fix missing variable rename in debugfs.h
This should have been part of commit 2fcbcb1b9e: "Fix function
declarations for ss commands to fix LTO warnings".

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-08-15 22:06:16 -04:00
Theodore Ts'o
2ca70c2253 Merge branch 'maint' into next 2018-08-13 22:40:15 -04:00
Ross Burton
5abc041492 build: use MKDIR_P instead of MKINSTALLDIRS
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-08-11 15:29:48 -04:00
Theodore Ts'o
2fcbcb1b9e Fix function declarations for ss commands to fix LTO warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-08-08 19:59:40 -04:00
David Anderson
0958bc6327 AOSP: Update Android.bp files.
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
2018-08-05 13:54:26 -04:00
Jaco Kroon
4a30e2ae7c debugfs: fix ncheck so it handles hard links correctly
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>
2018-08-05 12:07:20 -04:00
Li Dongyang
fddc423dc6 Fix compile error and warnings for old gcc versions
-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>
2018-07-14 20:46:30 -04:00
Theodore Ts'o
8cec4acdc0 tests, mke2fs: add option to suppress xattr copying to fix f_extent_htree
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>
2018-06-26 15:21:28 -04:00
Theodore Ts'o
47e6105264 debugfs: fix mknod command on some 32-bit platforms due to LFS
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>
2018-06-26 09:02:46 -04:00
Theodore Ts'o
574b714d58 Update Makefile.in files using "make depend"
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-25 10:10:39 -04:00
Theodore Ts'o
5f63e5c4f9 debugfs: suppress spurious "checksum errors" message for unrelated failures
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-24 21:21:49 -04:00
Theodore Ts'o
366d526f15 debugfs: avoid undefined bit shift in parse_uint()
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>
2018-06-24 00:39:37 -04:00
Theodore Ts'o
ac3256fd31 Fix gcc and clang warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-23 23:00:50 -04:00
Andreas Dilger
b7454eb8ee tests: remove redundant sed filtering
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>
2018-06-22 14:06:53 -04:00
Jan Kara
d194a08083 debugfs: allow fixing superblock errors in catastrophic mode
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>
2018-06-19 11:27:51 -04:00
Jan Kara
d338544de1 debugfs: allow read-write opening in catastrophic mode
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>
2018-06-19 11:27:51 -04:00
Theodore Ts'o
c7c99af6bd debugfs: add support to display details of extended attribute structures
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>
2018-06-13 18:41:45 -04:00
Theodore Ts'o
dd1543dba4 debugfs: add -b and -e options to the inode_dump command
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>
2018-05-26 23:11:18 -04:00
harshads
7cc4cf5c7c debugfs: release clusters only once in release_blocks_proc
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>
2018-03-24 11:14:06 -04:00
Theodore Ts'o
6a6393964f debugfs: read allocation bitmaps more efficiently
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>
2018-03-20 22:10:09 -04:00
Theodore Ts'o
c19b18f84b AOSP: use e2fsprogs-defaults for ccflags
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>
2018-02-26 13:54:20 -05:00
Jeff Gaston
33b80078db AOSP: Revert "Add "libc" to soong static_executable targets."
This reverts commit b799ad178fa18c2925a283206496d3f5d6e87f35.
It's no longer needed after https://android-review.googlesource.com/c/329298/

Bug: 34722432
Test: lunch aosp_arm-eng && mmma external/e2fsprogs
Change-Id: I4115fe89ef7751364053223be24e7682e66b6b67
From AOSP commit: 34115ec38e86ba3cc17ae7a866e891abf7bd3aeb
2018-02-26 13:53:35 -05:00
Pavlin Radoslavov
88ca49f99b AOSP: Add missing libdl dependencies
Bug: 62815515
Test: lunch full-eng; make checkbuild
Change-Id: I1751669c4ed046c22587938e04eb76abe8553a8d
From AOSP commit: a24084ceb74c84b0943c86deb5cb99a63d3c46d7
2018-02-26 12:23:11 -05:00
Theodore Ts'o
1ad400d380 Merge branch 'maint' into next 2018-02-26 11:13:35 -05:00
Theodore Ts'o
60f032bbc1 tune2fs/fuse2fs/debugfs: after replaying the journal, fix up s_lastcheck
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>
2018-02-24 18:11:19 -05:00
Theodore Ts'o
604075a0ad v1.43.9
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEK2m5VNv+CHkogTfJ8vlZVpUNgaMFAlp9KFYACgkQ8vlZVpUN
 gaNEdwgAgstbkq3T7E16dIbW+f7/U7JbF8ugvZh/OnXp0OunmrkP+N2T9ZHriG8k
 f0eb2Polp25lC2U3tHGUs4gRsTaZPKmxMQVwY8/cLs556+zlmItZpDdaT7Hu5zPH
 ReL/s0k9SjF9Cv75YAu8m6ygtkyiy+36HD50EFNAmZoWLQa2xHx/df+HXAXVVz5D
 ujzQ/W899RXdOBERzbvfYpblA/VoYPZaaPf6ctZMtBZfzWUcn+PLljmxPgZEJWNn
 KO/e0cftfulmD12G3OgLsge6hbOyJSN3SEHW5EBy87y3sR1EjJnrHADUxaaXDYrD
 9znRtY0LKqQfIX103Jlm82pigq+adA==
 =5ztX
 -----END PGP SIGNATURE-----

Merge tag 'v1.43.9' into next

v1.43.9
2018-02-09 00:29:10 -05:00
Tyson Nottingham
f54f08bd0b debugfs: remove misplaced "MMP is unsupported" message
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>
2018-02-07 23:28:17 -05:00
Theodore Ts'o
df22ead1ba Merge branch 'maint' into next 2018-01-02 00:53:10 -05:00
Shen-Ta Hsieh
88580763fc debugfs: fix printf format %d on ext2_ino_t
Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-01-01 23:51:36 -05:00
Tyson Nottingham
7600aa0f06 Add missing information to debugfs man pages and usage texts
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>
2017-12-15 00:28:58 -05:00
Qian Yingjin
07b11a7ba3 debugfs: fix ncheck program output
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>
2017-12-13 10:59:39 -05:00
Theodore Ts'o
69ab815dbe Merge branch 'maint' into next 2017-10-15 23:20:53 -04:00
Sebastian Rasmussen
055866d84d Fix typos in code comments and developer docs
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
2017-10-15 23:00:11 -04:00
Sebastian Rasmussen
ce20096fc6 Fix typos in error messages and documentation
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
2017-10-15 23:00:03 -04:00
Andreas Dilger
8dca24c3cb debugfs: print "Xst" bits of file mode via stat
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>
2017-10-15 22:27:40 -04:00
Theodore Ts'o
21f685b6c1 Merge branch 'maint' into next 2017-10-15 16:37:10 -04:00
Theodore Ts'o
6ae16a6814 misc: clean up error handling for ext2fs_run_ext3_journal()
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>
2017-10-15 00:22:20 -04:00