Commit Graph

45 Commits (6e4fa6e28151a3bffea2d73c22ea3b7f2338f0fd)

Author SHA1 Message Date
Darrick J. Wong 4ee2669982 debugfs: clean up feature test macros with predicate functions
Create separate predicate functions to test/set/clear feature flags,
thereby replacing the wordy old macros.  Furthermore, clean out the
places where we open-coded feature tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-10-24 01:26:35 -04:00
Theodore Ts'o df0b907ec1 debugfs: cleanup gcc -Wall warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-13 16:00:12 -04:00
Eric Sandeen 77b493e35b debugfs: don't swap htree nodes in-place
htree_dump_int_node() was swapping htree nodes in-place,
something not done elsewhere, so it made the sparse checker
unhappy.  Just use dedicated variables to hold the 2 needed
(endian-swapped) values.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:26:21 -05:00
Jan Kara 70f4632b62 libext2fs: provide functions to safely access name_len and file_type
Accessing name_len (and file_type) in ext4_dir_entry structure is
somewhat problematic because on big endian architecture we need to now
whether we are really dealing with ext4_dir_entry (which has u16
name_len which needs byte swapping) or ext4_dir_entry_2 (which has u8
name_len which must not be byte swapped).

Currently the code is somewhat surprising and name_len is always
treated as u16 and byte swapped (flag EXT2_DIRBLOCK_V2_STRUCT isn't
ever used) and then masking of name_len is used to access real
name_len or file_type. Doing things this way in applications using
libext2fs is unexpected to say the least (more natural is to type
struct ext4_dir_entry * to struct ext4_dir_entry_2 * but that gives
wrong results on big endian architectures. So provide helper functions
that give endian-safe access to these fields. Also convert users in
e2fsprogs to use these functions.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-08 17:03:05 -04:00
Theodore Ts'o b9b5e43ea8 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	lib/ext2fs/crc32c.c
	lib/ext2fs/rw_bitmaps.c
	resize/resize2fs.c
	version.h
2013-01-01 18:50:26 -05:00
Theodore Ts'o e3507739e4 Fix gcc -Wall nits
This fixes the last set of gcc -Wall complaints.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-01 13:28:27 -05:00
Theodore Ts'o 41bf599391 debugfs: teach the htree and ls commands to show directory checksums
In addition, make the directory interator more robust in the case
where the file system has the metadata checksum feature enabled, but
the directory checksum is not present in a directory block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-14 06:35:26 -04:00
Theodore Ts'o 24980deeaf Merge branch 'maint' into next
Conflicts:
	debugfs/htree.c
2012-10-14 04:57:37 -04:00
Theodore Ts'o e6575ce308 debugfs: fix htree command so that all printf's go through the pager
The "Reading directory block XXX..." message was not being sent
through the pager, which would result in confusing output.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-14 04:54:20 -04:00
Darrick J. Wong 81683c6a32 libext2fs: add checksums to the end of directory leaf nodes
Introduce small structures for recording directory tree checksums, and
some API changes to support writing out directory blocks with
checksums.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-08-02 17:27:43 -04:00
Darrick J. Wong a996466d98 debugfs: print htree internal node checksums
Print htree node checksums when dumping a directory index.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-07-30 19:20:04 -04:00
Darrick J. Wong 9c23b89612 debugfs: fix sprintf stack overflow
The htree dump code overflows a char buffer if the directory has a long
filename because the buffer is not large enough to hold the characters that are
not part of the filename.  Make the buffer larger and use snprintf instead.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-11-20 15:53:11 -05:00
Theodore Ts'o d1154eb460 Shorten compile commands run by the build system
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and
this was starting to cause some tools heartburn.  It also made "make
V=1" almost useless, since trying to following the individual commands
run by make was lost in the noise of all of the defines.

So fix this by putting the configure-generated defines in lib/config.h
and the directory pathnames to lib/dirpaths.h.

In addition, clean up some vestigal defines in configure.in and in the
Makefiles to further shorten the cc command lines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-18 17:34:37 -04:00
Eric Sandeen 11ba79b3a6 e2fsprogs: Remove impossible name_len tests.
The name_len field in ext2_dir_entry is actually comprised of
the name length in the lower 8 bytes, and the filetype in the
high 8 bytes.  So in places, we mask name_len with 0xFF to
get the actual length.

But once we have masked name_len with 0xFF, there is no point
in testing whether it is greater than EXT2_NAME_LEN, which
is 255 - or 0xFF.  So all of these tests are extraneous.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16 18:43:04 -04:00
Eric Sandeen 1ec5d104d7 debugfs: remove unused htree_dump "-l" argument
The long_opt / -l argument was apparently never implemented,
so remove it and associated argument parsing.

This slightly changes the (undocumented) behavior because it
no longer defaults to cwd if no filespec is specified...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-14 23:37:22 -04:00
Valerie Aurora Henson 048786d7e8 debugfs: Convert to support 64-bit filesystems
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 22:46:17 -04:00
Valerie Aurora Henson 24a117abd0 Convert to use io_channel_read_blk64() and io_channel_write_blk64()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:14:24 -04:00
Theodore Ts'o 42080a8656 debugfs: Fix miscellaneous gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11 23:23:16 -04:00
Theodore Ts'o 8a48035095 Fix encoding for rec_len in directories for >= 64k blocksize file systems
Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could
occur if the directory block is completely empty in 64k blocksize
filesystems), while the kernel interpreted 65535 to mean 65536.  The
kernel will accept both to mean 65536, and encodes 65535 to be 65536.
This commit changes e2fsprogs to match.

We add the encoding agreed upon for 128k and 256k filesystems, but we
don't enable support for these larger block sizes, since they haven't
been fully tested.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-21 21:07:38 -04:00
Theodore Ts'o 2af6fe017a debugfs: Fix format string warnings in htree_dump_leaf_node()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:08:36 -04:00
Jim Meyering 45e338f533 remove useless if-before-free tests
In case you're wondering about whether this change is safe from a
portability standpoint, fear not.  This has been beaten to death
in other forums.  Here are a few threads:

  http://thread.gmane.org/gmane.comp.version-control.git/74187
  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712
  http://thread.gmane.org/gmane.emacs.devel/98144
  http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092

There has been debate about whether it's a good idea from a
performance standpoint, too, but imho you'll have a hard time
finding an instance where this sort of change induces a
measurable performance penalty.  If you do, please let me know.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08 20:37:12 -04:00
Theodore Ts'o f8bd55160c debugfs: Add the ability to specify the hash seed to the "hash" command
Also add the ability to specify the hash algorithm by name instead of
by number.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-10 11:30:46 -04:00
Theodore Ts'o efc6f628e1 Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 23:07:54 -04:00
Theodore Ts'o 5dd77dbe5a Add support for with empty directory blocks in 64k blocksize filesystems
The rec_len field in the directory entry is 16 bits, so if the
filesystem is completely empty, rec_len of 0 is used to designate
65536, for the case where the directory entry takes the entire 64k
block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-25 21:08:19 -04:00
Theodore Ts'o 226515dfa9 debugfs: Fix htree command so it works with extent-based directories
Also add support to dump out the minor hash value in addition to the
major hash.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-08 11:56:07 -04:00
Theodore Ts'o 43323be957 Use BLOCK_FLAG_READ_ONLY flag in debugfs, e2image, and tune2fs
Pass BLOCK_FLAG_READ_ONLY to ext2fs_block_iterate2() so that debugfs,
e2image, and tune2fs will work well with filesystems containing
extents.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 20:05:55 -05:00
Andreas Dilger de8f3a7621 Fix gcc -Wall warnings, especially on 64-bit systems
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-25 11:18:11 -04:00
Theodore Ts'o d904dd2ac0 [COVERITY] Fix coverity warning in debugfs
This is a no-op since long_opt isn't currently being used; the -l option
to htree_dump is currently unwired to anything at the moment.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>

Coverity ID: 47: Used before assigned
2007-03-29 00:26:10 -04:00
Brian Behlendorf 89456558df [COVERITY] Fix (error case) memory leak in debugfs
Handle leaked cbuf due to early returns with a generic failure path.

Coverity ID: 24: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21 17:53:33 -04:00
Brian Behlendorf b772900b4b [COVERITY] Avoid static buffer overruns in debugfs
Add an extra byte to EXT2_NAME_LEN in the static allocation for the
required trailing null.  This allows filenames up to the maximum
length of EXT2_NAME_LEN withover an overrun.

Coverity ID: 11: Overrun Static
Coverity ID: 12: Overrun Static
Coverity ID: 13: Overrun Static

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21 15:09:15 -04:00
Theodore Ts'o f77704e416 Add directory hashed signed/unsigned hint to superblock
The e2fsprogs and kernel implementation of directory hash tree has a
bug which causes the implementation to be dependent on whether
characters are signed or unsigned.  Platforms such as the PowerPC,
Arm, and S/390 have signed characters by default, which means that
hash directories on those systems are incompatible with hash
directories on other systems, such as the x86.

To fix this we add a new flags field to the superblock, and define two
new bits in that field to indicate whether or not the directory should
be signed or unsigned.  If the bits are not set, e2fsck and fixed
kernels will set them to the signed/unsigned value of the currently
running platform, and then respect those bits when calculating the
directory hash.  This allows compatibility with current filesystems,
as well as allowing cross-architectural compatibility.

Addresses Debian Bug: #389772

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 22:32:35 -05:00
Eric Sandeen d0ff90d520 Fix signed vs unsigned printf format strings for block and inode numbers
There were still some %d's lurking when we print blocks & inodes; also
many of the counters in the e2fsck_struct were signed, and probably
need to be unsigned to avoid overflows.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-09-12 14:56:15 -04:00
Theodore Ts'o 49c6b4e947 Add handling for invalid option characters in debugfs subcommands
Fix the debugfs commands htree_dump, dx_hash, and list_dir so they print a
print a usage message when an illegal option character is given.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-04-27 20:59:42 -04:00
Takashi Sato 8deb80a5d1 Fix format statements to make e2fsprogs programs 32-bit clean
Change the format string(%d, %ld) for a block number and inode number
to %u or %lu.

Signed-off-by: Takashi Sato <sho@tnes.nec.co.jp>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 21:43:46 -05:00
Theodore Ts'o 544349270e Fix gcc -Wall nitpicks 2003-12-07 01:28:50 -05:00
Theodore Ts'o 88494bb6d4 util.c, ls.c, logdump.c, htree.c, dump.c, debugfs.h, debugfs.c, ChangeLog:
util.c (reset_getopt), debugfs.c (do_open_filesys,
  	do_show_super_stats), ls.c (do_list_dir), dump.c (do_dump),
  	htree.c (do_htree_dump, do_dx_hash), logdump.c (do_logdump):
  	Define and use a new function, reset_getopt(), which does whatever
  	is necessary to reset getopt() again.  This is different for
  	different implementations, so the portabilty issues are a bit of a
  	nightmare.  (Addresses Debian bug #192834)
2003-05-13 23:03:43 -04:00
Theodore Ts'o ed78c021c3 Fix up lots of portability problems that caused e2fsprogs not to build successfully
under Solaris.
2003-03-06 11:09:18 -05:00
Theodore Ts'o 3e69906495 Fix gcc -Wall nits.
Fix format bug if NLS is in use.

Add extra so that the info directory looks OK on OpenWall.
2002-10-13 23:56:28 -04:00
Theodore Ts'o 8132d840c8 Fix endian problems in the htree code for e2fsck and debugfs.
When byte-swapping a filesystem on a PPC architecture, byte-swap
the bitmaps since the historical big-endian ext2 variant had
byte-swapped bitmaps, and the ext2fs library assumes this.  Otherwise
the regression test suite will fail...
2002-10-02 22:07:17 -04:00
Theodore Ts'o 42e5b5f987 Flag continuation hashes in debugfs's htree command to make them
easier to find.
2002-09-22 15:27:28 -04:00
Theodore Ts'o 155f577b2b htree.c (do_htree_dump): Fix a bug where we were not cleanly
closing the pager after errors, which would leave the
	tty in noecho mode.
2002-07-21 14:17:45 -04:00
Theodore Ts'o 621732c956 htree.c (htree_dump_int_node): Add byte swapping code sot that
the htree dump function works on a big-endian machine.
2002-07-18 22:19:51 -04:00
Theodore Ts'o 503f9e7f6e Add support for the half-MD4 HTREE hash.
Add HTREE root node tests.
2002-06-26 16:52:10 -04:00
Theodore Ts'o 52783e0ca7 Add new function to the libext2fs library, ext2fs_dirhash, which
calculates the hash of a filename for indexed directories.
2002-03-11 15:04:45 -05:00
Theodore Ts'o df614db6ef Add initial support in debugfs for examining directory indexing
information.
2002-02-25 04:28:45 -05:00