From b044c2e02af46c54206f0f6e29896ab32681a7db Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 11 Jan 2001 15:26:39 +0000 Subject: [PATCH] Many files: debugfs.c, debugfs.h, dump.c, icheck.c, ls.c, lsdel.c, ncheck.c, setsuper.c, util.c: Change ino_t to ext2_ino_t. Fix a few minor gcc-wall complaints while we're at it. --- debugfs/ChangeLog | 6 +++ debugfs/debugfs.c | 112 ++++++++++++++++++++++++++--------------------------- debugfs/debugfs.h | 6 ++- debugfs/dump.c | 24 ++++++------ debugfs/icheck.c | 10 ++--- debugfs/ls.c | 14 +++---- debugfs/lsdel.c | 20 +++++----- debugfs/ncheck.c | 14 +++---- debugfs/setsuper.c | 6 +-- debugfs/util.c | 12 +++--- 10 files changed, 112 insertions(+), 112 deletions(-) diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index 2e4df37..9d1bbd7 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,9 @@ +2001-01-11 + + * debugfs.c, debugfs.h, dump.c, icheck.c, ls.c, lsdel.c, ncheck.c, + setsuper.c, util.c: Change ino_t to ext2_ino_t. Fix a few + minor gcc-wall complaints while we're at it. + 2001-01-01 * debugfs.c Replace use of struct ext2fs_sb with struct diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 846f607..003ccef 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -40,8 +40,8 @@ extern int optreset; /* defined by BSD, but not others */ extern ss_request_table debug_cmds; -ext2_filsys current_fs = NULL; -ino_t root, cwd; +ext2_filsys current_fs = NULL; +ext2_ino_t root, cwd; static void open_filesystem(char *device, int open_flags, blk_t superblock, blk_t blocksize, int catastrophic) @@ -253,8 +253,6 @@ void do_show_super_stats(int argc, char *argv[]) FILE *out; struct ext2_group_desc *gdp; int c, header_only = 0; - char buf[80]; - const char *none = "(none)"; const char *usage = "Usage: show_super [-h]"; optind = 0; @@ -386,7 +384,7 @@ static int list_blocks_proc(ext2_filsys fs, blk_t *blocknr, int blockcnt, } -static void dump_blocks(FILE *f, ino_t inode) +static void dump_blocks(FILE *f, ext2_ino_t inode) { struct list_blocks_struct lb; @@ -404,7 +402,7 @@ static void dump_blocks(FILE *f, ino_t inode) } -static void dump_inode(ino_t inode_num, struct ext2_inode inode) +static void dump_inode(ext2_ino_t inode_num, struct ext2_inode inode) { const char *i_type; FILE *out; @@ -420,7 +418,7 @@ static void dump_inode(ino_t inode_num, struct ext2_inode inode) else if (LINUX_S_ISFIFO(inode.i_mode)) i_type = "FIFO"; else if (LINUX_S_ISSOCK(inode.i_mode)) i_type = "socket"; else i_type = "bad type"; - fprintf(out, "Inode: %ld Type: %s ", inode_num, i_type); + fprintf(out, "Inode: %u Type: %s ", inode_num, i_type); fprintf(out, "Mode: %04o Flags: 0x%x Generation: %u\n", inode.i_mode & 0777, inode.i_flags, inode.i_generation); fprintf(out, "User: %5d Group: %5d Size: ", @@ -481,9 +479,9 @@ static void dump_inode(ino_t inode_num, struct ext2_inode inode) void do_stat(int argc, char *argv[]) { - ino_t inode; + ext2_ino_t inode; struct ext2_inode inode_buf; - int retval; + int retval; if (argc != 2) { com_err(argv[0], 0, "Usage: stat "); @@ -508,7 +506,7 @@ void do_stat(int argc, char *argv[]) void do_chroot(int argc, char *argv[]) { - ino_t inode; + ext2_ino_t inode; int retval; if (argc != 2) { @@ -531,7 +529,7 @@ void do_chroot(int argc, char *argv[]) void do_clri(int argc, char *argv[]) { - ino_t inode; + ext2_ino_t inode; int retval; struct ext2_inode inode_buf; @@ -564,7 +562,7 @@ void do_clri(int argc, char *argv[]) void do_freei(int argc, char *argv[]) { - ino_t inode; + ext2_ino_t inode; if (argc != 2) { com_err(argv[0], 0, "Usage: freei "); @@ -586,7 +584,7 @@ void do_freei(int argc, char *argv[]) void do_seti(int argc, char *argv[]) { - ino_t inode; + ext2_ino_t inode; if (argc != 2) { com_err(argv[0], 0, "Usage: seti "); @@ -608,7 +606,7 @@ void do_seti(int argc, char *argv[]) void do_testi(int argc, char *argv[]) { - ino_t inode; + ext2_ino_t inode; if (argc != 2) { com_err(argv[0], 0, "Usage: testi "); @@ -623,9 +621,9 @@ void do_testi(int argc, char *argv[]) return; if (ext2fs_test_inode_bitmap(current_fs->inode_map,inode)) - printf("Inode %ld is marked in use\n", inode); + printf("Inode %u is marked in use\n", inode); else - printf("Inode %ld is not in use\n", inode); + printf("Inode %u is not in use\n", inode); } @@ -767,15 +765,15 @@ static void modify_u32(char *com, const char *prompt, void do_modify_inode(int argc, char *argv[]) { struct ext2_inode inode; - ino_t inode_num; - int i; + ext2_ino_t inode_num; + int i; errcode_t retval; - unsigned char *frag, *fsize; - char buf[80]; - int os = current_fs->super->s_creator_os; - const char *hex_format = "0x%x"; - const char *octal_format = "0%o"; - const char *decimal_format = "%d"; + unsigned char *frag, *fsize; + char buf[80]; + int os = current_fs->super->s_creator_os; + const char *hex_format = "0x%x"; + const char *octal_format = "0%o"; + const char *decimal_format = "%d"; if (argc != 2) { com_err(argv[0], 0, "Usage: modify_inode "); @@ -864,8 +862,8 @@ void do_modify_inode(int argc, char *argv[]) void do_change_working_dir(int argc, char *argv[]) { - ino_t inode; - int retval; + ext2_ino_t inode; + int retval; if (argc != 2) { com_err(argv[0], 0, "Usage: cd "); @@ -904,24 +902,24 @@ void do_print_working_directory(int argc, char *argv[]) com_err(argv[0], retval, "while trying to get pathname of cwd"); } - printf("[pwd] INODE: %6ld PATH: %s\n", cwd, pathname); + printf("[pwd] INODE: %6u PATH: %s\n", cwd, pathname); free(pathname); retval = ext2fs_get_pathname(current_fs, root, 0, &pathname); if (retval) { com_err(argv[0], retval, "while trying to get pathname of root"); } - printf("[root] INODE: %6ld PATH: %s\n", root, pathname); + printf("[root] INODE: %6u PATH: %s\n", root, pathname); free(pathname); return; } static void make_link(char *sourcename, char *destname) { - ino_t inode; - int retval; - ino_t dir; - char *dest, *cp, *basename; + ext2_ino_t inode; + int retval; + ext2_ino_t dir; + char *dest, *cp, *basename; /* * Get the source inode @@ -979,9 +977,9 @@ void do_link(int argc, char *argv[]) static void unlink_file_by_name(char *filename) { - int retval; - ino_t dir; - char *basename; + int retval; + ext2_ino_t dir; + char *basename; basename = strrchr(filename, '/'); if (basename) { @@ -1044,10 +1042,10 @@ void do_find_free_block(int argc, char *argv[]) void do_find_free_inode(int argc, char *argv[]) { - ino_t free_inode, dir; - int mode; - int retval; - char *tmp; + ext2_ino_t free_inode, dir; + int mode; + int retval; + char *tmp; if (argc > 3 || (argc>1 && *argv[1] == '?')) { com_err(argv[0], 0, "Usage: find_free_inode [dir] [mode]"); @@ -1078,10 +1076,10 @@ void do_find_free_inode(int argc, char *argv[]) if (retval) com_err("ext2fs_new_inode", retval, ""); else - printf("Free inode found: %ld\n", free_inode); + printf("Free inode found: %u\n", free_inode); } -static errcode_t copy_file(int fd, ino_t newfile) +static errcode_t copy_file(int fd, ext2_ino_t newfile) { ext2_file_t e2_file; errcode_t retval; @@ -1125,12 +1123,12 @@ fail: void do_write(int argc, char *argv[]) { - int fd; - struct stat statbuf; - ino_t newfile; - errcode_t retval; + int fd; + struct stat statbuf; + ext2_ino_t newfile; + errcode_t retval; struct ext2_inode inode; - dgrp_t group; + dgrp_t group; if (check_fs_open(argv[0])) return; @@ -1161,7 +1159,7 @@ void do_write(int argc, char *argv[]) current_fs->group_desc[group].bg_free_inodes_count--; current_fs->super->s_free_inodes_count--; ext2fs_mark_super_dirty(current_fs); - printf("Allocated inode: %ld\n", newfile); + printf("Allocated inode: %u\n", newfile); retval = ext2fs_link(current_fs, cwd, argv[2], newfile, 0); if (retval) { com_err(argv[2], retval, ""); @@ -1195,9 +1193,9 @@ void do_write(int argc, char *argv[]) void do_mknod(int argc, char *argv[]) { - unsigned long mode, major, minor, nr; - ino_t newfile; - errcode_t retval; + unsigned long mode, major, minor, nr; + ext2_ino_t newfile; + errcode_t retval; struct ext2_inode inode; if (check_fs_open(argv[0])) @@ -1240,7 +1238,7 @@ void do_mknod(int argc, char *argv[]) com_err(argv[0], retval, ""); return; } - printf("Allocated inode: %ld\n", newfile); + printf("Allocated inode: %u\n", newfile); retval = ext2fs_link(current_fs, cwd, argv[1], newfile, 0); if (retval) { if (retval == EXT2_ET_DIR_NO_SPACE) { @@ -1274,7 +1272,7 @@ void do_mknod(int argc, char *argv[]) void do_mkdir(int argc, char *argv[]) { char *cp; - ino_t parent; + ext2_ino_t parent; char *name; errcode_t retval; @@ -1326,7 +1324,7 @@ static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr, return 0; } -static void kill_file_by_inode(ino_t inode) +static void kill_file_by_inode(ext2_ino_t inode) { struct ext2_inode inode_buf; @@ -1334,7 +1332,7 @@ static void kill_file_by_inode(ino_t inode) inode_buf.i_dtime = time(NULL); ext2fs_write_inode(current_fs, inode, &inode_buf); - printf("Kill file by inode %ld\n", inode); + printf("Kill file by inode %u\n", inode); ext2fs_block_iterate(current_fs, inode, 0, NULL, release_blocks_proc, NULL); printf("\n"); @@ -1347,7 +1345,7 @@ static void kill_file_by_inode(ino_t inode) void do_kill_file(int argc, char *argv[]) { - ino_t inode_num; + ext2_ino_t inode_num; if (argc != 2) { com_err(argv[0], 0, "Usage: kill_file "); @@ -1370,7 +1368,7 @@ void do_kill_file(int argc, char *argv[]) void do_rm(int argc, char *argv[]) { int retval; - ino_t inode_num; + ext2_ino_t inode_num; struct ext2_inode inode; if (argc != 2) { @@ -1425,7 +1423,7 @@ void do_show_debugfs_params(int argc, char *argv[]) void do_expand_dir(int argc, char *argv[]) { - ino_t inode; + ext2_ino_t inode; int retval; if (argc != 2) { diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h index f5d3d53..d1b8e25 100644 --- a/debugfs/debugfs.h +++ b/debugfs/debugfs.h @@ -13,7 +13,7 @@ #endif extern ext2_filsys current_fs; -extern ino_t root, cwd; +extern ext2_ino_t root, cwd; extern FILE *open_pager(void); extern void close_pager(FILE *stream); @@ -21,7 +21,7 @@ extern int check_fs_open(char *name); extern int check_fs_not_open(char *name); extern int check_fs_read_write(char *name); extern int check_fs_bitmaps(char *name); -extern ino_t string_to_inode(char *str); +extern ext2_ino_t string_to_inode(char *str); extern char *time_to_string(__u32); /* ss command functions */ @@ -29,6 +29,7 @@ extern char *time_to_string(__u32); /* dump.c */ extern void do_dump(int argc, char **argv); extern void do_cat(int argc, char **argv); +extern void do_rdump(int argc, char **argv); /* lsdel.c */ extern void do_lsdel(int argc, char **argv); @@ -43,6 +44,7 @@ extern void do_ncheck(int argc, char **argv); extern void do_dirty_filesys(int argc, char **argv); extern void do_open_filesys(int argc, char **argv); extern void do_close_filesys(int argc, char **argv); +extern void do_lcd(int argc, char **argv); extern void do_init_filesys(int argc, char **argv); extern void do_show_super_stats(int argc, char **argv); extern void do_kill_file(int argc, char **argv); diff --git a/debugfs/dump.c b/debugfs/dump.c index e946437..e290c14 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -94,12 +94,11 @@ static void fix_perms(const char *cmd, const struct ext2_inode *inode, com_err(cmd, errno, "while setting times of %s", name); } -static void dump_file(char *cmdname, ino_t ino, int fd, int preserve, - char *outname) +static void dump_file(const char *cmdname, ext2_ino_t ino, int fd, + int preserve, char *outname) { errcode_t retval; struct ext2_inode inode; - struct utimbuf ut; char buf[8192]; ext2_file_t e2_file; int nbytes; @@ -143,12 +142,12 @@ static void dump_file(char *cmdname, ino_t ino, int fd, int preserve, void do_dump(int argc, char **argv) { - ino_t inode; - int fd; - int c; - int preserve = 0; + ext2_ino_t inode; + int fd; + int c; + int preserve = 0; const char *dump_usage = "Usage: dump_inode [-p] "; - char *in_fn, *out_fn; + char *in_fn, *out_fn; optind = 0; #ifdef HAVE_OPTRESET @@ -191,7 +190,7 @@ void do_dump(int argc, char **argv) return; } -static void rdump_symlink(ino_t ino, struct ext2_inode *inode, +static void rdump_symlink(ext2_ino_t ino, struct ext2_inode *inode, const char *fullname) { ext2_file_t e2_file; @@ -245,11 +244,10 @@ errout: static int rdump_dirent(struct ext2_dir_entry *, int, int, char *, void *); -static void rdump_inode(ino_t ino, struct ext2_inode *inode, +static void rdump_inode(ext2_ino_t ino, struct ext2_inode *inode, const char *name, const char *dumproot) { char *fullname; - struct utimbuf ut; /* There are more efficient ways to do this, but this method * requires only minimal debugging. */ @@ -322,7 +320,7 @@ static int rdump_dirent(struct ext2_dir_entry *dirent, int offset, void do_rdump(int argc, char **argv) { - ino_t ino; + ext2_ino_t ino; struct ext2_inode inode; errcode_t retval; struct stat st; @@ -369,7 +367,7 @@ void do_rdump(int argc, char **argv) void do_cat(int argc, char **argv) { - ino_t inode; + ext2_ino_t inode; if (argc != 2) { com_err(argv[0], 0, "Usage: cat "); diff --git a/debugfs/icheck.c b/debugfs/icheck.c index 136c52e..33daa3b 100644 --- a/debugfs/icheck.c +++ b/debugfs/icheck.c @@ -19,15 +19,15 @@ #include "debugfs.h" struct block_info { - blk_t blk; - ino_t ino; + blk_t blk; + ext2_ino_t ino; }; struct block_walk_struct { struct block_info *barray; int blocks_left; int num_blocks; - ino_t inode; + ext2_ino_t inode; }; static int icheck_proc(ext2_filsys fs, @@ -56,7 +56,7 @@ void do_icheck(int argc, char **argv) struct block_info *binfo; int i; ext2_inode_scan scan = 0; - ino_t ino; + ext2_ino_t ino; struct ext2_inode inode; errcode_t retval; char *tmp; @@ -149,7 +149,7 @@ void do_icheck(int argc, char **argv) printf("%u\t\n", binfo->blk); continue; } - printf("%u\t%ld\n", binfo->blk, binfo->ino); + printf("%u\t%u\n", binfo->blk, binfo->ino); } error_out: diff --git a/debugfs/ls.c b/debugfs/ls.c index 4c96db4..e24bdb3 100644 --- a/debugfs/ls.c +++ b/debugfs/ls.c @@ -33,7 +33,7 @@ struct list_dir_struct { static const char *monstr[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; -static void ls_l_file(struct list_dir_struct *ls, char *name, ino_t ino) +static void ls_l_file(struct list_dir_struct *ls, char *name, ext2_ino_t ino) { struct ext2_inode inode; errcode_t retval; @@ -51,7 +51,7 @@ static void ls_l_file(struct list_dir_struct *ls, char *name, ino_t ino) sprintf(datestr, "%2d-%s-%4d %02d:%02d", tm_p->tm_mday, monstr[tm_p->tm_mon], 1900 + tm_p->tm_year, tm_p->tm_hour, tm_p->tm_min); - fprintf(ls->f, "%6ld %6o %5d %5d ", ino, inode.i_mode, + fprintf(ls->f, "%6u %6o %5d %5d ", ino, inode.i_mode, inode.i_uid, inode.i_gid); if (LINUX_S_ISDIR(inode.i_mode)) fprintf(ls->f, "%5d", inode.i_size); @@ -62,12 +62,12 @@ static void ls_l_file(struct list_dir_struct *ls, char *name, ino_t ino) } static void ls_file(struct list_dir_struct *ls, char *name, - ino_t ino, int rec_len) + ext2_ino_t ino, int rec_len) { char tmp[EXT2_NAME_LEN + 16]; int thislen; - sprintf(tmp, "%ld (%d) %s ", ino, rec_len, name); + sprintf(tmp, "%u (%d) %s ", ino, rec_len, name); thislen = strlen(tmp); if (ls->col + thislen > 80) { @@ -105,10 +105,10 @@ static int list_dir_proc(struct ext2_dir_entry *dirent, void do_list_dir(int argc, char *argv[]) { - ino_t inode; - int retval; + ext2_ino_t inode; + int retval; struct list_dir_struct ls; - int argptr = 1; + int argptr = 1; ls.options = 0; if (check_fs_open(argv[0])) diff --git a/debugfs/lsdel.c b/debugfs/lsdel.c index 3eb9037..0165676 100644 --- a/debugfs/lsdel.c +++ b/debugfs/lsdel.c @@ -20,17 +20,17 @@ #include "debugfs.h" struct deleted_info { - ino_t ino; - unsigned short mode; - unsigned short uid; - __u64 size; - time_t dtime; - int num_blocks; - int free_blocks; + ext2_ino_t ino; + unsigned short mode; + unsigned short uid; + __u64 size; + time_t dtime; + int num_blocks; + int free_blocks; }; struct lsdel_struct { - ino_t inode; + ext2_ino_t inode; int num_blocks; int free_blocks; int bad_blocks; @@ -73,7 +73,7 @@ void do_lsdel(int argc, char **argv) struct deleted_info *delarray; int num_delarray, max_delarray; ext2_inode_scan scan = 0; - ino_t ino; + ext2_ino_t ino; struct ext2_inode inode; errcode_t retval; char *block_buf; @@ -177,7 +177,7 @@ void do_lsdel(int argc, char **argv) deleted_info_compare); for (i = 0; i < num_delarray; i++) { - printf("%6lu %6d %6o %6llu %4d/%4d %s", delarray[i].ino, + printf("%6u %6d %6o %6llu %4d/%4d %s", delarray[i].ino, delarray[i].uid, delarray[i].mode, delarray[i].size, delarray[i].free_blocks, delarray[i].num_blocks, time_to_string(delarray[i].dtime)); diff --git a/debugfs/ncheck.c b/debugfs/ncheck.c index 83fe9b5..2c2845c 100644 --- a/debugfs/ncheck.c +++ b/debugfs/ncheck.c @@ -19,9 +19,9 @@ #include "debugfs.h" struct inode_info { - ino_t ino; - ino_t parent; - char *pathname; + ext2_ino_t ino; + ext2_ino_t parent; + char *pathname; }; struct inode_walk_struct { @@ -29,7 +29,7 @@ struct inode_walk_struct { int inodes_left; int num_inodes; int position; - ino_t parent; + ext2_ino_t parent; }; static int ncheck_proc(struct ext2_dir_entry *dirent, @@ -62,7 +62,7 @@ void do_ncheck(int argc, char **argv) struct inode_info *iinfo; int i; ext2_inode_scan scan = 0; - ino_t ino; + ext2_ino_t ino; struct ext2_inode inode; errcode_t retval; char *tmp; @@ -159,10 +159,10 @@ void do_ncheck(int argc, char **argv) printf("Inode\tPathname\n"); for (i=0, iinfo = iw.iarray; i < iw.num_inodes; i++, iinfo++) { if (iinfo->parent == 0) { - printf("%ld\t\n", iinfo->ino); + printf("%u\t\n", iinfo->ino); continue; } - printf("%ld\t%s\n", iinfo->ino, iinfo->pathname ? + printf("%u\t%s\n", iinfo->ino, iinfo->pathname ? iinfo->pathname : ""); if (iinfo->pathname) free(iinfo->pathname); diff --git a/debugfs/setsuper.c b/debugfs/setsuper.c index ae20e08..d7e8691 100644 --- a/debugfs/setsuper.c +++ b/debugfs/setsuper.c @@ -21,7 +21,7 @@ static struct ext2_super_block set_sb; struct super_set_info { - char *name; + const char *name; void *ptr; int size; errcode_t (*func)(struct super_set_info *info, char *arg); @@ -170,10 +170,6 @@ static errcode_t parse_string(struct super_set_info *info, char *arg) void do_set_super(int argc, char *argv[]) { - char *cp; - ino_t parent; - char *name; - errcode_t retval; static struct super_set_info *ss; if (check_fs_open(argv[0])) diff --git a/debugfs/util.c b/debugfs/util.c index 70c5d3f..fc328be 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -19,7 +19,7 @@ FILE *open_pager(void) { FILE *outfile; - char *pager = getenv("PAGER"); + const char *pager = getenv("PAGER"); signal(SIGPIPE, SIG_IGN); if (!pager) @@ -41,12 +41,12 @@ void close_pager(FILE *stream) * This routine is used whenever a command needs to turn a string into * an inode. */ -ino_t string_to_inode(char *str) +ext2_ino_t string_to_inode(char *str) { - ino_t ino; - int len = strlen(str); - char *end; - int retval; + ext2_ino_t ino; + int len = strlen(str); + char *end; + int retval; /* * If the string is of the form , then treat it as an -- 1.8.3.1