"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "debugfs/logdump.c" between
e2fsprogs-1.46.6.tar.gz and e2fsprogs-1.47.0.tar.gz

About: e2fsprogs provides the filesystem utilities for use with the ext2 filesystem. It also supports the ext3 and ext4 filesystems.

logdump.c  (e2fsprogs-1.46.6):logdump.c  (e2fsprogs-1.47.0)
skipping to change at line 51 skipping to change at line 51
#if __GNUC_PREREQ (4, 6) #if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
#include <uuid/uuid.h> #include <uuid/uuid.h>
enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL}; enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
#define ANY_BLOCK ((blk64_t) -1) #define ANY_BLOCK ((blk64_t) -1)
static int dump_all, dump_super, dump_old, dump_contents, dump_descr iptors; static int dump_all, dump_super, dump_old, dump_contents, dump_descr iptors;
static int64_t dump_counts;
static blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump; static blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
static unsigned int group_to_dump, inode_offset_to_dump; static unsigned int group_to_dump, inode_offset_to_dump;
static ext2_ino_t inode_to_dump; static ext2_ino_t inode_to_dump;
struct journal_source struct journal_source
{ {
enum journal_location where; enum journal_location where;
int fd; int fd;
ext2_file_t file; ext2_file_t file;
}; };
skipping to change at line 116 skipping to change at line 117
journal_source.file = 0; journal_source.file = 0;
dump_all = 0; dump_all = 0;
dump_old = 0; dump_old = 0;
dump_contents = 0; dump_contents = 0;
dump_super = 0; dump_super = 0;
dump_descriptors = 1; dump_descriptors = 1;
block_to_dump = ANY_BLOCK; block_to_dump = ANY_BLOCK;
bitmap_to_dump = -1; bitmap_to_dump = -1;
inode_block_to_dump = ANY_BLOCK; inode_block_to_dump = ANY_BLOCK;
inode_to_dump = -1; inode_to_dump = -1;
dump_counts = -1;
reset_getopt(); reset_getopt();
while ((c = getopt (argc, argv, "ab:ci:f:OsS")) != EOF) { while ((c = getopt (argc, argv, "ab:ci:f:OsSn:")) != EOF) {
switch (c) { switch (c) {
case 'a': case 'a':
dump_all++; dump_all++;
break; break;
case 'b': case 'b':
block_to_dump = strtoul(optarg, &tmp, 0); block_to_dump = strtoul(optarg, &tmp, 0);
if (*tmp) { if (*tmp) {
com_err(argv[0], 0, com_err(argv[0], 0,
"Bad block number - %s", optarg); "Bad block number - %s", optarg);
return; return;
skipping to change at line 151 skipping to change at line 153
break; break;
case 'O': case 'O':
dump_old++; dump_old++;
break; break;
case 's': case 's':
use_sb++; use_sb++;
break; break;
case 'S': case 'S':
dump_super++; dump_super++;
break; break;
case 'n':
dump_counts = strtol(optarg, &tmp, 10);
if (*tmp) {
com_err(argv[0], 0,
"Bad log counts number - %s", optarg);
return;
}
break;
default: default:
goto print_usage; goto print_usage;
} }
} }
if (optind != argc && optind != argc-1) { if (optind != argc && optind != argc-1) {
goto print_usage; goto print_usage;
} }
if (inode_spec) { if (inode_spec) {
int inode_group, group_offset, inodes_per_block; int inode_group, group_offset, inodes_per_block;
skipping to change at line 292 skipping to change at line 302
if (journal_fd >= 0) if (journal_fd >= 0)
close(journal_fd); close(journal_fd);
if (journal_file) if (journal_file)
ext2fs_file_close(journal_file); ext2fs_file_close(journal_file);
if (out_file && (out_file != stdout)) if (out_file && (out_file != stdout))
fclose(out_file); fclose(out_file);
return; return;
print_usage: print_usage:
fprintf(stderr, "%s: Usage: logdump [-acsOS] [-b<block>] [-i<filespec>]\n \t" fprintf(stderr, "%s: Usage: logdump [-acsOS] [-n<num_trans>] [-b<block>] [-i<filespec>]\n\t"
"[-f<journal_file>] [output_file]\n", argv[0]); "[-f<journal_file>] [output_file]\n", argv[0]);
} }
static int read_journal_block(const char *cmd, struct journal_source *source, static int read_journal_block(const char *cmd, struct journal_source *source,
ext2_loff_t offset, char *buf, unsigned int size) ext2_loff_t offset, char *buf, unsigned int size)
{ {
int retval; int retval;
unsigned int got; unsigned int got;
if (source->where == JOURNAL_IS_EXTERNAL) { if (source->where == JOURNAL_IS_EXTERNAL) {
skipping to change at line 367 skipping to change at line 377
struct ext2_super_block *sb; struct ext2_super_block *sb;
char jsb_buffer[1024]; char jsb_buffer[1024];
char buf[EXT2_MAX_BLOCK_SIZE]; char buf[EXT2_MAX_BLOCK_SIZE];
journal_superblock_t *jsb; journal_superblock_t *jsb;
unsigned int blocksize = 1024; unsigned int blocksize = 1024;
int retval; int retval;
__u32 magic, sequence, blocktype; __u32 magic, sequence, blocktype;
journal_header_t *header; journal_header_t *header;
tid_t transaction; tid_t transaction;
unsigned int blocknr = 0; unsigned int blocknr = 0;
unsigned int first_transaction_blocknr;
int fc_done; int fc_done;
__u64 total_len; __u64 total_len;
__u32 maxlen; __u32 maxlen;
int64_t cur_counts = 0;
bool exist_no_magic = false;
/* First, check to see if there's an ext2 superblock header */ /* First, check to see if there's an ext2 superblock header */
retval = read_journal_block(cmdname, source, 0, buf, 2048); retval = read_journal_block(cmdname, source, 0, buf, 2048);
if (retval) if (retval)
return; return;
jsb = (journal_superblock_t *) buf; jsb = (journal_superblock_t *) buf;
sb = (struct ext2_super_block *) (buf+1024); sb = (struct ext2_super_block *) (buf+1024);
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
skipping to change at line 459 skipping to change at line 472
blocknr, transaction); blocknr, transaction);
if (!blocknr) { if (!blocknr) {
/* Empty journal, nothing to do. */ /* Empty journal, nothing to do. */
if (!dump_old) if (!dump_old)
goto fc; goto fc;
else else
blocknr = 1; blocknr = 1;
} }
first_transaction_blocknr = blocknr;
while (1) { while (1) {
if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts
))
break;
if ((blocknr == first_transaction_blocknr) &&
(cur_counts != 0) && dump_old && (dump_counts != -1)) {
fprintf(out_file, "Dump all %lld journal records.\n",
(long long) cur_counts);
break;
}
retval = read_journal_block(cmdname, source, retval = read_journal_block(cmdname, source,
((ext2_loff_t) blocknr) * blocksize, ((ext2_loff_t) blocknr) * blocksize,
buf, blocksize); buf, blocksize);
if (retval) if (retval)
break; break;
header = (journal_header_t *) buf; header = (journal_header_t *) buf;
magic = be32_to_cpu(header->h_magic); magic = be32_to_cpu(header->h_magic);
sequence = be32_to_cpu(header->h_sequence); sequence = be32_to_cpu(header->h_sequence);
blocktype = be32_to_cpu(header->h_blocktype); blocktype = be32_to_cpu(header->h_blocktype);
if (magic != JBD2_MAGIC_NUMBER) { if (magic != JBD2_MAGIC_NUMBER) {
fprintf (out_file, "No magic number at block %u: " if (exist_no_magic == false) {
"end of journal.\n", blocknr); exist_no_magic = true;
fprintf(out_file, "No magic number at block %u: "
"end of journal.\n", blocknr);
}
if (dump_old && (dump_counts != -1)) {
blocknr++;
WRAP(jsb, blocknr, maxlen);
continue;
}
break; break;
} }
if (sequence != transaction) { if (sequence != transaction) {
fprintf (out_file, "Found sequence %u (not %u) at " fprintf (out_file, "Found sequence %u (not %u) at "
"block %u: end of journal.\n", "block %u: end of journal.\n",
sequence, transaction, blocknr); sequence, transaction, blocknr);
if (!dump_old) if (!dump_old)
break; break;
} }
skipping to change at line 501 skipping to change at line 534
} }
switch (blocktype) { switch (blocktype) {
case JBD2_DESCRIPTOR_BLOCK: case JBD2_DESCRIPTOR_BLOCK:
dump_descriptor_block(out_file, source, buf, jsb, dump_descriptor_block(out_file, source, buf, jsb,
&blocknr, blocksize, maxlen, &blocknr, blocksize, maxlen,
transaction); transaction);
continue; continue;
case JBD2_COMMIT_BLOCK: case JBD2_COMMIT_BLOCK:
cur_counts++;
transaction++; transaction++;
blocknr++; blocknr++;
WRAP(jsb, blocknr, maxlen); WRAP(jsb, blocknr, maxlen);
continue; continue;
case JBD2_REVOKE_BLOCK: case JBD2_REVOKE_BLOCK:
dump_revoke_block(out_file, buf, jsb, dump_revoke_block(out_file, buf, jsb,
blocknr, blocksize, blocknr, blocksize,
transaction); transaction);
blocknr++; blocknr++;
 End of changes. 11 change blocks. 
4 lines changed or deleted 39 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)