+ print_features(current_fs->super, stdout);
+}
+
+void do_bmap(int argc, char *argv[])
+{
+ ext2_ino_t ino;
+ blk_t blk, pblk;
+ int err;
+ errcode_t errcode;
+
+ if (common_args_process(argc, argv, 3, 3, argv[0],
+ "<file> logical_blk", 0))
+ return;
+
+ ino = string_to_inode(argv[1]);
+ if (!ino)
+ return;
+ blk = parse_ulong(argv[2], argv[0], "logical_block", &err);
+
+ errcode = ext2fs_bmap(current_fs, ino, 0, 0, 0, blk, &pblk);
+ if (errcode) {
+ com_err("argv[0]", errcode,
+ "while mapping logical block %u\n", blk);
+ return;
+ }
+ printf("%u\n", pblk);
+}
+
+void do_imap(int argc, char *argv[])
+{
+ ext2_ino_t ino;
+ unsigned long group, block, block_nr, offset;
+
+ if (common_args_process(argc, argv, 2, 2, argv[0],
+ "<file>", 0))
+ return;
+ ino = string_to_inode(argv[1]);
+ if (!ino)
+ return;
+
+ group = (ino - 1) / EXT2_INODES_PER_GROUP(current_fs->super);
+ offset = ((ino - 1) % EXT2_INODES_PER_GROUP(current_fs->super)) *
+ EXT2_INODE_SIZE(current_fs->super);
+ block = offset >> EXT2_BLOCK_SIZE_BITS(current_fs->super);
+ if (!current_fs->group_desc[(unsigned)group].bg_inode_table) {
+ com_err(argv[0], 0, "Inode table for group %lu is missing\n",
+ group);
+ return;
+ }
+ block_nr = current_fs->group_desc[(unsigned)group].bg_inode_table +
+ block;
+ offset &= (EXT2_BLOCK_SIZE(current_fs->super) - 1);
+
+ printf("Inode %d is part of block group %lu\n"
+ "\tlocated at block %lu, offset 0x%04lx\n", ino, group,
+ block_nr, offset);
+
+}
+
+void do_set_current_time(int argc, char *argv[])
+{
+ time_t now;
+
+ if (common_args_process(argc, argv, 2, 2, argv[0],
+ "<time>", 0))
+ return;
+
+ now = string_to_time(argv[1]);
+ if (now == ((time_t) -1)) {
+ com_err(argv[0], 0, "Couldn't parse argument as a time: %s\n",
+ argv[1]);
+ return;
+
+ } else {
+ printf("Setting current time to %s\n", time_to_string(now));
+ current_fs->now = now;
+ }
+}
+
+static int find_supp_feature(__u32 *supp, int feature_type, char *name)
+{
+ int compat, bit, ret;
+ unsigned int feature_mask;
+
+ if (name) {
+ if (feature_type == E2P_FS_FEATURE)
+ ret = e2p_string2feature(name, &compat, &feature_mask);
+ else
+ ret = e2p_jrnl_string2feature(name, &compat,
+ &feature_mask);
+ if (ret)
+ return ret;
+
+ if (!(supp[compat] & feature_mask))
+ return 1;
+ } else {
+ for (compat = 0; compat < 3; compat++) {
+ for (bit = 0, feature_mask = 1; bit < 32;
+ bit++, feature_mask <<= 1) {
+ if (supp[compat] & feature_mask) {
+ if (feature_type == E2P_FS_FEATURE)
+ fprintf(stdout, " %s",
+ e2p_feature2string(compat,
+ feature_mask));
+ else
+ fprintf(stdout, " %s",
+ e2p_jrnl_feature2string(compat,
+ feature_mask));
+ }
+ }
+ }
+ fprintf(stdout, "\n");
+ }
+
+ return 0;
+}
+
+void do_supported_features(int argc, char *argv[])
+{
+ int i, j, ret;
+ __u32 supp[3] = { EXT2_LIB_FEATURE_COMPAT_SUPP,
+ EXT2_LIB_FEATURE_INCOMPAT_SUPP,
+ EXT2_LIB_FEATURE_RO_COMPAT_SUPP };
+ __u32 jrnl_supp[3] = { JFS_KNOWN_COMPAT_FEATURES,
+ JFS_KNOWN_INCOMPAT_FEATURES,
+ JFS_KNOWN_ROCOMPAT_FEATURES };
+
+ if (argc > 1) {
+ ret = find_supp_feature(supp, E2P_FS_FEATURE, argv[1]);
+ if (ret) {
+ ret = find_supp_feature(jrnl_supp, E2P_JOURNAL_FEATURE,
+ argv[1]);
+ }
+ if (ret)
+ com_err(argv[0], 0, "Unknown feature: %s\n", argv[1]);
+ else
+ fprintf(stdout, "Supported feature: %s\n", argv[1]);
+ } else {
+ fprintf(stdout, "Supported features:");
+ ret = find_supp_feature(supp, E2P_FS_FEATURE, NULL);
+ ret = find_supp_feature(jrnl_supp, E2P_JOURNAL_FEATURE, NULL);
+ }