diff options
author | Theodore Ts'o <tytso@mit.edu> | 2001-12-16 23:23:37 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2001-12-16 23:23:37 -0500 |
commit | 4ea7bd04390935e1f8b473c8b857e518df2e226b (patch) | |
tree | 522193270e7d1c89b7bacc8a7df6486dcccaf82d /misc | |
parent | 8cf93332d180e6929d73cd8c855c3a83d6a6648c (diff) | |
download | e2fsprogs-4ea7bd04390935e1f8b473c8b857e518df2e226b.tar.gz |
Fix various gcc -Wall nits. Fixed a bug in mke2fs where a bogus
error message could be printed on an malloc() failure, and e2image
was optimized to avoid needless system calls by using the stashed
inode functions.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/ChangeLog | 9 | ||||
-rw-r--r-- | misc/dumpe2fs.c | 9 | ||||
-rw-r--r-- | misc/e2image.c | 29 | ||||
-rw-r--r-- | misc/fsck.c | 2 | ||||
-rw-r--r-- | misc/fstype.c | 10 | ||||
-rw-r--r-- | misc/get_device_by_label.c | 2 | ||||
-rw-r--r-- | misc/mke2fs.c | 11 | ||||
-rw-r--r-- | misc/tune2fs.c | 18 | ||||
-rw-r--r-- | misc/util.c | 7 | ||||
-rw-r--r-- | misc/util.h | 2 |
10 files changed, 67 insertions, 32 deletions
diff --git a/misc/ChangeLog b/misc/ChangeLog index 2ac28654..385fabda 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,5 +1,14 @@ 2001-12-16 Theodore Tso <tytso@valinux.com> + * dumpe2fs.c (list_desc), fsck.c (fs_match), + get_device_by_label.c (get_label_uuid), + mke2fs.c (set_fs_defaults, zap_sector, PRS), + tune2fs.c (remove_journal_device, update_feature_set), + util.c (figure_journal_size), util.h: Fix gcc -Wall nits. + + * e2image.c (write_raw_image_file): Fix gcc -Wall nits, and use + the stashed inode functions to optimize away system calls. + * Makefile.in, jfs_user.h: linux/jfs.h has been renamed to linux/jbd.h diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index 87e563f8..b86bf4ec 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -37,6 +37,7 @@ extern int optind; #include "ext2fs/ext2fs.h" #include "e2p/e2p.h" #include "jfs_user.h" +#include <uuid/uuid.h> #include "../version.h" #include "nls-enable.h" @@ -45,7 +46,7 @@ extern int optind; const char * program_name = "dumpe2fs"; char * device_name = NULL; -char *num_format = "%lu"; +const char *num_format = "%lu"; static void usage(void) { @@ -125,12 +126,12 @@ static void list_desc (ext2_filsys fs) printf(num_format, fs->group_desc[i].bg_block_bitmap); diff = fs->group_desc[i].bg_block_bitmap - group_blk; if (diff >= 0) - printf(" (+%d)", diff); + printf(" (+%ld)", diff); fputs(_(", Inode bitmap at "), stdout); printf(num_format, fs->group_desc[i].bg_inode_bitmap); diff = fs->group_desc[i].bg_inode_bitmap - group_blk; if (diff >= 0) - printf(" (+%d)", diff); + printf(" (+%ld)", diff); fputs(_("\n Inode table at "), stdout); printf(num_format, fs->group_desc[i].bg_inode_table); fputc('-', stdout); @@ -138,7 +139,7 @@ static void list_desc (ext2_filsys fs) inode_blocks_per_group - 1); diff = fs->group_desc[i].bg_inode_table - group_blk; if (diff > 0) - printf(" (+%d)", diff); + printf(" (+%ld)", diff); printf (_("\n %d free blocks, %d free inodes, " "%d directories\n Free blocks: "), fs->group_desc[i].bg_free_blocks_count, diff --git a/misc/e2image.c b/misc/e2image.c index ccabb197..d8d43f9e 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -173,6 +173,16 @@ static errcode_t meta_get_blocks(ext2_filsys fs, ext2_ino_t ino, return 0; } +static errcode_t meta_check_directory(ext2_filsys fs, ext2_ino_t ino) +{ + if ((ino != stashed_ino) || !stashed_inode) + return EXT2_ET_CALLBACK_NOTHANDLED; + + if (!LINUX_S_ISDIR(stashed_inode->i_mode)) + return EXT2_ET_NO_DIRECTORY; + return 0; +} + static errcode_t meta_read_inode(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode) { @@ -182,6 +192,20 @@ static errcode_t meta_read_inode(ext2_filsys fs, ext2_ino_t ino, return 0; } +static void use_inode_shortcuts(ext2_filsys fs, int bool) +{ + if (bool) { + fs->get_blocks = meta_get_blocks; + fs->check_directory = meta_check_directory; + fs->read_inode = meta_read_inode; + stashed_ino = 0; + } else { + fs->get_blocks = 0; + fs->check_directory = 0; + fs->read_inode = 0; + } +} + static int process_dir_block(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, blk_t ref_block, int ref_offset, void *priv_data) @@ -293,7 +317,7 @@ static void write_block(int fd, char *buf, int sparse_offset, } } -static output_meta_data_blocks(ext2_filsys fs, int fd) +static void output_meta_data_blocks(ext2_filsys fs, int fd) { errcode_t retval; blk_t blk; @@ -360,6 +384,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd) exit(1); } + use_inode_shortcuts(fs, 1); stashed_inode = &inode; while (1) { retval = ext2fs_get_next_inode(scan, &ino, &inode); @@ -404,7 +429,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd) } } } - + use_inode_shortcuts(fs, 0); output_meta_data_blocks(fs, fd); } diff --git a/misc/fsck.c b/misc/fsck.c index c958bafc..83751bd8 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -736,7 +736,7 @@ static int fs_match(struct fs_info *fs, struct fs_type_compile *cmp) if (cmp->list == 0 || cmp->list[0] == 0) return 1; - for (n=0; cp = cmp->list[n]; n++) { + for (n=0; (cp = cmp->list[n]); n++) { switch (cmp->type[n]) { case FS_TYPE_NORMAL: checked_type++; diff --git a/misc/fstype.c b/misc/fstype.c index 31f30273..8f127386 100644 --- a/misc/fstype.c +++ b/misc/fstype.c @@ -16,11 +16,13 @@ #include <fcntl.h> #include <sys/types.h> +#include "fsck.h" + struct fs_magic { - const char *fs_name; - int offset; - int len; - char *magic; + const char *fs_name; + int offset; + int len; + const char *magic; }; struct fs_magic type_array[] = { diff --git a/misc/get_device_by_label.c b/misc/get_device_by_label.c index 69750d4f..2bebcded 100644 --- a/misc/get_device_by_label.c +++ b/misc/get_device_by_label.c @@ -82,7 +82,7 @@ get_label_uuid(const char *device, char **label, char *uuid) { /* should merge these later */ int fd; size_t label_size; - char *sb_uuid = 0, *sb_label = 0; + unsigned char *sb_uuid = 0, *sb_label = 0; struct ext2_super_block e2sb; struct xfs_super_block xfsb; diff --git a/misc/mke2fs.c b/misc/mke2fs.c index f7e48321..d60e28e3 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -142,7 +142,8 @@ struct mke2fs_defaults { { 0, 0, 0, 0}, }; -static void set_fs_defaults(char *fs_type, struct ext2_super_block *super, +static void set_fs_defaults(const char *fs_type, + struct ext2_super_block *super, int blocksize, int *inode_ratio) { int megs; @@ -317,7 +318,7 @@ struct progress_struct { }; static void progress_init(struct progress_struct *progress, - char *label,__u32 max) + const char *label,__u32 max) { int i; @@ -555,8 +556,8 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect) buf = malloc(512*nsect); if (!buf) { - printf(_("Warning: out of memory erasing sectors %d-%d: %s\n"), - sect, sect + nsect - 1, error_message(retval)); + printf(_("Out of memory erasing sectors %d-%d\n"), + sect, sect + nsect - 1); exit(1); } memset(buf, 0, 512*nsect); @@ -771,7 +772,7 @@ static void PRS(int argc, char *argv[]) errcode_t retval; char * oldpath = getenv("PATH"); char * raid_opts = 0; - char * fs_type = 0; + const char * fs_type = 0; int default_features = 1; blk_t dev_size; #ifdef linux diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 028c25cd..794f35b1 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -95,7 +95,7 @@ static __u32 ok_features[3] = { */ static void remove_journal_device(ext2_filsys fs) { - char *journal_device; + char *journal_path; ext2_filsys jfs; char buf[1024]; journal_superblock_t *jsb; @@ -107,16 +107,16 @@ static void remove_journal_device(ext2_filsys fs) commit_remove_journal = 1; /* force removal even if error */ uuid_unparse(fs->super->s_journal_uuid, buf); - journal_device = get_spec_by_uuid(buf); + journal_path = get_spec_by_uuid(buf); - if (!journal_device) { - journal_device = + if (!journal_path) { + journal_path = ext2fs_find_block_device(fs->super->s_journal_dev); - if (!journal_device) + if (!journal_path) return; } - retval = ext2fs_open(journal_device, EXT2_FLAG_RW| + retval = ext2fs_open(journal_path, EXT2_FLAG_RW| EXT2_FLAG_JOURNAL_DEV_OK, 0, fs->blocksize, unix_io_manager, &jfs); if (retval) { @@ -126,7 +126,7 @@ static void remove_journal_device(ext2_filsys fs) } if (!(jfs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { fprintf(stderr, _("%s is not a journal device.\n"), - journal_device); + journal_path); goto no_valid_journal; } @@ -181,7 +181,7 @@ no_valid_journal: sizeof(fs->super->s_journal_uuid)); ext2fs_mark_super_dirty(fs); printf(_("Journal removed\n")); - free(journal_device); + free(journal_path); } /* Helper function for remove_journal_inode */ @@ -250,9 +250,7 @@ static void update_feature_set(ext2_filsys fs, char *features) { int sparse, old_sparse, filetype, old_filetype; int journal, old_journal; - struct ext2_inode inode; struct ext2_super_block *sb= fs->super; - errcode_t retval; old_sparse = sb->s_feature_ro_compat & EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER; diff --git a/misc/util.c b/misc/util.c index 1160e6b8..4bffb43a 100644 --- a/misc/util.c +++ b/misc/util.c @@ -206,7 +206,7 @@ void parse_journal_opts(const char *opts) * in the filesystem. For very small filesystems, it is not reasonable to * have a journal that fills more than half of the filesystem. */ -int figure_journal_size(int journal_size, ext2_filsys fs) +int figure_journal_size(int size, ext2_filsys fs) { blk_t j_blocks; @@ -215,9 +215,8 @@ int figure_journal_size(int journal_size, ext2_filsys fs) return 0; } - if (journal_size >= 0) { - j_blocks = journal_size * 1024 / - (fs->blocksize / 1024); + if (size >= 0) { + j_blocks = size * 1024 / (fs->blocksize / 1024); if (j_blocks < 1024 || j_blocks > 102400) { fprintf(stderr, _("\nThe requested journal " "size is %d blocks; it must be\n" diff --git a/misc/util.h b/misc/util.h index d4ef8f96..d3cc9e66 100644 --- a/misc/util.h +++ b/misc/util.h @@ -21,5 +21,5 @@ extern void proceed_question(void); extern void check_plausibility(const char *device); extern void parse_journal_opts(const char *opts); extern void check_mount(const char *device, int force, const char *type); -extern int figure_journal_size(int journal_size, ext2_filsys fs); +extern int figure_journal_size(int size, ext2_filsys fs); extern void print_check_message(ext2_filsys fs); |