summaryrefslogtreecommitdiff
path: root/misc/dumpe2fs.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid potential NULL dereference when argv[0]Theodore Ts'o2022-08-111-1/+2
| | | | | | | | | Addresses-Coverity-Bug: 1500772 Addresses-Coverity-Bug: 1500769 Addresses-Coverity-Bug: 1500767 Addresses-Coverity-Bug: 1500758 Addresses-Coverity-Bug: 1500756 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* dumpe2fs, resize2fs: avoid memory leak on error pathzhanchengbin2022-05-111-0/+1
| | | | | | Link: https://lore.kernel.org/r/cbfd9852-bc89-1e83-f101-36fd29a0e70e@huawei.com Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Fix clang warnings on architectures with a 64-bit longTheodore Ts'o2021-02-111-8/+10
| | | | | | | | | | | | On most systems where we compile e2fsprogs, the u64 type is an unsigned long long. However, there are platforms (such as the PowerPC) where a long 64-bits and so u64 is typedef'ed to be unsigned long instead of a unsigned long long. Fix this by using explicit casts in printf statements. For scanf calls, we need to receive the value into a unsigned long long, and then assign it to a u64, after doing range checks. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Make userspace tools number of fast commits blocks awareHarshad Shirwadkar2021-01-211-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes number of fast commit blocks configurable. Also, the number of fast commit blocks can now be seen in dumpe2fs output. $ ./misc/mke2fs -O fast_commit -t ext4 image mke2fs 1.46-WIP (20-Mar-2020) Discarding device blocks: done Creating filesystem with 5120 1k blocks and 1280 inodes Allocating group tables: done Writing inode tables: done Creating journal (1040 blocks): done Writing superblocks and filesystem accounting information: done $ ./misc/dumpe2fs image dumpe2fs 1.46-WIP (20-Mar-2020) ... Journal features: (none) Total journal size: 1040k Total journal blocks: 1040 Max transaction length: 1024 Fast commit length: 16 Journal sequence: 0x00000001 Journal start: 0 $ ./misc/mke2fs -O fast_commit -t ext4 image -J fast_commit_size=256,size=1 mke2fs 1.46-WIP (20-Mar-2020) Creating filesystem with 5120 1k blocks and 1280 inodes Allocating group tables: done Writing inode tables: done Creating journal (1280 blocks): done Writing superblocks and filesystem accounting information: done $ ./misc/dumpe2fs image dumpe2fs 1.46-WIP (20-Mar-2020) ... Journal features: (none) Total journal size: 1280k Total journal blocks: 1280 Max transaction length: 1024 Fast commit length: 256 Journal sequence: 0x00000001 Journal start: 0 This patch also adds information about fast commit feature in mke2fs and tune2fs man pages. Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Enable threaded support for e2fsprogs' applications.Theodore Ts'o2021-01-211-1/+1
| | | | Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Merge branch 'maint' into nextTheodore Ts'o2020-03-071-1/+1
|\
| * e2fsck: use proper types for variablesAndreas Dilger2020-02-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Use ext2_ino_t instead of ino_t for referencing inode numbers. Use loff_t for for file offsets, and dgrp_t for group numbers. Cast products to ssize_t before multiplication to avoid overflow. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Reviewed-by: Shilong Wang <wshilong@ddn.com> Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2020-01-251-4/+8
|\ \ | |/
| * mmp: abstract out repeated 'sizeof(buf), buf' usageAndreas Dilger2020-01-241-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The printf("%.*s") format requires both the buffer size and buffer pointer to be specified for each use. Since this is repeatedly given as "(int)sizeof(buf), (char *)buf" for mmp_nodename and mmp_bdevname fields, with typecasts to avoid compiler warnings. Add a helper macro EXT2_LEN_STR() to avoid repeated boilerplate code. This can also be used for other superblock buffer fields that may not have NUL-terminated strings (e.g. s_volume_name, s_last_mounted, s_{first,last}_error_func, s_mount_opts) to simplify code and avoid the need for temporary buffers for NUL-termination. Annotate the superblock string fields that may not be NUL-terminated. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
| * mmp: don't assume NUL termination for MMP stringsAndreas Dilger2020-01-241-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Don't assume that mmp_nodename and mmp_bdevname are NUL terminated, since very long node/device names may completely fill the buffers. Limit string printing to the maximum buffer size for safety, and change the field definitions to __u8 to make it more clear that they are not NUL-terminated strings, as is done with other strings in the superblock that do not have NUL termination. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Rename functions, types, constants to reflect jbd2 usageTheodore Ts'o2019-11-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had previously stuck to using the names from ext3/jbd kernel files, and used a script in contrib/jbd2-resync.sh to convert the kernel files to use the ext3/jbd conventions so we could keep the files e2fsck/recovery.c and e2fsck/revoke.c in sync with jbd2/recovery.c and jbd2/revoke.c, respectively. This has been getting harder and harder, so let's make a global sweep through e2fsprogs to use the jbd2 names. Fortunately none of the ext3/jbd names had leaked out into publically exported header files, so this is only an internal change. Which looks scary, but it's basically a search and replace, so if it compiles it's going to be correct. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Teach ext2fs_open2() to honor the EXT2_FLAG_SUPER_ONLY flagTheodore Ts'o2019-10-221-0/+2
|/ | | | | | | | | | | | | | | Opening the file system with EXT2_FLAG_SUPER_ONLY will leave fs->group_desc to be NULL and modify "dumpe2fs -h" and tune2fs when it is emulating e2label to use this flag. This speeds up "dumpe2fs -h" and "e2label" when operating on very large file systems. To allow other libext2fs functions to work without too many surprises, ext2fs_group_desc() will read in the block group descriptors on demand. This allows "dumpe2fs -h" to be able to read the journal inode, for example. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cray-bug-id: LUS-5777
* misc: add e2mmpstatus utility via dumpe2fsShuichi Ihara2018-06-221-40/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | e2mmpstatus is a Multi-Mount Protection (MMP) helper utility to read an MMP block to see if it is being updated. It can also output the latest update time, nodename, and device from the MMP block. This is useful for HA and other maintenance scripts to determine if the filesystem is in use on another node, and which node it is. Signed-off-by: Shuichi Ihara <sihara@ddn.com> Signed-off-by: Li Xi <lixi@ddn.com> Signed-off-by: Wang Shilong <wshilong@ddn.com> Moved e2mmpstatus checking/dumping code to be part of dumpe2fs rather than a standalone program, using the "-m" option to check MMP status, and "-i" to dump info. If dumpe2fs is called as "e2mmpstatus" (and also "mmpstatus" for compatibility reasons), assume "-m" is specified. Re-use the existing MMP block handing routines (with some changes) to check and dump the MMP block, rather than adding duplicate versions. Modify dumpe2fs to exit with a non-zero error code if there is an error while reading the filesystem metadata or MMP block, or if "-m" is used with the "mmp" feature and is in use by another node. Add a configure check for gethostname() rather than depending on _BSD_SOURCE or _XOPEN_SOURCE to be set. Update the f_mmp, m_mmp, m_mmp_bad_csum, and m_mmp_bad_magic tests to use e2mmpstatus to check and dump the MMP state before and after e2fsck is run to verify that the tool is working correctly. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc: fix all the compiler warningsDarrick J. Wong2017-03-031-15/+0
| | | | | | | | | | Fix the various compiler warnings that have crept in, and only define __bitwise if the system headers haven't already done so. Linux 4.10 changes the __bitwise definition so that our redefinition here is just different enough that gcc complains. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Refactor code to print journal superblock informationTheodore Ts'o2017-02-161-83/+2
| | | | | | | | Move the code to list the journal superblock information to libe2p, so it can be used by debugfs, and so we don't have two copies of substantially the same code in dumpe2fs. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc: clean up feature test macros with predicate functionsDarrick J. Wong2015-10-241-16/+9
| | | | | | | | | 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>
* Move the check_plausibility() function from misc to lib/supportTheodore Ts'o2015-07-121-2/+2
| | | | | | | | The check_plausibility() function is now used all over the place, so we should move the plausible.c file to lib/support and remove the special case handling for that file that had been in the build system. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* libext2fs, libe2p, misc: git rid of jfs_user.hTheodore Ts'o2015-05-251-1/+1
| | | | | | | | | | Having multiple versions of jfs_user.h was confusing the Android build. Clean up things by removing the lib/ext2fs/jfs_user.h and misc/jfs_user.h and simplifying how we emulate the kernel infrastructure needed by journal replay code and removing the kernel-specific lines from kernel-jbd.h. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* dumpe2fs: output cleanupDarrick J. Wong2014-12-131-5/+3
| | | | | | | | | Don't display unused inodes twice, and make it clear that we're printing a descriptor checksum. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Cc: TR Reardon <thomas_reardon@hotmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* dumpe2fs: reduce dumpe2fs output to 80 columns or lessDarrick J. Wong2014-12-131-1/+5
| | | | | Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Merge branch 'maint' into nextTheodore Ts'o2014-12-021-1/+1
|\
| * dumpe2fs: don't crash when the user provides no block device argumentDarrick J. Wong2014-11-071-1/+1
| | | | | | | | | | | | | | | | If the user doesn't provide any arguments, the guard fails to run and the whole thing segfaults on ext2fs_open2(). Don't do that. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | misc: add plausibility checks to debugfs/tune2fs/dumpe2fs/e2fsckDarrick J. Wong2014-09-191-0/+3
| | | | | | | | | | | | | | | | | | | | If any of these utilities detect a bad superblock magic, call check_plausibility to see if blkid can identify the passed-in argument as something else (xfs, partition, etc.) in the hopes of catching a user error. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | dumpe2fs: provide a machine-readable group-only modeDarrick J. Wong2014-09-191-5/+35
| | | | | | | | | | | | | | | | Spit out just the group descriptor data in a machine readable format. This is most useful for testing and scripting purposes. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | dumpe2fs: display external journal feature flagsDarrick J. Wong2014-09-111-1/+13
| | | | | | | | | | | | | | | | Display the feature flags of an external journal. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reported-by: TR Reardon <thomas_reardon@hotmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | e2fsck/debugfs: fix descriptor block size handling errors with journal_csumDarrick J. Wong2014-09-111-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that there are some serious problems with the on-disk format of journal checksum v2. The foremost is that the function to calculate descriptor tag size returns sizes that are too big. This causes alignment issues on some architectures and is compounded by the fact that some parts of jbd2 use the structure size (incorrectly) to determine the presence of a 64bit journal instead of checking the feature flags. These errors regrettably lead to the journal corruption reported by Mr. Reardon. Therefore, introduce journal checksum v3, which enlarges the descriptor block tag format to allow for full 32-bit checksums of journal blocks, fix the journal tag function to return the correct sizes, and fix the jbd2 recovery code to use feature flags to determine 64bitness. Add a few function helpers so we don't have to open-code quite so many pieces. Switching to a 16-byte block size was found to increase journal size overhead by a maximum of 0.1%, to convert a 32-bit journal with no checksumming to a 32-bit journal with checksum v3 enabled. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reported-by: TR Reardon <thomas_reardon@hotmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2014-08-251-1/+3
|\ \ | |/ | | | | | | | | | | Conflicts: RELEASE-NOTES debian/changelog version.h
| * dumpe2fs: complain if extra arguments are given on the command lineTheodore Ts'o2014-08-241-1/+3
| | | | | | | | | | | | Addresses-Debian-Bug: #758074 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | dumpe2fs: complain when checksum verification failsDarrick J. Wong2014-08-021-1/+16
| | | | | | | | | | | | | | | | Warn the user to run e2fsck if the superblock or bitmaps fails checksum verification. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2014-07-061-3/+3
|\ \ | |/ | | | | | | | | | | | | | | | | Conflicts: debugfs/set_fields.c tests/f_mmp/script tests/f_mmp_garbage/script tests/m_mmp/script tests/t_mmp_1on/script tests/t_mmp_2off/script
| * e2fsprogs: introduce ext2fs_close_free() helperLukas Czerner2014-07-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently there are many uses of ext2fs_close() which might be wrong. First of all ext2fs_close() does not set the ext2_filsys pointer to NULL so the caller is responsible for clearing it, however there are some cases there we do not do it. Second of all very small number of users of ext2fs_close() actually check the return value. If there is a problem in ext2fs_close() it will not even free the ext2_filsys structure, but majority of users expect it to do so. To fix both problems this commit introduces a new helper ext2fs_close_free() which will not only check for the return value and free the ext2_filsys structure if the call to ext2fs_close2() failed, but it will also set the ext2_filsys pointer to NULL. Replace every use of ext2fs_close() in e2fsprogs tools with ext2fs_close_free() - there is no real reason to keep using ext2fs_close(). Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
* | misc: fix compile warnings on master branchAndreas Dilger2014-05-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix compile warnings found on the master branch when using LLVM. - Add missing format string when using the libintl _() macro - include <limits.h> header to get PATH_MAX definition - fix format vs. variable mismatches - add header block for create_inode.c file - remove use of bzero(), use ext2fs_get_memzero() instead Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2013-12-261-4/+6
|\ \ | |/ | | | | | | Conflicts: lib/ext2fs/csum.c
| * dumpe2fs: don't try to print the journal info when using image filesTheodore Ts'o2013-12-261-0/+2
| | | | | | | | | | | | | | | | If dumpe2fs tries to print journal info when using an image file created using e2image, it will crash since the journal isn't available. So don't even try to print it. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
| * Clean up sparse warningsTheodore Ts'o2013-12-161-4/+4
| | | | | | | | | | | | | | Mostly by adding static and removing excess extern qualifiers. Also convert a few remaining non-ANSI function declarations to ANSI. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2013-12-161-15/+17
|\ \ | |/ | | | | | | Conflicts: debugfs/debugfs.8.in
| * build: quiet LLVM non-literal string format warningAndreas Dilger2013-12-151-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compiling with LLVM generates a large number of warnings due to the use of _() for wrapping strings for i18n: warning: format string is not a string literal (potentially insecure) [-Wformat-security] ./nls-enable.h:4:14: note: expanded from macro '_' #define _(a) (gettext (a)) ^~~~~~~~~~~~ These warnings are fixed by using "%s" as the format string, and then _() is used as the string argument. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2013-12-121-8/+18
|\ \ | |/ | | | | | | Conflicts: lib/ext2fs/newdir.c
| * dumpe2fs: check return valuesDarrick J. Wong2013-12-121-8/+18
| | | | | | | | | | | | | | | | Check the return values from ext2fs_get_block_bitmap_range2(); if an error happened, print that and don't print garbage bitmap. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2013-12-031-1/+1
|\ \ | |/ | | | | | | | | Conflicts: e2fsck/pass2.c e2fsck/pass3.c
| * dumpe2fs: fix printing of block offsets for 64-bit file systemsTheodore Ts'o2013-12-021-1/+1
| | | | | | | | | | | | | | | | Use ext2fs_group_first_block2() instead of ext2fs_group_first_block() to avoid dumpe2fs from printing crazy block offsets when we have block numbers which are larger than 32 bits. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2013-10-121-1/+1
|\ \ | |/ | | | | | | | | | | Conflicts: e2fsck/problem.c e2fsck/rehash.c e2fsck/super.c
| * e2fsprogs: fix blk_t <- blk64_t assignment mismatchesDarrick J. Wong2013-10-071-1/+1
| | | | | | | | | | | | | | | | | | Fix all the places where we should be using a blk64_t instead of a blk_t. These fixes are more severe because 64bit values could be truncated silently. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* | misc: fix gcc -Wall nitsTheodore Ts'o2013-05-201-1/+1
| | | | | | | | | | | | [For 1.43 branch] Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* | libext2fs: dump feature flags for jbd2 v2 checksumsDarrick J. Wong2012-08-021-0/+29
| | | | | | | | | | | | | | Modify the dump code to print information about jbd2 v2 checksum data. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | libext2fs: block group checksum should use metadata_csum algorithmDarrick J. Wong2012-08-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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>
* | dumpe2fs: display block bitmap checksumDarrick J. Wong2012-07-301-0/+4
| | | | | | | | | | | | | | Display the block bitmap checksum when displaying block groups. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | dumpe2fs: display inode bitmap checksumDarrick J. Wong2012-07-301-0/+4
|/ | | | | | | Display the inode bitmap checksum for each block group. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* dumpe2fs: print journal's s_errno field if it is non-zeroTheodore Ts'o2012-05-311-0/+3
| | | | Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* dumpe2fs: fix 64-bit block numbers on 32-bit systemsTheodore Ts'o2012-05-141-8/+17
| | | | | | | Fix bug which caused 64-bit block numbers to be incorrectly printed on systems with 32-bit longs. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>