Commit Graph

365 Commits (bbcd91bb0de943b364670373957a5658c4487692)

Author SHA1 Message Date
Bryce Harrington 84461ea9d0 e2fsprogs: fix spelling of 'filesystme' in debugfs help
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-08-19 17:56:06 -04:00
Theodore Ts'o 6854ab1d4a debugfs: interpret date strings of the form @dddd
Debugfs will now interpret date strings of the form @123 as 123
seconds after the start of the epoch.  This is handy when editing an
orphan inode linked list using the inode's deletion time field.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-06-11 22:02:17 -04:00
Eric Sandeen 97a67c40dc debugfs: fix strtoblk for 64bit block numbers
Affects icheck, freeb, setb, testb...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-05-27 22:12:01 -04:00
Zheng Liu 1d520184ee debugfs: cleanup in do_show_debugfs_params
Remove 'out' variable and replace fprintf with printf.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-24 14:33:07 -04:00
Theodore Ts'o e64e6761aa Fix gcc -Wall nitpicks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-05 12:13:05 -07:00
Theodore Ts'o 2ae5d1fdb8 debugfs: teach seti and freei to free a block of inodes
In order to the inode allocation functions, it's useful to set and
clear a range of inodes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-26 10:36:24 -07:00
Theodore Ts'o 24dea55494 Use rbtree bitmaps for dumpe2fs, debugfs, and tune2fs
For large file systems, using the rbtree bitmap can save a lot of
memory.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-15 16:39:56 -04:00
Theodore Ts'o 8a1da3c5ae debugfs: use ss_safe_getenv() instead of getenv()
In the case where debugfs (or rdebugfs) is installed setgid disk, or
some such, we need to disable the use of environment variables for the
obvious reasons.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-15 16:18:29 -05:00
Theodore Ts'o 622cee8833 debugfs: fix spelling typo in ncheck
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-23 11:33:33 -05:00
Theodore Ts'o 8bf1e9184e debugfs: add ncheck -c option
Add a -c option to ncheck will verifies the file type information in
the directory entry.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-17 17:08:39 -05:00
Theodore Ts'o 2b1cae7a26 debugfs: optimize ncheck and improve its error checking
Don't call ext2fs_get_pathname() for every single directory; instead,
only call it if we find a matching directory entry.  In addition, if
ext2fs_get_pathname() fails, print the number of the parent directory
in angle parents so the user gets some additional information.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-16 17:49:46 -05:00
Theodore Ts'o f62516f33b rdebugfs: don't install by default
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-21 08:24:44 -05: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 3cebf9c102 debugfs: fix gcc -Wall complaints
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:14:23 -05:00
Theodore Ts'o c4ab66c526 debugfs: add filefrag command
Add the ability to report on the fragmentation of a file on a file
system opened using debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:14:15 -05:00
Theodore Ts'o 5e96c5721d debugfs: add the freefrag command
The freefrag command provides the functionality of e2freefrag on the
currently open file system in debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:12:12 -05:00
Theodore Ts'o e88c5a33a8 debugfs: build read-only variant of debugfs
Create a version of debugfs which only supports read-only examination
of the file system metadata (but not the data blocks).  The idea is
that this version of debugfs might be suitable to be setuid root, and
executable only by members of a particular group, or setgid disk, and
globally executable, depending on the security/privacy policies in
force at a particular site.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-11-18 22:08:53 -05:00
Eric Sandeen 7105c183a0 debugfs: tidy up mmp handling
Several small fixes:

* Gracefully fail mmp commands if fs is not open
* Show magic number in dump_mmp command
* Fix header in output for set_mmp_value -l

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-11-11 21:06:04 -05:00
Eric Sandeen 3859977a6b debugfs.8: add documentation of the mmp commands
Document the dump_mmp and set_mmp_value commands in
the debugfs manpage.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-11-11 21:06:04 -05:00
Theodore Ts'o 0c80c44bd0 libext2fs: ext2fs_[set_]file_acl_block needs to check for 64-bit feature flag
The ext2fs_file_acl_block() and ext2fs_set_file_acl_block() needs to
only check i_file_acl_high if the 64-bit flag is set.  This is needed
because otherwise we will run into problems on Hurd systems which
actually use that field for h_i_mode_high.

This involves an ABI change since we need to pass ext2_filsys to these
functions.  Fortunately these functions were first included in the
1.42-WIP series, so it's OK for us to change them now.  (This is why
we have 1.42-WIP releases.  :-)

Addresses-Sourceforge-Bug: #3379227

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-10-16 20:46:49 -04:00
Eric Sandeen d352f838e8 debugfs: initialize inode to 0 in list_dir_proc() if no inode nr
If (!ino), the inode will be uninitialized when we print it
in the PARSE_OPT case.

So do the same as the LONG_OPT case, and memset it to 0 if
(!ino).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-25 01:55:28 -04:00
Andreas Dilger 0f5eba7501 ext2fs: add multi-mount protection (INCOMPAT_MMP)
Multi-mount protection is feature that allows mke2fs, e2fsck, and
others to detect if the filesystem is mounted on a remote node (on
SAN disks) and avoid corrupting the filesystem.  For e2fsprogs this
means that it checks the MMP block to see if the filesystem is in use,
and marks the filesystem busy while e2fsck is running on the system.

This is useful on SAN disks that are shared between high-availability
servers, or accessible by multiple nodes that aren't in HA pairs.  MMP
isn't intended to serve as a primary HA exclusion mechanism, but as a
failsafe to protect against user, software, or hardware errors.

There is no requirement that e2fsck updates the MMP block at regular
intervals, but e2fsck does this occasionally to provide useful
information to the sysadmin in case of a detected conflict.

For the kernel (since Linux 3.0) MMP adds a "heartbeat" mechanism to
periodically write to disk (every few seconds by default) to notify
other nodes that the filesystem is still in use and unsafe to modify.

Originally-by: Kalpak Shah <kalpak@clusterfs.com>

Signed-off-by: Johann Lombardi <johann@whamcloud.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-25 01:55:23 -04: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
Theodore Ts'o 16c581d0e8 debugfs: add 64-bit support to the set_field commands
The set_fields commands (set_super_value, set_inode_field,
set_block_group) now handle fields which store in split fields on
ext4's on-disk format.  For example, the superblock fields
s_blocks_count and s_blocks_count_hi.

The user can either set the low or high part of the field via
"blocks_count_lo" or "blocks_count_hi", or both parts can be set via
"blocks_count".

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16 10:32:02 -04:00
Theodore Ts'o 89efc88e65 libext2fs: add metadata checksum and snapshot feature flags
Reserve EXT4_FEATURE_RO_COMPAT_METADATA_CSUM and
EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP.  Also reserve fields in the
superblock and the inode for the checksums.  In the block group
descriptor, reserve the exclude bitmap field for the snapshot feature,
and checksums for the inode and block allocation bitmaps.

With this commit, the metadata checksum and exclude bitmap features
should have reserved all of the fields they need in ext4's on-disk
format.

This commit also fixes an a missing byte swap for s_overhead_blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Darrick J. Wong <djwong@us.ibm.com>
Cc: Amir Goldstein <amir73il@gmail.com>
2011-09-16 10:24:09 -04:00
Theodore Ts'o 2418dfd7b9 dumpe2fs: display "free blocks" as "free clusters" for bigalloc file systems
Change this for the equivalent function in debugfs as well.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16 10:13:41 -04:00
Theodore Ts'o af0df2aa4a debugfs: add a new debugfs command 'blocks'
The blocks command prints out the blocks used by a particular inode,
in a format which is useful for test suite automation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-09 12:13:40 -04:00
Andreas Dilger 0bd0e59320 misc: use EXT2_I_SIZE() consistently to get size
Use the EXT2_I_SIZE() macro consistently to access the inode size.
The i_size/i_size_high combination is open coded in several places.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-07-08 20:52:59 -04:00
Andreas Dilger 931b58e1cb ext2fs: Handle internal journal over 2^32 bytes
The write_journal_inode() code is only setting the low 32-bit i_size
for the journal size, even though it is possible to specify a journal
up to 10M blocks in size.  Trying to create a journal larger than 2GB
will succeed, but an immediate e2fsck would fail.  Store i_size_high
for the journal inode when creating it, and load it upon access.

Use s_jnl_blocks[15] to store the journal i_size_high backup.  This
field is currently unused, as EXT2_N_BLOCKS is 15, so it is using
s_jnl_blocks[0..14], and i_size is in s_jnl_blocks[16].

Rename the "size" argument "num_blocks" for the journal creation functions
to clarify this parameter is in units of filesystem blocks and not bytes.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 12:17:29 -04:00
Andreas Dilger 1d8f5ae36e debugfs: fix icheck finding blocks used for xattrs
This was an "uninitialized variable" warning, but it turns out to be
a real bug.  Without this change, it is not possible to use "icheck"
to find blocks that are used for the i_file_acl (xattr) block.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 11:29:54 -04:00
Andreas Dilger cf5301d7f2 misc: clean up compiler warnings
Fix several types of compiler warnings (unused variables/labels),
uninitialized variables, etc that are hit with gcc -Wall.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 10:58:25 -04:00
Eric Sandeen f5ae5b3a12 debugfs: document htree-related commands in man page
The debugfs commands dirsearch, dx_hash, and htree_dump were
never documented in the man page.  Do so.

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
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
Theodore Ts'o 5af9eeaa7d Merge branch 'maint' into next
Conflicts:
	lib/e2p/ls.c
2011-03-18 16:44:37 -04:00
Eric Sandeen d4a9330212 e2fsprogs: man page typo fixes
Fix a few typos in manpages.

Reported-by: Branislav Náter <bnater@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-03-18 15:03:15 -04:00
Theodore Ts'o 4df1618250 add new superblock field: s_overhead_blocks
It turns out that it's very hard to calculate overheads in the face of
clustered allocation (bigalloc).  This is because multiple metadata
blocks from different block groups can end up in the same allocation
cluster.  Calculating the exact overhead requires O(all block bitmaps)
in memory, or O(number of block groups**2) in time.  So we will
calculate this at mkfs time and stash it in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-03-18 14:47:15 -04:00
Theodore Ts'o 829d999488 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/initialize.c
2011-02-27 19:47:44 -05:00
Theodore Ts'o 412376efff Add basic BIGALLOC support for cluster-based allocation
This adds the superblock fields needed so that dumpe2fs works and the
code points and renames the superblock fields from describing
fragments to clusters.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-25 21:43:54 -05:00
Aditya Kali 0edcc27021 e2fsprogs: reserving code points for new ext4 quota feature
This patch adds support for detecting the new 'quota' feature in ext4.
The patch reserves code points for usr and group quota inodes and also
for the feature flag EXT4_FEATURE_RO_COMPAT_QUOTA.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-25 18:31:52 -05:00
Theodore Ts'o 9d92a201de Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
	lib/ext2fs/ext2fs.h
	misc/mke2fs.c
2010-09-24 22:40:21 -04:00
Theodore Ts'o a946844235 debugfs: Make the extents listing in the stat command more concise
Use "[u]" instead of "[uninit]" and limit the amount of detail printed
for the extent tree blocks, so it is more similar to the format used
for direct/indirect mapped inodes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-24 22:05:58 -04:00
Theodore Ts'o 0fd68e0241 debugfs: Add the -D option to request Direct I/O
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-24 10:12:54 -04:00
Theodore Ts'o c4b87b8c4f debugfs: Display the extent tree blocks in the stat command output
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-19 22:52:09 -04:00
Theodore Ts'o 9345f02671 tune2fs, debugfs, libext2fs: Add support for ext4 default mount options
Add support for 2.6.35's new default mount options which can be
specified in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-18 19:38:22 -04:00
Theodore Ts'o 8668592362 debugfs: Add new debugfs command punch (aka truncate)
This uses the newly added ext2fs_punch() function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-22 09:39:04 -04:00
Theodore Ts'o db0bdb49f4 Merge branch 'maint' into next
Conflicts:
	resize/extent.c
2010-07-19 02:37:41 -04:00
Theodore Ts'o f5448c19ac Add support for Next3 snapshot superblock fields to dumpe2fs and debugfs
We also support for byte-swapping the Next3 fields, although the
current Next3 implementation doesn't support big-endian systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-24 21:08:37 -04:00
Theodore Ts'o c5b23f6c0e Merge branch 'maint' into next 2010-03-15 18:53:45 -04:00
Theodore Ts'o de2c477815 debugfs: Correctly show the allocation status of a block using logdump
The offset in the bitmap was not getting correctly calculated when the
user specifics a block to track using "logdump -b <block-num>"

Addresses-Debian-Bug: #564084

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-03-15 00:14:12 -04:00