/*
* There must be only one definition if we're hooking in extra commands or
- * chaging default prompt. Use -DSKIP_GLOBDEF for that.
+ * changing default prompt. Use -DSKIP_GLOBDEF for that.
*/
#ifndef SKIP_GLOBDEFS
ss_request_table *extra_cmds;
}
current_fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
- if (catastrophic)
- com_err(device, 0, "catastrophic mode - not reading inode or group bitmaps");
- else {
+ if (!catastrophic) {
retval = ext2fs_read_bitmaps(current_fs);
if (retval) {
com_err(device, retval,
int catastrophic = 0;
blk64_t superblock = 0;
blk64_t blocksize = 0;
- int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
+ int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS |
+ EXT2_FLAG_THREADS;
char *data_filename = 0;
char *undo_file = NULL;
"inode table at %llu\n"
" %u free %s%s, "
"%u free %s, "
- "%u used %s%s",
- i, ext2fs_block_bitmap_loc(current_fs, i),
- ext2fs_inode_bitmap_loc(current_fs, i),
- ext2fs_inode_table_loc(current_fs, i),
- ext2fs_bg_free_blocks_count(current_fs, i), units,
+ "%u used %s%s", i,
+ (unsigned long long) ext2fs_block_bitmap_loc(current_fs, i),
+ (unsigned long long) ext2fs_inode_bitmap_loc(current_fs, i),
+ (unsigned long long) ext2fs_inode_table_loc(current_fs, i),
+ ext2fs_bg_free_blocks_count(current_fs, i),
+ units,
ext2fs_bg_free_blocks_count(current_fs, i) != 1 ?
"s" : "",
ext2fs_bg_free_inodes_count(current_fs, i),
fprintf(lb->f, ", ");
if (lb->first_block == lb->last_block)
fprintf(lb->f, "(%lld):%llu",
- (long long)lb->first_bcnt, lb->first_block);
+ (long long)lb->first_bcnt,
+ (unsigned long long) lb->first_block);
else
fprintf(lb->f, "(%lld-%lld):%llu-%llu",
(long long)lb->first_bcnt, (long long)lb->last_bcnt,
- lb->first_block, lb->last_block);
+ (unsigned long long) lb->first_block,
+ (unsigned long long) lb->last_block);
lb->first_block = 0;
}
info.curr_level, info.max_depth,
info.curr_entry, info.num_entries,
logical_width,
- extent.e_lblk,
+ (unsigned long long) extent.e_lblk,
logical_width,
- extent.e_lblk + (extent.e_len - 1),
+ (unsigned long long) extent.e_lblk + (extent.e_len - 1),
physical_width,
- extent.e_pblk,
+ (unsigned long long) extent.e_pblk,
physical_width+3, "", extent.e_len);
continue;
}
fprintf(f, "%s(ETB%d):%llu",
printed ? ", " : "", info.curr_level,
- extent.e_pblk);
+ (unsigned long long) extent.e_pblk);
printed = 1;
continue;
}
info.curr_level, info.max_depth,
info.curr_entry, info.num_entries,
logical_width,
- extent.e_lblk,
+ (unsigned long long) extent.e_lblk,
logical_width,
- extent.e_lblk + (extent.e_len - 1),
+ (unsigned long long) extent.e_lblk + (extent.e_len - 1),
physical_width,
- extent.e_pblk,
+ (unsigned long long) extent.e_pblk,
physical_width,
- extent.e_pblk + (extent.e_len - 1),
+ (unsigned long long) extent.e_pblk + (extent.e_len - 1),
extent.e_len,
extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT ?
"Uninit" : "");
fprintf(f,
"%s(%lld%s):%lld",
printed ? ", " : "",
- extent.e_lblk,
+ (unsigned long long) extent.e_lblk,
extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT ?
"[u]" : "",
- extent.e_pblk);
+ (unsigned long long) extent.e_pblk);
else
fprintf(f,
"%s(%lld-%lld%s):%lld-%lld",
printed ? ", " : "",
- extent.e_lblk,
- extent.e_lblk + (extent.e_len - 1),
+ (unsigned long long) extent.e_lblk,
+ (unsigned long long) extent.e_lblk + (extent.e_len - 1),
extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT ?
"[u]" : "",
- extent.e_pblk,
- extent.e_pblk + (extent.e_len - 1));
+ (unsigned long long) extent.e_pblk,
+ (unsigned long long) extent.e_pblk + (extent.e_len - 1));
printed = 1;
}
if (printed)
char frag, fsize;
int os = current_fs->super->s_creator_os;
struct ext2_inode_large *large_inode;
- int is_large_inode = 0;
+ size_t inode_size;
- if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
- is_large_inode = 1;
large_inode = (struct ext2_inode_large *) inode;
+ if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
+ inode_size = ext2fs_inode_actual_size(large_inode);
+ else
+ inode_size = EXT2_GOOD_OLD_INODE_SIZE;
if (LINUX_S_ISDIR(inode->i_mode)) i_type = "directory";
else if (LINUX_S_ISREG(inode->i_mode)) i_type = "regular";
fprintf(out, "%sInode: %u Type: %s ", prefix, inode_num, i_type);
fprintf(out, "%sMode: 0%03o Flags: 0x%x\n",
prefix, inode->i_mode & 07777, inode->i_flags);
- if (is_large_inode && large_inode->i_extra_isize >= 24) {
+ if (ext2fs_inode_includes(inode_size, i_version_hi)) {
fprintf(out, "%sGeneration: %u Version: 0x%08x:%08x\n",
prefix, inode->i_generation, large_inode->i_version_hi,
inode->osd1.linux1.l_i_version);
}
fprintf(out, "%sUser: %5d Group: %5d",
prefix, inode_uid(*inode), inode_gid(*inode));
- if (is_large_inode && large_inode->i_extra_isize >= 32)
+ if (ext2fs_inode_includes(inode_size, i_projid))
fprintf(out, " Project: %5d", large_inode->i_projid);
fputs(" Size: ", out);
if (LINUX_S_ISREG(inode->i_mode) || LINUX_S_ISDIR(inode->i_mode))
- fprintf(out, "%llu\n", EXT2_I_SIZE(inode));
+ fprintf(out, "%llu\n", (unsigned long long) EXT2_I_SIZE(inode));
else
fprintf(out, "%u\n", inode->i_size);
if (os == EXT2_OS_HURD)
}
fprintf(out, "%sFragment: Address: %u Number: %u Size: %u\n",
prefix, inode->i_faddr, frag, fsize);
- if (is_large_inode && large_inode->i_extra_isize >= 24) {
+ if (ext2fs_inode_includes(inode_size, i_ctime_extra))
fprintf(out, "%s ctime: 0x%08x:%08x -- %s", prefix,
inode->i_ctime, large_inode->i_ctime_extra,
- inode_time_to_string(inode->i_ctime,
- large_inode->i_ctime_extra));
+ time_to_string(ext2fs_inode_xtime_get(inode, i_ctime)));
+ else
+ fprintf(out, "%sctime: 0x%08x -- %s", prefix, inode->i_ctime,
+ time_to_string((__s32) inode->i_ctime));
+ if (ext2fs_inode_includes(inode_size, i_atime_extra))
fprintf(out, "%s atime: 0x%08x:%08x -- %s", prefix,
inode->i_atime, large_inode->i_atime_extra,
- inode_time_to_string(inode->i_atime,
- large_inode->i_atime_extra));
+ time_to_string(ext2fs_inode_xtime_get(inode, i_atime)));
+ else
+ fprintf(out, "%satime: 0x%08x -- %s", prefix, inode->i_atime,
+ time_to_string((__s32) inode->i_atime));
+ if (ext2fs_inode_includes(inode_size, i_mtime_extra))
fprintf(out, "%s mtime: 0x%08x:%08x -- %s", prefix,
inode->i_mtime, large_inode->i_mtime_extra,
- inode_time_to_string(inode->i_mtime,
- large_inode->i_mtime_extra));
+ time_to_string(ext2fs_inode_xtime_get(inode, i_mtime)));
+ else
+ fprintf(out, "%smtime: 0x%08x -- %s", prefix, inode->i_mtime,
+ time_to_string((__s32) inode->i_mtime));
+ if (ext2fs_inode_includes(inode_size, i_crtime_extra))
fprintf(out, "%scrtime: 0x%08x:%08x -- %s", prefix,
large_inode->i_crtime, large_inode->i_crtime_extra,
- inode_time_to_string(large_inode->i_crtime,
- large_inode->i_crtime_extra));
- if (inode->i_dtime)
+ time_to_string(ext2fs_inode_xtime_get(large_inode,
+ i_crtime)));
+ if (inode->i_dtime) {
+ if (ext2fs_inode_includes(inode_size, i_ctime_extra)) {
+ time_t tm;
+
+ /* dtime doesn't have its own i_dtime_extra field, so
+ * approximate this with i_ctime_extra instead. */
+ tm = __decode_extra_sec(inode->i_dtime,
+ large_inode->i_ctime_extra);
fprintf(out, "%s dtime: 0x%08x:(%08x) -- %s", prefix,
- large_inode->i_dtime, large_inode->i_ctime_extra,
- inode_time_to_string(inode->i_dtime,
- large_inode->i_ctime_extra));
- } else {
- fprintf(out, "%sctime: 0x%08x -- %s", prefix, inode->i_ctime,
- time_to_string((__s32) inode->i_ctime));
- fprintf(out, "%satime: 0x%08x -- %s", prefix, inode->i_atime,
- time_to_string((__s32) inode->i_atime));
- fprintf(out, "%smtime: 0x%08x -- %s", prefix, inode->i_mtime,
- time_to_string((__s32) inode->i_mtime));
- if (inode->i_dtime)
+ inode->i_dtime, large_inode->i_ctime_extra,
+ time_to_string(tm));
+ } else {
fprintf(out, "%sdtime: 0x%08x -- %s", prefix,
inode->i_dtime,
time_to_string((__s32) inode->i_dtime));
+ }
}
if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
internal_dump_inode_extra(out, prefix, inode_num,
dump_inode_attributes(out, inode_num);
if (ext2fs_has_feature_metadata_csum(current_fs->super)) {
__u32 crc = inode->i_checksum_lo;
- if (is_large_inode &&
- large_inode->i_extra_isize >=
- (offsetof(struct ext2_inode_large,
- i_checksum_hi) -
- EXT2_GOOD_OLD_INODE_SIZE))
+ if (ext2fs_inode_includes(inode_size, i_checksum_hi))
crc |= ((__u32)large_inode->i_checksum_hi) << 16;
fprintf(out, "Inode checksum: 0x%08x\n", crc);
}
int ref_offset EXT2FS_ATTR((unused)),
void *private EXT2FS_ATTR((unused)))
{
- printf("%llu ", *blocknr);
+ printf("%llu ", (unsigned long long) *blocknr);
return 0;
}
while (count-- > 0) {
if (!ext2fs_test_block_bitmap2(current_fs->block_map,block))
com_err(argv[0], 0, "Warning: block %llu already clear",
- block);
+ (unsigned long long) block);
ext2fs_unmark_block_bitmap2(current_fs->block_map,block);
block++;
}
while (count-- > 0) {
if (ext2fs_test_block_bitmap2(current_fs->block_map,block))
com_err(argv[0], 0, "Warning: block %llu already set",
- block);
+ (unsigned long long) block);
ext2fs_mark_block_bitmap2(current_fs->block_map,block);
block++;
}
return;
while (count-- > 0) {
if (ext2fs_test_block_bitmap2(current_fs->block_map,block))
- printf("Block %llu marked in use\n", block);
+ printf("Block %llu marked in use\n",
+ (unsigned long long) block);
else
- printf("Block %llu not in use\n", block);
+ printf("Block %llu not in use\n",
+ (unsigned long long) block);
block++;
}
}
com_err("ext2fs_new_block", retval, 0);
return;
} else
- printf("%llu ", free_blk);
+ printf("%llu ", (unsigned long long) free_blk);
}
printf("\n");
}
&ret_flags, &pblk);
if (errcode) {
com_err(argv[0], errcode,
- "while mapping logical block %llu\n", blk);
+ "while mapping logical block %llu\n",
+ (unsigned long long) blk);
return;
}
- printf("%llu", pblk);
+ printf("%llu", (unsigned long long) pblk);
if (ret_flags & BMAP_RET_UNINIT)
fputs(" (uninit)", stdout);
fputc('\n', stdout);
retval = ext2fs_mmp_read(current_fs, mmp_block, current_fs->mmp_buf);
if (retval) {
com_err(argv[0], retval, "reading MMP block %llu.\n",
- mmp_block);
+ (unsigned long long) mmp_block);
return;
}
t = mmp_s->mmp_time;
- fprintf(stdout, "block_number: %llu\n", current_fs->super->s_mmp_block);
+ fprintf(stdout, "block_number: %llu\n",
+ (unsigned long long) current_fs->super->s_mmp_block);
fprintf(stdout, "update_interval: %d\n",
current_fs->super->s_mmp_update_interval);
fprintf(stdout, "check_interval: %d\n", mmp_s->mmp_check_interval);
fprintf(stdout, "sequence: %08x\n", mmp_s->mmp_seq);
- fprintf(stdout, "time: %lld -- %s", mmp_s->mmp_time, ctime(&t));
+ fprintf(stdout, "time: %llu -- %s",
+ (unsigned long long) mmp_s->mmp_time, ctime(&t));
fprintf(stdout, "node_name: %.*s\n",
EXT2_LEN_STR(mmp_s->mmp_nodename));
fprintf(stdout, "device_name: %.*s\n",
#endif
"[-c]] [device]";
int c;
- int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
+ int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES |
+ EXT2_FLAG_64BITS | EXT2_FLAG_THREADS;
char *request = 0;
int exit_status = 0;
char *cmd_file = 0;