mirror of https://github.com/vitalif/e2fsprogs
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.bitmap-optimize
parent
8cf93332d1
commit
4ea7bd0439
|
@ -1,5 +1,8 @@
|
|||
2001-12-16 Theodore Tso <tytso@valinux.com>
|
||||
|
||||
* setsuper.c (print_possible_fields),
|
||||
logdump.c (dump_journal): Fix gcc -Wall nits
|
||||
|
||||
* Makefile.in, jfs_user.h: linux/jfs.h has been renamed to
|
||||
linux/jbd.h
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ extern int optreset; /* defined by BSD, but not others */
|
|||
|
||||
#include "debugfs.h"
|
||||
#include "jfs_user.h"
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
|
||||
|
||||
|
@ -342,13 +343,13 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
|||
(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
|
||||
blocksize = EXT2_BLOCK_SIZE(sb);
|
||||
blocknr = (blocksize == 1024) ? 2 : 1;
|
||||
uuid_unparse(&sb->s_uuid, jsb_buffer);
|
||||
uuid_unparse(sb->s_uuid, jsb_buffer);
|
||||
fprintf(out_file, "Ext2 superblock header found.\n");
|
||||
if (dump_all) {
|
||||
fprintf(out_file, "\tuuid=%s\n", jsb_buffer);
|
||||
fprintf(out_file, "\tblocksize=%d\n", blocksize);
|
||||
fprintf(out_file, "\tjournal data size %ld\n",
|
||||
sb->s_blocks_count);
|
||||
(long) sb->s_blocks_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ static errcode_t parse_string(struct super_set_info *info, char *arg)
|
|||
static void print_possible_fields()
|
||||
{
|
||||
struct super_set_info *ss;
|
||||
char *type;
|
||||
const char *type;
|
||||
|
||||
printf("Superblock fields supported by the set_super_value command:\n");
|
||||
for (ss = super_fields ; ss->name ; ss++) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
2001-12-16 Theodore Tso <tytso@valinux.com>
|
||||
|
||||
* e2fsck.h (ext2fs_get_refcount_size), unix.c (check_mount, PRS),
|
||||
pass1.c (adjust_extattr_refcount),
|
||||
ea_refcount.c (ea_refcount_create): Fix gcc -Wall nits.
|
||||
|
||||
* recovery.c, revoke.c: Update to versions from 2.4.17-pre8.
|
||||
|
||||
* journal.c, jfs_user.h: Update support code for new version of
|
||||
|
|
|
@ -304,6 +304,7 @@ extern errcode_t ea_refcount_decrement(ext2_refcount_t refcount,
|
|||
blk_t blk, int *ret);
|
||||
extern errcode_t ea_refcount_store(ext2_refcount_t refcount,
|
||||
blk_t blk, int count);
|
||||
extern blk_t ext2fs_get_refcount_size(ext2_refcount_t refcount);
|
||||
extern void ea_refcount_intr_begin(ext2_refcount_t refcount);
|
||||
extern blk_t ea_refcount_intr_next(ext2_refcount_t refcount, int *ret);
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ errcode_t ea_refcount_create(int size, ext2_refcount_t *ret)
|
|||
ext2_refcount_t refcount;
|
||||
errcode_t retval;
|
||||
size_t bytes;
|
||||
int i;
|
||||
|
||||
retval = ext2fs_get_mem(sizeof(struct ea_refcount),
|
||||
(void **) &refcount);
|
||||
|
|
|
@ -933,7 +933,6 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
|
|||
struct ext2_ext_attr_header *header;
|
||||
struct problem_context pctx;
|
||||
ext2_filsys fs = ctx->fs;
|
||||
errcode_t retval;
|
||||
blk_t blk;
|
||||
__u32 should_be;
|
||||
int count;
|
||||
|
|
|
@ -204,7 +204,7 @@ static void show_stats(e2fsck_t ctx)
|
|||
static void check_mount(e2fsck_t ctx)
|
||||
{
|
||||
errcode_t retval;
|
||||
int mount_flags, cont, fd;
|
||||
int mount_flags, cont;
|
||||
|
||||
retval = ext2fs_check_if_mounted(ctx->filesystem_name, &mount_flags);
|
||||
if (retval) {
|
||||
|
@ -592,8 +592,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
|
|||
ctx->options |= E2F_OPT_READONLY;
|
||||
ctx->filesystem_name = argv[optind];
|
||||
if (flush) {
|
||||
int fd = open(ctx->filesystem_name, O_RDONLY, 0);
|
||||
|
||||
fd = open(ctx->filesystem_name, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
com_err("open", errno,
|
||||
_("while opening %s for flushing"),
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2001-12-16 Theodore Tso <tytso@valinux.com>
|
||||
|
||||
* pf.c: Add const to struct flags_name to avoid -Wall complaints.
|
||||
|
||||
2001-11-05 Theodore Tso <tytso@valinux.com>
|
||||
|
||||
* pf.c: Add a new file attribute, EXT2_NOTAIL_FL
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
struct flags_name {
|
||||
unsigned long flag;
|
||||
char *short_name;
|
||||
char *long_name;
|
||||
const char *short_name;
|
||||
const char *long_name;
|
||||
};
|
||||
|
||||
static struct flags_name flags_array[] = {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
2001-12-16 Theodore Tso <tytso@valinux.com>
|
||||
|
||||
* bitops.h (ext2fs_mark_generic_bitmap, ext2fs_unmark_generic_bitmap),
|
||||
ext_attr.c (ext2fs_read_ext_attr, ext2fs_write_ext_attr),
|
||||
fileio.c (ext2fs_file_write): Fix gcc -Wall nits
|
||||
|
||||
* Makefile.in, jfs_user.h: linux/jfs.h has been renamed to
|
||||
linux/jbd.h
|
||||
|
||||
|
|
|
@ -77,6 +77,11 @@ extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
|||
blk_t block, int num);
|
||||
extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
|
||||
|
||||
/* These two routines moved to gen_bitmap.c */
|
||||
extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
__u32 bitno);
|
||||
extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
blk_t bitno);
|
||||
/*
|
||||
* The inline routines themselves...
|
||||
*
|
||||
|
@ -456,11 +461,6 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* These two routines moved to gen_bitmap.c */
|
||||
extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
__u32 bitno);
|
||||
extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
blk_t bitno);
|
||||
_INLINE_ int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
blk_t bitno);
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ void ext2fs_swap_ext_attr(ext2_filsys fs, char *to, char *from)
|
|||
errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
|
||||
{
|
||||
errcode_t retval;
|
||||
struct ext2_ext_attr_entry *entry;
|
||||
|
||||
retval = io_channel_read_blk(fs->io, block, 1, buf);
|
||||
if (retval)
|
||||
|
@ -76,9 +75,8 @@ errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
|
|||
errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, void *inbuf)
|
||||
{
|
||||
errcode_t retval;
|
||||
char *p, *end, *write_buf;
|
||||
char *write_buf;
|
||||
char *buf = NULL;
|
||||
struct ext2_dir_entry *dirent;
|
||||
|
||||
#ifdef EXT2FS_ENABLE_SWAPFS
|
||||
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
|
||||
|
|
|
@ -239,11 +239,9 @@ errcode_t ext2fs_file_write(ext2_file_t file, void *buf,
|
|||
unsigned int nbytes, unsigned int *written)
|
||||
{
|
||||
ext2_filsys fs;
|
||||
blk_t pb;
|
||||
errcode_t retval = 0;
|
||||
unsigned int start, c, count = 0;
|
||||
char *ptr = (char *) buf;
|
||||
int dontfill;
|
||||
|
||||
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
|
||||
fs = file->fs;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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[] = {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue