Commit Graph

544 Commits (master)

Author SHA1 Message Date
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 8c236c62c9 Merge branch 'maint' into next 2013-03-13 16:17:34 -04:00
Theodore Ts'o 16b1fcf87d debugfs: fix command failures for extent_inode commands that take arguments
The extent_inode commands split_node, replace_node, and insert_node
take arguments which resulted in confusing error messages after
succeeding.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-13 14:19:16 -04:00
Theodore Ts'o 7c1384c324 debugfs: add sanity check to make sure we never shift 64 bits right
In the tables which are used to parse the fields for the set_fields
command, there should never be a entry which has a size set to 8
bytes, and two pointers defined.  Not only would it result in
undefined behavior in the compiled code, it doesn't make any sense and
is definitely a bug.

Reported-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-28 09:06:23 -05:00
Theodore Ts'o 7b68fa38b8 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	lib/ext2fs/ext2_err.et.in
	version.h
2013-01-16 14:14:09 -05:00
Theodore Ts'o e1e961cb80 debugfs: fix mknod command so that it updates the block group statistics
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-16 14:09:20 -05:00
Darren Hart 4df6a37bd3 debugfs: add symlink command
Add support for symbolic links using a new symlink command.  Modeled
after the do_mkdir() command.

Testing demonstrates both fastlinks and slowlinks work correctly.
Very long target paths fail as the command parsing appears to truncate
the input to somewhere around 256 bytes.

Signed-off-by: Darren Hart <dvhart@infradead.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Andreas Dilger <adilger@dilger.ca>
2013-01-16 14:09:20 -05:00
Theodore Ts'o 9e85208e84 debugfs: fix gcc-wall complaints
Fix the missing function prototypes from the recently added new
debugfs commands, plus some signed vs unsigned comparison complaints.

Also change the abbreviation of the block_dump command from "bp" to
the more appropriate "bp".

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-14 16:54:09 -05:00
Eric Sandeen 85a24385b6 debugfs: document zap_block & block_dump
What little docs there were had a cut & paste error.
We can do better. :)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-01-12 19:26:37 -05: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
Zheng Liu d3b4de412c debugfs: fixup the hard-coded buffer length in dump_file
Allocate the block buffer in dump_file() instead of assuming that the
block size is no more than 8k.

CC: George Spelvin <linux@horizon.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-01 15:12:14 -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 ab83252174 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/problem.h
2012-12-24 10:50:20 -05:00
Theodore Ts'o ba75d9e208 debugfs: add the commands "zap_block" and "block_dump"
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:45 -05:00
Theodore Ts'o 2168df757a debugfs: add a makefile rule to build debugfs.static
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:45 -05:00
Theodore Ts'o bee7b67ce9 debugfs: add the ability to manipulate the extent tree directly
This commit adds the functionality which had previously only been in
the tst_extents command to debugfs.  The debugfs command extent_open
will open extent tree of a particular inode, and enables a series of
commands which will allow the user to interact with the extent tree
directly.  Once the extent tree is closed via extent_open(), these
additional commands will be disabled again.

This commit exports two new functions from lib/ext2fs/extent.c which
had previously been statically defined: ext2fs_extent_node_split() and
ext2fs_extent_goto2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:41 -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
Theodore Ts'o f6f359e7e6 Merge branch 'maint' into next 2012-08-19 18:11:46 -04:00
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
Darrick J. Wong 2556373a33 libext2fs: change on-disk journal layout to support metadata checksumming
Define flags and change journal structure definitions to support v2 journal
checksumming.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-08-02 20:47:45 -04:00
Darrick J. Wong a9620d8b30 libext2fs: add checksum to MMP block
Calculate and verify a checksum of the MMP block.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-08-02 20:47:45 -04:00
Darrick J. Wong 5b58dc2304 libext2fs: block group checksum should use metadata_csum algorithm
Change the block group algorithm to use the same algorithm as the rest
of the metadata_csum.  This mostly involves providing a helper
function to tell if group descriptors should have checksums set or
verified, and modifying the gdt checksum code to use the correct
algorithm.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-08-02 20:47:45 -04:00
Darrick J. Wong 1eedf3e52c libext2fs: record the checksum algorithm in use in the superblock
Record the type of checksum algorithm we're using for metadata in the
superblock, in case we ever want/need to change the algorithm.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-08-02 20:47:44 -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 6d0af0c85d debugfs: dump inode checksum when appropriate
Dump inode checksum when displaying inode info.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-07-30 18:48:04 -04:00
Darrick J. Wong 9bca9a39b7 debugfs: optionally ignore bad checksums
If someone is debugging a badly damaged filesystem, it might be useful
to disable the checksum verifications that will otherwise prevent the
filesystem from loading.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-07-30 17:46:15 -04:00
Tony Breeds d6a4bcb517 Make Multi Mount Protection (MMP) optional at configure time.
Add --{en,dis}able-mmp options for configure, default to enabled.
Also make tools fail gracefully in the event of encoutering a filesystem
with MMP enabled when the tools were compiled with --disable-mmp

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-07-30 14:50:30 -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
Valerie Aurora Henson d7cca6b06f Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()

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-10-25 21:43:47 -04:00
Theodore Ts'o cd65a24e75 libext2fs: Convert ext2fs_bg_flag_test() to ext2fs_bg_flags_test()
After cleaning up ext2fs_bg_flag_set() and ext2fs_bg_flag_clear(),
we're left with ext2fs_bg_flag_test().  Convert it to
ext2fs_bg_flags_test().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:42:12 -04:00
Eric Sandeen 03b9dca63a debugfs: open file systems using EXT2_FLAG_64BITS
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:41:13 -04:00
Theodore Ts'o 95bcea9fc1 Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
	misc/mke2fs.c
2009-10-04 20:40:46 -04:00
Theodore Ts'o e1f0850795 Don't use in-tree header files if using system uuid or blkid libraries
This commit forces the use of the system-provided blkid or uuid header
files if we are using the system-provided blkid or uuid libraries.
This avoids using the in-tree header files with the system libraries.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-04 14:45:08 -04:00
Peng Tao 2d7ef236b7 debugfs: add matching fclose
If the cmd_file is not stdin, we should close the file handle via fclose().
Thanks David Binderman to point this out.

Addresses-Novell-Bugzilla: #524526

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-10-03 22:30:37 -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 4efbac6fed Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 20:46:34 -04:00
Theodore Ts'o 732c8cd58f Use accessor functions fields for bg_flags in the block group descriptors
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:15:12 -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
Valerie Aurora Henson 6d879a999b debugfs: Move everything to new bitmap interface
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 20:22:42 -04:00
Theodore Ts'o baa8dbeb4e Merge branch 'maint' into next
Conflicts:
	misc/Makefile.in
2009-08-01 20:43:00 -04:00
Theodore Ts'o 187cb623dc debugfs: Add the new command dump_extents and extent the stat command
Extend the stat command to display more detailed extent information if
the file uses extent mapping instead of displaying the block map using
the block_iterate funtion.

Add the command dump_extents which displays even more detailed
information about an inode's extent tree.

This commit is an extension of a patch from Curt Wohlgemuth.

Signed-off-by: Curt Wohlgemuth <curtw@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-27 10:37:20 -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 c13351f6c5 Add support for configure --enable-verbose-makecmds
Some people don't want to see the concise "kernel-style" make output.
This configure option allows build engines that want to see the full
set of commands executed by the makefile to get what they want.  Most
people will find this more distracting than useful, unless they need
to debug the Makefiles.

(It is not necessary to rerun configure to enable this verbose make
output temprarily; if a developer wants to do a quick debug of a
directory's makefile, he or she can simply edit the definition of the
$(E) and $(Q) variables in the Makefile; instructions can be found in
the MCONFIG file which is included in at the beginning of every
Makefile.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-02 00:11:17 -04:00
Theodore Ts'o a6a1c0815c Fix Makefile dependencies for libcom_err
The e2fsprogs makefiles were using the same Makefile variable
LIBCOM_ERR for the link-line arguments as well as the dependencies.
Since LIBCOM_ERR can now include non-file arguments such as
"-lpthread", we need to use a separate DEPLIBCOM_ERR variable that
only has build file dependencies.

Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR.

Addresses-Sourceforge-Patches: #2813809

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-01 22:06:51 -04:00
Eric Sandeen dad0bab204 debugfs: don't try to fclose NULL
do_logdump may jump to errout if fopen(out_file) fails,
but in that case out_file is NULL, and fclose will segfault.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-06-29 01:07:29 -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 6e9761c2c0 debugfs: Fix miscellaneous memory leaks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-15 03:54:59 -04:00
Valerie Aurora Henson 1ef4118e0a Add missing free_blocks_hi field to debugfs table.
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01 16:15:40 -04:00
Theodore Ts'o d17ad1234d Update release notes, version string, etc. for E2fsprogs 1.41.6 release 2009-05-30 13:56:31 -04:00
Theodore Ts'o 4f858546e1 Update man pages to include ext4 in the synposis, instead of just "ext2/ext3"
The e2fsprogs programs have historically just said that they operate
on ext2 and ext3 file system in their man pages.  Update them to say
that they also operate on ext4 file systems.

Addresses-Launchpad-bug: #381854

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-30 12:34:28 -04:00
Theodore Ts'o 6dce532867 debugfs: Add -a option to close_filesys command
Add an -a option to the close_filesys command which writes any changes
to the superblock or block group descriptors to all of the backup
superblock locations.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-28 22:03:33 -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
Theodore Ts'o fa15820f4c debugfs: Teach the set_inode_fields_command how to set i_file_acl_high
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 09:41:04 -04:00
Theodore Ts'o 81624c3c7b debugfs: Print 64-bit file acl
This is necessary so we can debug filesystem corruptions caused by the
i_file_acl bogusly getting set.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 09:40:26 -04:00
Manish Katiyar a5bde7959b debugfs: Fix typos in logdump's error messages
Below patch fixes some trivial typos found during code reading

Signed-off-by : Manish Katiyar <mkatiyar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08 20:48: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
Eric Sandeen eefa4d950c debugfs: fix segfault on "stat" command with no open fs
This is a regression from commit
8fdf29117f, which attempts to access
current_fs via a feature check before we check that it's open.

Just moving the feature check below the open check should fix it.

Reported-by: Andrew Hecox <ahecox@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08 19:29:28 -04:00
Theodore Ts'o b7c5b40308 Add support for a new superblock field: s_kbytes_written
This field tracks the lifetime amount of writes to the filesystem.  It
will be updated by the kernel as well as by e2fsprogs programs which
write to the filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 01:59:23 -05:00
Theodore Ts'o 5299580c1c Use format strings directly to prevent -Werror=format-security failures
Gcc is too stupid to realize that:

    const char *usage="String which has no percent signs";

    com_err(progname, 0, usage);

is OK.  I refuse to bow to stupidity with:

   com_err(progname, 0, "%s", usage);

but I will use the string directly for the sake of people who like to
build with -Werror=format-security.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:05:25 -05:00
Theodore Ts'o 98446d7382 debugfs: Fix logdump command for 32-bit filesystems
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-18 22:48:16 -05:00
Theodore Ts'o e3d41d397f debugfs: Fix ncheck display so that extra characters aren't printed
Fix a single-character typo in the printf format statement.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-20 23:51:53 -04:00
Theodore Ts'o a25f0e73a7 debugfs: Fix ncheck when printing pathnames for multiple hardlinks in a directory
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-12 23:12:22 -04:00
Manish Katiyar c59776306c debugfs: Make the usage messsage of logdump consistent with man page
Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-01 19:55:10 -04:00
Theodore Ts'o 03206bd825 debugfs: Fix ncheck to print all pathnames for the inodes
The ncheck command in debugfs had a bug where some inodes would not
have their pathnames printed if other inodes had more than one hard
link.  Fix this bug and simplify the code by printing all of the
pathnames for the requested inodes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-01 19:14:06 -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 711d3846a0 Fix various spelling mistakes in various man pages
Thanks to A. Costa for pointing these out.

Addresses-Debian-Bug: #498100
Addresses-Debian-Bug: #498101
Addresses-Debian-Bug: #498102
Addresses-Debian-Bug: #498103

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-07 14:08:40 -04:00
Manish Katiyar 87dd569b88 debugfs: Fix memory leak in do_ncheck()'s error path
Also the progname printed as "ncheck" instead of "do_ncheck" to be
consistent with the other error messages in debugfs.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-05 07:50:44 -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 eaf8fedcfe debugfs: Use extents when writing a file if the filesystem supports them
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 18:38:47 -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
Andreas Dilger 03efde8abe add debugfs command to print known features
Print out the currently supported features of e2fsprogs/libext2fs
via a new "debugfs supported_features" command.  This helps scripts
to know whether it is possible to try and enable specific features
in the filesystem.

Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-08-24 21:31:52 -04:00
Manish Katiyar 73b0542596 debugfs: Print the progname instead of argv[0] in error message
Trivial fix to print the progname instead of argv[0] in error message.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-08-24 17:29:33 -04:00
Manish Katiyar 4262162ac2 debugfs: Close the file handle and return in case of errors
Close the filehandle and return in case if we are unable to expand the
directory during write.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-08-24 17:29:33 -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 2a7bfe8353 Flush stdio buffers before calling setbuf()
On Solaris setbuf() will discard any pending output to the stream, so
make we call fflush() before calling setbuf().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:57 -04:00
Theodore Ts'o ebabf2ad6d Define _XOPEN_SOURCE to 600 consistently for Solaris C99 support
Solaris's header files are very picky about which C compiler can be
used for SUSv3 conformance.  Use of C99 is not compatible with SUSv2
(_XOPEN_SOURCE=500), and C89 is not compatible with SUSv3
(_XOPEN_SOURCE=600).  Since we need some SUSv3 functions, consistently
use SUSv3 so that e2fsprogs will build on Solaris using c99.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:57 -04:00
Theodore Ts'o 71ff129e9f Merge branch 'maint'
Conflicts:

	README
	resize/online.c
	version.h
2008-06-17 23:54:51 -04:00
Theodore Ts'o 054cd1f61e Clarify the debugfs man page regarding the default superblock
Addresses-Debian-Bug: #486463

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-17 21:57:24 -04:00
Theodore Ts'o 9d99416ea3 Fix dependency for $(LIBSS) when an explicit dlopen() library is needed
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 21:53:35 -04:00
Theodore Ts'o a16031c639 debugfs: Print the nanosecond field and i_version field of an inode
Add support for dumping out the new inode fields added in ext4

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-15 22:17:06 -04:00
Theodore Ts'o 494a1daad3 Basic flexible block group support
Add superblock definition, and dumpe2fs and debugfs support.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-04-22 23:32:15 -04:00
Theodore Ts'o daf7a6e5d1 Fix tst_extents build when building w/o dynamic libraries
$(LIBSS) should automatically include @DLOPEN_LIB@ so the right thing
happens for programs that need to use the ss library.

Reorder the library link order for tst_extents since the blkid library
uses libuuid functions.

Thanks to Eric Sandeen for pointing this problem out!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 16:56:09 -04:00
Andreas Dilger cf96ecf13f debugfs: Add support for "set_block_group <bg_num> checksum calc"
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:26 -04:00
Theodore Ts'o a70f10dbc4 Merge branch 'maint' 2008-03-30 14:03:51 -04:00
Theodore Ts'o a2ff0f31c1 debugfs, tune2fs: Handle daylight savings time when parsing a time string
We need to set tm_isdst to -1 so that mktime will automatically
determine whether or not daylight savings time (DST) is in effect.
Previously tm_isdst was set to 0, which caused mktime to interpret the
time as if it was always not using DST.

Addresses-Debian-Bug: #471882

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-21 09:10:09 -04:00
Jose R. Santos 8fdf29117f Make debugfs uninit block group aware
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:33:12 -04:00
Theodore Ts'o abe85c9f1b Merge branch 'maint' into next 2008-03-20 15:31:03 -04:00
Theodore Ts'o a7ee4e0183 debugfs: Don't use a pager if stdout is not a tty
If we are redirecting the output of debugfs to a file or to another
process via a pipe, there's no point sending the output to a pager.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 10:57:55 -04:00
Theodore Ts'o 2d328bb76d Fix miscellaneous gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-17 23:17:13 -04:00
Theodore Ts'o 399033a6ab Merge branch 'maint' 2008-02-29 00:43:29 -05:00
Andreas Mohr 0fd2f90067 Add manpage references to debugfs/tune2fs commands
Make debugfs and tune2fs reference each other in the "SEE ALSO"
section.

Addresses-Sourceforge-Patches: #1399325

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-28 20:57:08 -05:00
Theodore Ts'o a49670e64e Merge branch 'maint'
Conflicts:

	lib/blkid/devname.c
	lib/blkid/probe.c
	misc/mke2fs.c
	misc/tune2fs.c
2008-02-27 18:53:34 -05:00
Theodore Ts'o 5aae7c292f debugfs: Fix find_free_block to avoid reporting the block more than once
Addresses-Sourceforge-Bug: #1096315

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-27 13:38:56 -05:00
Theodore Ts'o 0157e7c635 Merge branch 'maint' into next 2008-02-18 23:01:43 -05:00
Theodore Ts'o 007df86011 debugfs: Add new superblock fields to the set_super_value command
Signed-off-by: Rupesh Thakare <rupesh@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 22:16:52 -05:00
Eric Sandeen 290ac0e321 print "mostly-printable" xattr strings in debugfs
Taking a cue from getfattr... if a string is "mostly"
printable characters, go ahead & print as a string,
and escape what's left over.

so we get:

Extended attributes stored in inode body:
  selinux = "system_u:object_r:root_t:s0\000" (28)

instead of:

Extended attributes stored in inode body:
  selinux = "73 79 73 74 65 6d 5f 75 3a 6f 62 6a 65 63 74 5f 72 3a 72 6f 6f 74 5f 74 3a 73 30 00 " (28)

(selinux includes the trailing null in "len" so it
never prints as a string today)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-02-18 22:11:20 -05: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
Theodore Ts'o 49ce6cb5ce Allow debugfs to be extended for use by test programs
This change allows debugfs to be reused as the base for e2fsprogs
internal test programs, by linking debugfs object files with
additional object file(s) that define additional commands.  The test
program's object file(s) should define their own comand table, and
define the symbol extra_cmds to be a pointer to the ss_request_table.
In addition, the symbol debug_prog_name can be used to override the
name of the program printed in the version banner and in the ss
prompt.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 15:27:04 -05:00
Theodore Ts'o d8d12558dc debugfs: Fix error handling in strtoblk() and common_block_args_process()
Fix strtoblk() to allow a block number 0, and
common_block_args_process() so it prints an error message if a block
number that can't be parsed by strtoul().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 15:27:04 -05:00
Theodore Ts'o 428f6b32a9 Merge branch 'maint' into next
Conflicts:

	configure
	lib/ext2fs/ext2_fs.h
	misc/e2image.c
2008-01-27 20:09:05 -05:00
Theodore Ts'o d056b99191 debugfs: Add -p option to ls subcommand.
Originally submitted by Jason Pyeron:

While working with a compromized system (suckit root kit) hidden files
were viewable by debugfs but not any other utility.  When spaces and
tabs were put into the directory names defugfs did not "show" them.

"ls -p" quotes the output so is can be parsed easily.

Addresses-Red-Hat-Bugzilla: #149480
Addresses-Sourceforge-Feature-Request: #1201667

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-04 15:28:51 -05:00
Theodore Ts'o b05d4ab635 debugfs: Change lsdel to use ext2fs_block_iterate2 it can find large files
Addresses-Sourceforge-Feature-Request: #1257500
Addresses-Sourceforge-Support-Request: #1253511

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-03 14:53:31 -05:00
Theodore Ts'o fef2b38d8e Merge branch 'maint' into next
Conflicts:

	configure
	debian/rules
	e2fsck/swapfs.c
	lib/ext2fs/ext2_fs.h
2008-01-01 12:41:35 -05:00
Theodore Ts'o b026d539e6 debugfs: allow the undel command reallocate without linking the inode
When recovering a large number of deleted files, linking the undeleted
inodes to directories may require a directory to be expanded.  This
could allocate a block that that had been used by one of the
yet-to-be-undeleted files.  So the 'undel' command been enhanced to
allow the destination pathname to be optional.  This will allow the
cautious user to undelete all of the inodes without specifying a
destination pathname, and then either use debugfs's link command to
add hard links, or use e2fsck to link all of the recovered files to
the lost+found directory.

Addresses-Sourceforge-Feature-Request: #967141

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-01 11:43:41 -05:00
Theodore Ts'o 8192c63308 debugfs: Add #include <string.h> to pick up prototype for strcasecmp
Addresses-Sourceforge-Patch: #1861659

Reported-by: Mike Frysinger <vapier@users.sourceforge.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-01-01 10:27:38 -05:00
Theodore Ts'o d9099eec8e Merge branch 'cl/remove-masix' into next 2007-11-01 01:54:22 -04:00
Coly Li 227181f88f debugfs: remove masix support
This patch remove masix supporting from debugfs.

Singed-off-by: Coly Li <coyli@suse.de>
--
2007-11-01 01:53:55 -04:00
Dmitry V. Levin d9039ae0ff Check fgets(3) return value
When fgets() function fails, contents of the buffer is undefined.  That
is, fgets() return value needs to be checked, to avoid undefined behavior.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2007-10-29 10:59:01 -04:00
Valerie Clement 5d38ef1d04 libext2fs: cleanup usage of unsigned int or __u32 and replace it with blk_t
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-14 21:54:28 -04:00
Theodore Ts'o 2eae093081 Clean up applications to not use EXT2FS_ENABLE_SWAPFS or EXT2_FLAG_SWAP_BYTES
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-11 02:57:31 -04:00
Theodore Ts'o a98b51e9dd Miscellaneous Cleanups
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-03 20:10:46 -04:00
Theodore Ts'o d4e0b1c6f5 Fix gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-03 18:56:01 -04:00
Theodore Ts'o 424a3e4a23 Remove Changelog files since they're not used after the git migration
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-08 08:50:41 -04:00
Theodore Ts'o d7b64725ee Update Release Notes, Changelogs, version.h, etc. for 1.40 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-24 17:32:47 -04: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
Eric Sandeen 5113a6e32b Fix mke2fs and debugfs to support large (> 16 bit) uid's and gid's
Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem.  This wasn't working correctly
if the uid/gid was > 16 bits.   In additional, debugfs wasn't displaying
large uid/gid's correctly.  This patch fixes these two programs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-05-08 00:10:54 -04:00
Theodore Ts'o d362a3fb7e Define the l_i_iversion field in ext2_inode
The l_i_version field is now defined from the old l_i_reserved1 field in
the ext2 inode.  This field will be used to store high 32 bits of the
64-bit inode version number.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-19 01:53:53 -04:00
Theodore Ts'o c7c1209efd Add new debugfs command "set_block_group"
This command allows the user to set a value in the block group descriptors
for a particular block group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-13 15:56:00 -04:00
Theodore Ts'o a4ea6b98f3 Fix debugfs's date parser so that it accepts integer values
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-10 21:10:55 -04:00
Eric Sandeen 3e41913c48 Handle large setb/testb/freeb commands in debugfs
Fix a signed vs. unsigned problem by using blk_t instead of int

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2007-04-10 15:40:04 -04:00
Theodore Ts'o efac5a7f0d debugfs: support > 2GB files for the dump and rdump commands
Add _GNU_SOURCE define to make sure O_LARGEFILE is defined for
do_dump(), and use O_LARGEFILE when writing files using do_rdump().

Addresses Debian Bug: #412614

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-02 18:30:46 -04:00
Brian Behlendorf 971fe05630 [COVERITY] Handle potential case in debugfs if ext2fs_get_pathname returns NULL
Coverity ID: 51: Use After Free

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-29 00:32:23 -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 0bed54fd3e [COVERITY] Fix file handle leak in debugfs's logdump (in error case)
Also fixed a bug in checking if the fopen failed.

Coverity ID: 30: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-23 23:01:09 -04:00
Brian Behlendorf 2f1ecfa5f8 [COVERITY] Fix memory leak on error handling in the debugfs's icheck command
Coverity ID: 25: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-21 19:16:11 -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 57a1cbb643 Allow the debugfs lcd command to work w/o a filesystem being open
Addresses LTC Bugzilla #27513

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-07 08:09:10 -05:00
Matthias Koenig 97fa31b947 Fix dump_usued segault in debugfs if used without open filesystem
The dump_unused command in debugfs segfaults if used without an open
filesystem:

sor:~ # debugfs
debugfs 1.39 (29-May-2006)
debugfs:  dump_unused
Segmentation fault

Patch (from IBM) below.

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
2007-01-28 12:40:28 -05:00
Theodore Ts'o a6d8302b48 Use the newer add/remove_error_table com_err interfaces
Change all of the e2fsprogs programs to use the newer add_error_table()
and remove_error_table() interfaces instead of the much older
initialize_*_error_table() function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-12-26 03:38:07 -05:00
Theodore Ts'o cf8272e108 Allow debugfs and dumpe2fs to support fs features under development
Add support for the new flag EXT2_FLAG_SOFTSUPP_FEATURES flag to
ext2fs_open() , which allows application to open filesystes with features
which are currently only partially supported by e2fsprogs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-12 23:26:46 -05: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
Theodore Ts'o 5d17119d14 On-disk format definition for huge files
- EXT4_FEATURE_RO_COMPAT_HUGE_FILE (0x0008) - change i_blocks to be
  in units of s_blocksize units instead of 512-byte sectors, use
  l_i_frag and l_i_fsize as i_blocks_hi (could also be part of 64BIT).

E2fsck and debugfs changed to support i_blocks_hi instead of l_i_frag and
l_i_fsize.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 06:32:03 -05:00
Theodore Ts'o cce2f497e0 Fix Debian FTBFS problem caused by devmapper library using pthreads
Addresses Debian bug: #388718

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-01 22:18:08 -04: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 6cab406d2b Fix debugfs coredump when lsdel is run without an open filesystem
Addresses Debian Bug: #378335

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-08-29 17:02:56 -04:00
Andreas Dilger d047e073e7 debugfs "stat" should print unsigned values for xattrs
This patch changes debugfs to print unsigned chars when "stat" on an inode
finds xattrs in the inode.  Without this change, the values are printed
as signed chars, e.g. "ffffffec" instead of "ec".

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2006-06-21 00:01:42 -04:00
Theodore Ts'o 9c07dc00b8 Add missing backwards compatibility for ancient Linux systems
This fixes some (but not all) of the compatibility bugs which prevented
e2fsprogs from being compiled on a Linux 2.0.35 system.  There are still
some unprotected use of long long's, and apparently some type problems
with the uuid library, but these can be fixed up later.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-29 11:06:16 -04:00
Theodore Ts'o 2c83031791 Fix debugfs's dump_unsued commands on filesystems with a 64k blocksize
Use EXT2_MAX_BLOCK_SIZE instead of a hardcoded blocksize of 32768, since 
this will fail on a filesystem with a 64k blocksize.  (Addresses SourceForge
bug #1424311)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-28 23:42:47 -04:00
Theodore Ts'o e3e92534ac Fix type warning problem with time_t in debugfs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-21 19:26:06 -04:00
Theodore Ts'o f5fa20078b Add support for EXT2_FEATURE_COMPAT_LAZY_BG
This feature is initially intended for testing purposes; it allows an
ext2/ext3 developer to create very large filesystems using sparse files
where most of the block groups are not initialized and so do not require
much disk space.  Eventually it could be used as a way of speeding up
mke2fs and e2fsck for large filesystem, but that would be best done by 
adding an RO_COMPAT extension to the filesystem to allow the inode table
to be lazily initialized on a per-block basis, instead of being entirely initialized
or entirely unused on a per-blockgroup basis.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-08 20:17:26 -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 98eb44bdb5 Add an option to debugfs to open filesystems in exclusive mode
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-18 19:58:13 -05:00
Theodore Ts'o 6a2efe047d Fix debugfs's icheck to correctly report the owner of an EA block
Hello Ted,
here is a minor fixup with debugfs "icheck" finding a block in an EA.
It was reporting the inode number as one too low because it was set
after the EA check is done.

From: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-08 18:22:06 -05:00
Theodore Ts'o 9b9a780f5a Fix various gcc -Wall complaints.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-12-10 21:50:30 -05:00
Theodore Ts'o 4efae606bf New debugfs command: set_current_time
Generalize the time parsing code and move it to
util.c:string_to_time().  Add new command, set_current_time, which
sets the time used to set the filesystems's time fields.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-24 21:56:38 -04:00
Theodore Ts'o 38d732bb5a Fix debugfs's set_inode_field so it can properly set i_size
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-06 05:42:44 -04:00
Theodore Ts'o caf037a456 Fix debugfs's set_inode_fields command from silently failing.
The set_inodes_field command was silently failing when setting one of
the following fields: frag, fsize, uid_high, gid_high, and author.
The type size for these fields were set to an incorrect value in the
inode_fields table.
2005-07-04 12:24:40 -05:00