@MCONFIG@
-PROGS= debugfs
+PROGS= debugfs rdebugfs
MANPAGES= debugfs.8
MK_CMDS= _SS_DIR_OVERRIDE=../lib/ss ../lib/ss/mk_cmds
DEBUG_OBJS= debug_cmds.o debugfs.o util.o ncheck.o icheck.o ls.o \
lsdel.o dump.o set_fields.o logdump.o htree.o unused.o
+RO_DEBUG_OBJS= ro_debug_cmds.o ro_debugfs.o util.o ncheck.o icheck.o ls.o \
+ lsdel.o logdump.o htree.o
+
SRCS= debug_cmds.c $(srcdir)/debugfs.c $(srcdir)/util.c $(srcdir)/ls.c \
$(srcdir)/ncheck.c $(srcdir)/icheck.c $(srcdir)/lsdel.c \
$(srcdir)/dump.c $(srcdir)/set_fields.c ${srcdir}/logdump.c \
$(E) " LD $@"
$(Q) $(CC) $(ALL_LDFLAGS) -o debugfs $(DEBUG_OBJS) $(LIBS)
+rdebugfs: $(RO_DEBUG_OBJS) $(DEPLIBS)
+ $(E) " LD $@"
+ $(Q) $(CC) $(ALL_LDFLAGS) -o rdebugfs $(RO_DEBUG_OBJS) $(LIBS)
+
debug_cmds.c debug_cmds.h: debug_cmds.ct
$(E) " MK_CMDS $@"
$(Q) $(MK_CMDS) $(srcdir)/debug_cmds.ct
+ro_debug_cmds.c ro_debug_cmds.h: ro_debug_cmds.ct
+ $(E) " MK_CMDS $@"
+ $(Q) $(MK_CMDS) $(srcdir)/ro_debug_cmds.ct
+
+ro_debugfs.o: debugfs.c
+ $(E) " CC $@"
+ $(Q) $(CC) -c $(ALL_CFLAGS) $< -DREAD_ONLY -o $@
+
debugfs.8: $(DEP_SUBSTITUTE) $(srcdir)/debugfs.8.in
$(E) " SUBST $@"
$(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/debugfs.8.in debugfs.8
done
clean:
- $(RM) -f debugfs debugfs.8 \#* *.s *.o *.a *~ debug_cmds.c core
+ $(RM) -f $(PROGS) debugfs.8 \#* *.s *.o *.a *~ debug_cmds.c \
+ ro_debug_cmds.c core
mostlyclean: clean
distclean: clean
open_flags |= EXT2_FLAG_IMAGE_FILE;
break;
case 'w':
+#ifdef READ_ONLY
+ goto print_usage;
+#else
open_flags |= EXT2_FLAG_RW;
+#endif /* READ_ONLY */
break;
case 'f':
open_flags |= EXT2_FLAG_FORCE;
return;
print_usage:
- fprintf(stderr, "%s: Usage: open [-s superblock] [-b blocksize] "
- "[-c] [-w] <device>\n", argv[0]);
+ fprintf(stderr, "%s: Usage: open [-s superblock] [-b blocksize] [-c] "
+#ifndef READ_ONLY
+ "[-w] "
+#endif
+ "<device>\n", argv[0]);
}
void do_lcd(int argc, char **argv)
close_filesystem();
}
+#ifndef READ_ONLY
void do_init_filesys(int argc, char **argv)
{
struct ext2_super_block param;
root = cwd = EXT2_ROOT_INO;
return;
}
+#endif /* READ_ONLY */
static void print_features(struct ext2_super_block * s, FILE *f)
{
fprintf(stderr, "%s: Usage: show_super [-h]\n", argv[0]);
}
+#ifndef READ_ONLY
void do_dirty_filesys(int argc EXT2FS_ATTR((unused)),
char **argv EXT2FS_ATTR((unused)))
{
current_fs->super->s_state &= ~EXT2_VALID_FS;
ext2fs_mark_super_dirty(current_fs);
}
+#endif /* READ_ONLY */
struct list_blocks_struct {
FILE *f;
root = inode;
}
+#ifndef READ_ONLY
void do_clri(int argc, char *argv[])
{
ext2_ino_t inode;
ext2fs_mark_inode_bitmap2(current_fs->inode_map,inode);
ext2fs_mark_ib_dirty(current_fs);
}
+#endif /* READ_ONLY */
void do_testi(int argc, char *argv[])
{
printf("Inode %u is not in use\n", inode);
}
+#ifndef READ_ONLY
void do_freeb(int argc, char *argv[])
{
blk64_t block;
}
ext2fs_mark_bb_dirty(current_fs);
}
+#endif /* READ_ONLY */
void do_testb(int argc, char *argv[])
{
}
}
+#ifndef READ_ONLY
static void modify_u8(char *com, const char *prompt,
const char *format, __u8 *val)
{
if (debugfs_write_inode(inode_num, &inode, argv[1]))
return;
}
+#endif /* READ_ONLY */
void do_change_working_dir(int argc, char *argv[])
{
return 0;
}
+#ifndef READ_ONLY
static void make_link(char *sourcename, char *destname)
{
ext2_ino_t ino;
unlink_file_by_name(argv[1]);
}
+#endif /* READ_ONLY */
void do_find_free_block(int argc, char *argv[])
{
printf("Free inode found: %u\n", free_inode);
}
+#ifndef READ_ONLY
static errcode_t copy_file(int fd, ext2_ino_t newfile)
{
ext2_file_t e2_file;
return;
}
}
+#endif /* READ_ONLY */
void do_show_debugfs_params(int argc EXT2FS_ATTR((unused)),
char *argv[] EXT2FS_ATTR((unused)))
current_fs ? current_fs->device_name : "--none--");
}
+#ifndef READ_ONLY
void do_expand_dir(int argc, char *argv[])
{
ext2_ino_t inode;
}
print_features(current_fs->super, stdout);
}
+#endif /* READ_ONLY */
void do_bmap(int argc, char *argv[])
{
}
+#ifndef READ_ONLY
void do_set_current_time(int argc, char *argv[])
{
time_t now;
current_fs->now = now;
}
}
+#endif /* READ_ONLY */
static int find_supp_feature(__u32 *supp, int feature_type, char *name)
{
}
}
+#ifndef READ_ONLY
void do_punch(int argc, char *argv[])
{
ext2_ino_t ino;
return;
}
}
+#endif /* READ_ONLY */
void do_dump_mmp(int argc, char *argv[])
{
{
int retval;
int sci_idx;
- const char *usage = "Usage: %s [-b blocksize] [-s superblock] [-f cmd_file] [-R request] [-V] [[-w] [-c] device]";
+ const char *usage =
+ "Usage: %s [-b blocksize] [-s superblock] [-f cmd_file] "
+ "[-R request] [-V] ["
+#ifndef READ_ONLY
+ "[-w] "
+#endif
+ "[-c] device]";
int c;
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
char *request = 0;
blk64_t blocksize = 0;
int catastrophic = 0;
char *data_filename = 0;
+#ifdef READ_ONLY
+ const char *opt_string = "icR:f:b:s:Vd:D";
+#else
+ const char *opt_string = "iwcR:f:b:s:Vd:D";
+#endif
if (debug_prog_name == 0)
+#ifdef READ_ONLY
+ debug_prog_name = "rdebugfs";
+#else
debug_prog_name = "debugfs";
-
+#endif
add_error_table(&et_ext2_error_table);
fprintf (stderr, "%s %s (%s)\n", debug_prog_name,
E2FSPROGS_VERSION, E2FSPROGS_DATE);
- while ((c = getopt (argc, argv, "iwcR:f:b:s:Vd:D")) != EOF) {
+ while ((c = getopt (argc, argv, opt_string)) != EOF) {
switch (c) {
case 'R':
request = optarg;
case 'i':
open_flags |= EXT2_FLAG_IMAGE_FILE;
break;
+#ifndef READ_ONLY
case 'w':
open_flags |= EXT2_FLAG_RW;
break;
+#endif
case 'D':
open_flags |= EXT2_FLAG_DIRECT_IO;
break;
--- /dev/null
+#
+# Restricted set of debugfs commands
+#
+# Copyright (C) 1993 Theodore Ts'o. This file may be redistributed
+# under the terms of the GNU Public License.
+#
+command_table debug_cmds;
+
+request do_show_debugfs_params, "Show debugfs parameters",
+ show_debugfs_params, params;
+
+request do_open_filesys, "Open a filesystem",
+ open_filesys, open;
+
+request do_close_filesys, "Close the filesystem",
+ close_filesys, close;
+
+request do_show_super_stats, "Show superblock statistics",
+ show_super_stats, stats;
+
+request do_ncheck, "Do inode->name translation",
+ ncheck;
+
+request do_icheck, "Do block->inode translation",
+ icheck;
+
+request do_chroot, "Change root directory",
+ change_root_directory, chroot;
+
+request do_change_working_dir, "Change working directory",
+ change_working_directory, cd;
+
+request do_list_dir, "List directory",
+ list_directory, ls;
+
+request do_stat, "Show inode information ",
+ show_inode_info, stat;
+
+request do_dump_extents, "Dump extents information ",
+ dump_extents, extents, ex;
+
+request do_blocks, "Dump blocks used by an inode ",
+ blocks;
+
+request do_testi, "Test an inode's in-use flag",
+ testi;
+
+request do_find_free_block, "Find free block(s)",
+ find_free_block, ffb;
+
+request do_find_free_inode, "Find free inode(s)",
+ find_free_inode, ffi;
+
+request do_print_working_directory, "Print current working directory",
+ print_working_directory, pwd;
+
+request do_lsdel, "List deleted inodes",
+ list_deleted_inodes, lsdel;
+
+request do_logdump, "Dump the contents of the journal",
+ logdump;
+
+request do_htree_dump, "Dump a hash-indexed directory",
+ htree_dump, htree;
+
+request do_dx_hash, "Calculate the directory hash of a filename",
+ dx_hash, hash;
+
+request do_dirsearch, "Search a directory for a particular filename",
+ dirsearch;
+
+request do_bmap, "Calculate the logical->physical block mapping for an inode",
+ bmap;
+
+request do_imap, "Calculate the location of an inode",
+ imap;
+
+request do_supported_features, "Print features supported by this version of e2fsprogs",
+ supported_features;
+
+request do_dump_mmp, "Dump MMP information",
+ dump_mmp;
+
+end;
+