enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
-#define ANY_BLOCK ((blk_t) -1)
+#define ANY_BLOCK ((blk64_t) -1)
-int dump_all, dump_contents, dump_descriptors;
-blk_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
-unsigned int group_to_dump, inode_offset_to_dump;
-ext2_ino_t inode_to_dump;
+static int dump_all, dump_contents, dump_descriptors;
+static blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
+static unsigned int group_to_dump, inode_offset_to_dump;
+static ext2_ino_t inode_to_dump;
struct journal_source
{
(group_offset / inodes_per_block);
inode_offset_to_dump = ((group_offset % inodes_per_block)
* sizeof(struct ext2_inode));
- printf("Inode %u is at group %u, block %u, offset %u\n",
+ printf("Inode %u is at group %u, block %llu, offset %u\n",
inode_to_dump, inode_group,
inode_block_to_dump, inode_offset_to_dump);
}
static int read_journal_block(const char *cmd, struct journal_source *source,
- off_t offset, char *buf, int size,
- unsigned int *got)
+ off_t offset, char *buf, unsigned int size)
{
int retval;
+ unsigned int got;
if (source->where == JOURNAL_IS_EXTERNAL) {
if (lseek(source->fd, offset, SEEK_SET) < 0) {
retval = errno;
- com_err(cmd, retval, "while seeking in reading journal");
- return retval;
+ goto seek_err;
}
retval = read(source->fd, buf, size);
- if (retval >= 0) {
- *got = retval;
- retval = 0;
- } else
+ if (retval < 0) {
retval = errno;
+ goto read_err;
+ }
+ got = retval;
+ retval = 0;
} else {
retval = ext2fs_file_lseek(source->file, offset,
EXT2_SEEK_SET, NULL);
if (retval) {
+ seek_err:
com_err(cmd, retval, "while seeking in reading journal");
return retval;
}
-
- retval = ext2fs_file_read(source->file, buf, size, got);
+ retval = ext2fs_file_read(source->file, buf, size, &got);
+ if (retval) {
+ read_err:
+ com_err(cmd, retval, "while reading journal");
+ return retval;
+ }
}
-
- if (retval)
- com_err(cmd, retval, "while reading journal");
- else if (*got != (unsigned int) size) {
- com_err(cmd, 0, "short read (read %d, expected %d) "
- "while reading journal", *got, size);
+ if (got != size) {
+ com_err(cmd, 0, "short read (read %u, expected %u) "
+ "while reading journal", got, size);
retval = -1;
}
-
return retval;
}
char buf[8192];
journal_superblock_t *jsb;
unsigned int blocksize = 1024;
- unsigned int got;
int retval;
__u32 magic, sequence, blocktype;
journal_header_t *header;
unsigned int blocknr = 0;
/* First, check to see if there's an ext2 superblock header */
- retval = read_journal_block(cmdname, source, 0,
- buf, 2048, &got);
+ retval = read_journal_block(cmdname, source, 0, buf, 2048);
if (retval)
return;
/* Next, read the journal superblock */
retval = read_journal_block(cmdname, source, blocknr*blocksize,
- jsb_buffer, 1024, &got);
+ jsb_buffer, 1024);
if (retval)
return;
while (1) {
retval = read_journal_block(cmdname, source,
blocknr*blocksize, buf,
- blocksize, &got);
- if (retval || got != blocksize)
+ blocksize);
+ if (retval)
return;
header = (journal_header_t *) buf;
int blocksize,
tid_t transaction)
{
- unsigned int got;
int retval;
char buf[8192];
retval = read_journal_block("logdump", source,
blocksize * log_blocknr,
- buf, blocksize, &got);
+ buf, blocksize);
if (retval)
return;
offset = ((block_to_dump - super->s_first_data_block) %
super->s_blocks_per_group);
- fprintf(out_file, " (block bitmap for block %u: "
+ fprintf(out_file, " (block bitmap for block %llu: "
"block is %s)\n",
block_to_dump,
ext2fs_test_bit(offset, buf) ? "SET" : "CLEAR");