diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-08-27 23:07:54 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-08-27 23:07:54 -0400 |
commit | efc6f628e15de95bcd13e4f0ee223cb42115d520 (patch) | |
tree | 7f486b4bc1a4c8fc47f236f1e95e33feee745f7c | |
parent | 4690e621acd4579dae60b6f55f58284ee805e86d (diff) | |
download | e2fsprogs-efc6f628e15de95bcd13e4f0ee223cb42115d520.tar.gz |
Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
233 files changed, 2691 insertions, 2691 deletions
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 8b2f31e5..8b0965ec 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -4,7 +4,7 @@ * * Copyright (C) 1993 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. - * + * * Modifications by Robert Sanders <gt8134b@prism.gatech.edu> */ @@ -16,7 +16,7 @@ #include <time.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif @@ -46,7 +46,7 @@ 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, + blk_t blocksize, int catastrophic, char *data_filename) { int retval; @@ -60,7 +60,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock, if (data_filename) { if ((open_flags & EXT2_FLAG_IMAGE_FILE) == 0) { - com_err(device, 0, + com_err(device, 0, "The -d option is only valid when reading an e2image file"); current_fs = NULL; return; @@ -78,7 +78,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock, "opening read-only because of catastrophic mode"); open_flags &= ~EXT2_FLAG_RW; } - + retval = ext2fs_open(device, open_flags, superblock, blocksize, unix_io_manager, ¤t_fs); if (retval) { @@ -105,7 +105,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock, if (data_io) { retval = ext2fs_set_data_io(current_fs, data_io); if (retval) { - com_err(device, retval, + com_err(device, retval, "while setting data source"); goto errout; } @@ -129,7 +129,7 @@ void do_open_filesys(int argc, char **argv) blk_t blocksize = 0; int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES; char *data_filename = 0; - + reset_getopt(); while ((c = getopt (argc, argv, "iwfecb:s:d:")) != EOF) { switch (c) { @@ -173,7 +173,7 @@ void do_open_filesys(int argc, char **argv) if (check_fs_not_open(argv[0])) return; open_filesystem(argv[optind], open_flags, - superblock, blocksize, catastrophic, + superblock, blocksize, catastrophic, data_filename); return; @@ -200,7 +200,7 @@ void do_lcd(int argc, char **argv) static void close_filesystem(NOARGS) { int retval; - + if (current_fs->flags & EXT2_FLAG_IB_DIRTY) { retval = ext2fs_write_inode_bitmap(current_fs); if (retval) @@ -230,7 +230,7 @@ void do_init_filesys(int argc, char **argv) struct ext2_super_block param; errcode_t retval; int err; - + if (common_args_process(argc, argv, 3, 3, "initialize", "<device> <blocksize>", CHECK_FS_NOTOPEN)) return; @@ -315,12 +315,12 @@ void do_show_super_stats(int argc, char *argv[]) for (i=0; i < current_fs->group_desc_count; i++) numdirs += current_fs->group_desc[i].bg_used_dirs_count; fprintf(out, "Directories: %d\n", numdirs); - + if (header_only) { close_pager(out); return; } - + gdp = ¤t_fs->group_desc[0]; for (i = 0; i < current_fs->group_desc_count; i++, gdp++) { fprintf(out, " Group %2d: block bitmap at %u, " @@ -361,7 +361,7 @@ print_usage: fprintf(stderr, "%s: Usage: show_super [-h]\n", argv[0]); } -void do_dirty_filesys(int argc EXT2FS_ATTR((unused)), +void do_dirty_filesys(int argc EXT2FS_ATTR((unused)), char **argv EXT2FS_ATTR((unused))) { if (check_fs_open(argv[0])) @@ -402,10 +402,10 @@ static void finish_range(struct list_blocks_struct *lb) lb->first_block = 0; } -static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)), - blk_t *blocknr, e2_blkcnt_t blockcnt, +static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)), + blk_t *blocknr, e2_blkcnt_t blockcnt, blk_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *private) { struct list_blocks_struct *lb = (struct list_blocks_struct *) private; @@ -451,7 +451,7 @@ static void dump_xattr_string(FILE *out, const char *str, int len) { int printable = 0; int i; - + /* check: is string "printable enough?" */ for (i = 0; i < len; i++) if (isprint(str[i])) @@ -468,9 +468,9 @@ static void dump_xattr_string(FILE *out, const char *str, int len) fprintf(out, "%02x ", (unsigned char)str[i]); } -static void internal_dump_inode_extra(FILE *out, +static void internal_dump_inode_extra(FILE *out, const char *prefix EXT2FS_ATTR((unused)), - ext2_ino_t inode_num EXT2FS_ATTR((unused)), + ext2_ino_t inode_num EXT2FS_ATTR((unused)), struct ext2_inode_large *inode) { struct ext2_ext_attr_entry *entry; @@ -504,7 +504,7 @@ static void internal_dump_inode_extra(FILE *out, return; } fprintf(out, " "); - dump_xattr_string(out, EXT2_EXT_ATTR_NAME(entry), + dump_xattr_string(out, EXT2_EXT_ATTR_NAME(entry), entry->e_name_len); fprintf(out, " = \""); dump_xattr_string(out, start + entry->e_value_offs, @@ -559,11 +559,11 @@ void internal_dump_inode(FILE *out, const char *prefix, fprintf(out, "%sMode: %04o Flags: 0x%x\n", prefix, inode->i_mode & 0777, inode->i_flags); if (is_large_inode && large_inode->i_extra_isize >= 24) { - fprintf(out, "%sGeneration: %u Version: 0x%08x:%08x\n", + fprintf(out, "%sGeneration: %u Version: 0x%08x:%08x\n", prefix, inode->i_generation, large_inode->i_version_hi, inode->osd1.linux1.l_i_version); } else { - fprintf(out, "%sGeneration: %u Version: 0x%08x\n", prefix, + fprintf(out, "%sGeneration: %u Version: 0x%08x\n", prefix, inode->i_generation, inode->osd1.linux1.l_i_version); } fprintf(out, "%sUser: %5d Group: %5d Size: ", @@ -585,11 +585,11 @@ void internal_dump_inode(FILE *out, const char *prefix, fprintf(out, "%sFile ACL: %d Directory ACL: %d\n", prefix, inode->i_file_acl, LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0); - if (os == EXT2_OS_LINUX) + if (os == EXT2_OS_LINUX) fprintf(out, "%sLinks: %d Blockcount: %llu\n", - prefix, inode->i_links_count, - (((unsigned long long) - inode->osd2.linux2.l_i_blocks_hi << 32)) + + prefix, inode->i_links_count, + (((unsigned long long) + inode->osd2.linux2.l_i_blocks_hi << 32)) + inode->i_blocks); else fprintf(out, "%sLinks: %d Blockcount: %u\n", @@ -605,10 +605,10 @@ void internal_dump_inode(FILE *out, const char *prefix, fprintf(out, "%sFragment: Address: %d Number: %d Size: %d\n", prefix, inode->i_faddr, frag, fsize); if (is_large_inode && large_inode->i_extra_isize >= 24) { - fprintf(out, "%s ctime: 0x%08x:%08x -- %s", prefix, + fprintf(out, "%s ctime: 0x%08x:%08x -- %s", prefix, inode->i_ctime, large_inode->i_ctime_extra, time_to_string(inode->i_ctime)); - fprintf(out, "%s atime: 0x%08x:%08x -- %s", prefix, + fprintf(out, "%s atime: 0x%08x:%08x -- %s", prefix, inode->i_atime, large_inode->i_atime_extra, time_to_string(inode->i_atime)); fprintf(out, "%s mtime: 0x%08x:%08x -- %s", prefix, @@ -625,7 +625,7 @@ void internal_dump_inode(FILE *out, const char *prefix, fprintf(out, "%smtime: 0x%08x -- %s", prefix, inode->i_mtime, time_to_string(inode->i_mtime)); } - if (inode->i_dtime) + if (inode->i_dtime) fprintf(out, "%sdtime: 0x%08x -- %s", prefix, inode->i_dtime, time_to_string(inode->i_dtime)); if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE) @@ -644,11 +644,11 @@ void internal_dump_inode(FILE *out, const char *prefix, devnote = ""; } else { major = (inode->i_block[1] & 0xfff00) >> 8; - minor = ((inode->i_block[1] & 0xff) | + minor = ((inode->i_block[1] & 0xff) | ((inode->i_block[1] >> 12) & 0xfff00)); devnote = "(New-style) "; } - fprintf(out, "%sDevice major/minor number: %02d:%02d (hex %02x:%02x)\n", + fprintf(out, "%sDevice major/minor number: %02d:%02d (hex %02x:%02x)\n", devnote, major, minor, major, minor); } else if (do_dump_blocks) @@ -658,7 +658,7 @@ void internal_dump_inode(FILE *out, const char *prefix, static void dump_inode(ext2_ino_t inode_num, struct ext2_inode *inode) { FILE *out; - + out = open_pager(); internal_dump_inode(out, "", inode_num, inode, 1); close_pager(out); @@ -900,7 +900,7 @@ void do_modify_inode(int argc, char *argv[]) const char *octal_format = "0%o"; const char *decimal_format = "%d"; const char *unsignedlong_format = "%lu"; - + if (common_inode_args_process(argc, argv, &inode_num, CHECK_FS_RW)) return; @@ -908,7 +908,7 @@ void do_modify_inode(int argc, char *argv[]) if (debugfs_read_inode(inode_num, &inode, argv[1])) return; - + modify_u16(argv[0], "Mode", octal_format, &inode.i_mode); modify_u16(argv[0], "User ID", decimal_format, &inode.i_uid); modify_u16(argv[0], "Group ID", decimal_format, &inode.i_gid); @@ -919,7 +919,7 @@ void do_modify_inode(int argc, char *argv[]) modify_u32(argv[0], "Deletion time", decimal_format, &inode.i_dtime); modify_u16(argv[0], "Link count", decimal_format, &inode.i_links_count); if (os == EXT2_OS_LINUX) - modify_u16(argv[0], "Block count high", unsignedlong_format, + modify_u16(argv[0], "Block count high", unsignedlong_format, &inode.osd2.linux2.l_i_blocks_hi); modify_u32(argv[0], "Block count", unsignedlong_format, &inode.i_blocks); modify_u32(argv[0], "File flags", hex_format, &inode.i_flags); @@ -936,7 +936,7 @@ void do_modify_inode(int argc, char *argv[]) if (os == EXT2_OS_HURD) modify_u32(argv[0], "Translator Block", decimal_format, &inode.osd1.hurd1.h_i_translator); - + modify_u32(argv[0], "Fragment address", decimal_format, &inode.i_faddr); switch (os) { case EXT2_OS_HURD: @@ -956,7 +956,7 @@ void do_modify_inode(int argc, char *argv[]) modify_u32(argv[0], buf, decimal_format, &inode.i_block[i]); } modify_u32(argv[0], "Indirect Block", decimal_format, - &inode.i_block[EXT2_IND_BLOCK]); + &inode.i_block[EXT2_IND_BLOCK]); modify_u32(argv[0], "Double Indirect Block", decimal_format, &inode.i_block[EXT2_DIND_BLOCK]); modify_u32(argv[0], "Triple Indirect Block", decimal_format, @@ -969,7 +969,7 @@ void do_change_working_dir(int argc, char *argv[]) { ext2_ino_t inode; int retval; - + if (common_inode_args_process(argc, argv, &inode, 0)) return; @@ -986,7 +986,7 @@ void do_print_working_directory(int argc, char *argv[]) { int retval; char *pathname = NULL; - + if (common_args_process(argc, argv, 1, 1, "print_working_directory", "", 0)) return; @@ -1026,22 +1026,22 @@ static int ext2_file_type(unsigned int mode) if (LINUX_S_ISDIR(mode)) return EXT2_FT_DIR; - + if (LINUX_S_ISCHR(mode)) return EXT2_FT_CHRDEV; - + if (LINUX_S_ISBLK(mode)) return EXT2_FT_BLKDEV; - + if (LINUX_S_ISLNK(mode)) return EXT2_FT_SYMLINK; if (LINUX_S_ISFIFO(mode)) return EXT2_FT_FIFO; - + if (LINUX_S_ISSOCK(mode)) return EXT2_FT_SOCK; - + return 0; } @@ -1066,7 +1066,7 @@ static void make_link(char *sourcename, char *destname) base_name = sourcename; /* * Figure out the destination. First see if it exists and is - * a directory. + * a directory. */ if (! (retval=ext2fs_namei(current_fs, root, cwd, destname, &dir))) dest = base_name; @@ -1090,8 +1090,8 @@ static void make_link(char *sourcename, char *destname) if (debugfs_read_inode(ino, &inode, sourcename)) return; - - retval = ext2fs_link(current_fs, dir, dest, ino, + + retval = ext2fs_link(current_fs, dir, dest, ino, ext2_file_type(inode.i_mode)); if (retval) com_err("make_link", retval, 0); @@ -1109,7 +1109,7 @@ void do_link(int argc, char *argv[]) } static int mark_blocks_proc(ext2_filsys fs, blk_t *blocknr, - int blockcnt EXT2FS_ATTR((unused)), + int blockcnt EXT2FS_ATTR((unused)), void *private EXT2FS_ATTR((unused))) { blk_t block; @@ -1143,7 +1143,7 @@ void do_undel(int argc, char *argv[]) /* * XXX this function doesn't handle changing the links count on the - * parent directory when undeleting a directory. + * parent directory when undeleting a directory. */ inode.i_links_count = LINUX_S_ISDIR(inode.i_mode) ? 2 : 1; inode.i_dtime = 0; @@ -1165,7 +1165,7 @@ static void unlink_file_by_name(char *filename) int retval; ext2_ino_t dir; char *base_name; - + base_name = strrchr(filename, '/'); if (base_name) { *base_name++ = '\0'; @@ -1197,7 +1197,7 @@ void do_find_free_block(int argc, char *argv[]) int count; errcode_t retval; char *tmp; - + if ((argc > 3) || (argc==2 && *argv[1] == '?')) { com_err(argv[0], 0, "Usage: find_free_block [count [goal]]"); return; @@ -1225,7 +1225,7 @@ void do_find_free_block(int argc, char *argv[]) goal = current_fs->super->s_first_data_block; printf("Free blocks found: "); - free_blk = goal - 1; + free_blk = goal - 1; while (count-- > 0) { retval = ext2fs_new_block(current_fs, free_blk + 1, 0, &free_blk); @@ -1249,7 +1249,7 @@ void do_find_free_inode(int argc, char *argv[]) int mode; int retval; char *tmp; - + if (argc > 3 || (argc>1 && *argv[1] == '?')) { com_err(argv[0], 0, "Usage: find_free_inode [dir] [mode]"); return; @@ -1383,11 +1383,11 @@ void do_write(int argc, char *argv[]) ext2fs_inode_alloc_stats2(current_fs, newfile, +1, 0); memset(&inode, 0, sizeof(inode)); inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG; - inode.i_atime = inode.i_ctime = inode.i_mtime = + inode.i_atime = inode.i_ctime = inode.i_mtime = current_fs->now ? current_fs->now : time(0); inode.i_links_count = 1; inode.i_size = statbuf.st_size; - if (current_fs->super->s_feature_incompat & + if (current_fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) inode.i_flags |= EXT4_EXTENTS_FL; if (debugfs_write_new_inode(newfile, &inode, argv[0])) { @@ -1474,7 +1474,7 @@ void do_mknod(int argc, char *argv[]) ext2fs_mark_ib_dirty(current_fs); memset(&inode, 0, sizeof(inode)); inode.i_mode = mode; - inode.i_atime = inode.i_ctime = inode.i_mtime = + inode.i_atime = inode.i_ctime = inode.i_mtime = current_fs->now ? current_fs->now : time(0); if ((major < 256) && (minor < 256)) { inode.i_block[0] = major*256+minor; @@ -1531,7 +1531,7 @@ try_again: } static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr, - int blockcnt EXT2FS_ATTR((unused)), + int blockcnt EXT2FS_ATTR((unused)), void *private EXT2FS_ATTR((unused))) { blk_t block; @@ -1631,7 +1631,7 @@ static int rmdir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)), rds->empty = 0; return 0; } - + void do_rmdir(int argc, char *argv[]) { int retval; @@ -1688,7 +1688,7 @@ void do_rmdir(int argc, char *argv[]) } } -void do_show_debugfs_params(int argc EXT2FS_ATTR((unused)), +void do_show_debugfs_params(int argc EXT2FS_ATTR((unused)), char *argv[] EXT2FS_ATTR((unused))) { FILE *out = stdout; @@ -1717,7 +1717,7 @@ void do_expand_dir(int argc, char *argv[]) void do_features(int argc, char *argv[]) { int i; - + if (check_fs_open(argv[0])) return; @@ -1740,7 +1740,7 @@ void do_bmap(int argc, char *argv[]) blk_t blk, pblk; int err; errcode_t errcode; - + if (common_args_process(argc, argv, 3, 3, argv[0], "<file> logical_blk", 0)) return; @@ -1780,7 +1780,7 @@ void do_imap(int argc, char *argv[]) group); return; } - block_nr = current_fs->group_desc[(unsigned)group].bg_inode_table + + block_nr = current_fs->group_desc[(unsigned)group].bg_inode_table + block; offset &= (EXT2_BLOCK_SIZE(current_fs->super) - 1); @@ -1929,7 +1929,7 @@ int main(int argc, char **argv) blk_t blocksize = 0; int catastrophic = 0; char *data_filename = 0; - + if (debug_prog_name == 0) debug_prog_name = "debugfs"; @@ -1955,11 +1955,11 @@ int main(int argc, char **argv) open_flags |= EXT2_FLAG_RW; break; case 'b': - blocksize = parse_ulong(optarg, argv[0], + blocksize = parse_ulong(optarg, argv[0], "block size", 0); break; case 's': - superblock = parse_ulong(optarg, argv[0], + superblock = parse_ulong(optarg, argv[0], "superblock number", 0); break; case 'c': @@ -1979,7 +1979,7 @@ int main(int argc, char **argv) open_filesystem(argv[optind], open_flags, superblock, blocksize, catastrophic, data_filename); - + sci_idx = ss_create_invocation(debug_prog_name, "0.0", (char *) NULL, &debug_cmds, &retval); if (retval) { @@ -2014,7 +2014,7 @@ int main(int argc, char **argv) if (current_fs) close_filesystem(); - + remove_error_table(&et_ext2_error_table); return exit_status; } diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h index 003c19ad..3c0f0166 100644 --- a/debugfs/debugfs.h +++ b/debugfs/debugfs.h @@ -84,7 +84,7 @@ extern void do_set_block_group_descriptor(int argc, char **); extern void do_dump_unused(int argc, char **argv); /* debugfs.c */ -extern void internal_dump_inode(FILE *, const char *, ext2_ino_t, +extern void internal_dump_inode(FILE *, const char *, ext2_ino_t, struct ext2_inode *, int); extern void do_dirty_filesys(int argc, char **argv); diff --git a/debugfs/dump.c b/debugfs/dump.c index 2cfe623a..39a41668 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -1,6 +1,6 @@ /* * dump.c --- dump the contents of an inode out to a file - * + * * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. */ @@ -22,7 +22,7 @@ #include <utime.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif @@ -51,7 +51,7 @@ static struct { { LINUX_S_IXOTH, S_IXOTH }, { 0, 0 } }; - + static mode_t mode_xlate(__u16 lmode) { mode_t mode = 0; @@ -106,7 +106,7 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd, ext2_file_t e2_file; int nbytes; unsigned int got; - + if (debugfs_read_inode(ino, &inode, cmdname)) return; @@ -117,7 +117,7 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd, } while (1) { retval = ext2fs_file_read(e2_file, buf, sizeof(buf), &got); - if (retval) + if (retval) com_err(cmdname, retval, "while reading ext2 file"); if (got == 0) break; @@ -130,12 +130,12 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd, com_err(cmdname, retval, "while closing ext2 file"); return; } - + if (preserve) fix_perms("dump_file", &inode, fd, outname); else if (fd != 1) close(fd); - + return; } @@ -147,7 +147,7 @@ void do_dump(int argc, char **argv) int preserve = 0; const char *dump_usage = "Usage: dump_inode [-p] <file> <output_file>"; char *in_fn, *out_fn; - + reset_getopt(); while ((c = getopt (argc, argv, "p")) != EOF) { switch (c) { @@ -171,7 +171,7 @@ void do_dump(int argc, char **argv) out_fn = argv[optind+1]; inode = string_to_inode(in_fn); - if (!inode) + if (!inode) return; fd = open(out_fn, O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE, 0666); @@ -289,7 +289,7 @@ errout: free(fullname); } -static int rdump_dirent(struct ext2_dir_entry *dirent, +static int rdump_dirent(struct ext2_dir_entry *dirent, int offset EXT2FS_ATTR((unused)), int blocksize EXT2FS_ATTR((unused)), char *buf EXT2FS_ATTR((unused)), void *private) @@ -360,7 +360,7 @@ void do_cat(int argc, char **argv) fflush(stdout); fflush(stderr); - dump_file(argv[0], inode, 1, 0, argv[2]); + dump_file(argv[0], inode, 1, 0, argv[2]); return; } diff --git a/debugfs/htree.c b/debugfs/htree.c index 1659b63f..983dc9a2 100644 --- a/debugfs/htree.c +++ b/debugfs/htree.c @@ -1,6 +1,6 @@ /* * htree.c --- hash tree routines - * + * * Copyright (C) 2002 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. */ @@ -17,7 +17,7 @@ #include <sys/types.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif @@ -40,7 +40,7 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino, blk_t pblk; ext2_dirhash_t hash, minor_hash; int rec_len, hash_alg; - + errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk); if (errcode) { com_err("htree_dump_leaf_node", errcode, @@ -105,13 +105,13 @@ static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino, static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, struct ext2_dx_root_info * rootnode, - struct ext2_dx_entry *ent, + struct ext2_dx_entry *ent, char *buf, int level) { struct ext2_dx_countlimit limit; struct ext2_dx_entry e; int hash, i; - + limit = *((struct ext2_dx_countlimit *) ent); limit.count = ext2fs_le16_to_cpu(limit.count); @@ -159,7 +159,7 @@ static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino, fprintf(pager, "Couldn't allocate child block.\n"); return; } - + errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk); if (errcode) { com_err("htree_dump_int_block", errcode, @@ -232,7 +232,7 @@ void do_htree_dump(int argc, char *argv[]) com_err(argv[0], 0, "Not a directory"); goto errout; } - + if ((inode.i_flags & EXT2_BTREE_FL) == 0) { com_err(argv[0], 0, "Not a hash-indexed directory"); goto errout; @@ -251,7 +251,7 @@ void do_htree_dump(int argc, char *argv[]) goto errout; } - errcode = io_channel_read_blk(current_fs->io, blk, + errcode = io_channel_read_blk(current_fs->io, blk, 1, buf); if (errcode) { com_err(argv[0], errcode, "Error reading root node"); @@ -290,7 +290,7 @@ void do_dx_hash(int argc, char *argv[]) int c; int hash_version = 0; __u32 hash_seed[4]; - + hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0; reset_getopt(); @@ -330,14 +330,14 @@ struct process_block_struct { }; static int search_dir_block(ext2_filsys fs, blk_t *blocknr, - e2_blkcnt_t blockcnt, blk_t ref_blk, + e2_blkcnt_t blockcnt, blk_t ref_blk, int ref_offset, void *priv_data); void do_dirsearch(int argc, char *argv[]) { ext2_ino_t inode; struct process_block_struct pb; - + if (check_fs_open(argv[0])) return; @@ -357,7 +357,7 @@ void do_dirsearch(int argc, char *argv[]) } pb.search_name = argv[2]; pb.len = strlen(pb.search_name); - + ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, 0, search_dir_block, &pb); @@ -366,7 +366,7 @@ void do_dirsearch(int argc, char *argv[]) static int search_dir_block(ext2_filsys fs, blk_t *blocknr, - e2_blkcnt_t blockcnt, + e2_blkcnt_t blockcnt, blk_t ref_blk EXT2FS_ATTR((unused)), int ref_offset EXT2FS_ATTR((unused)), void *priv_data) @@ -394,7 +394,7 @@ static int search_dir_block(ext2_filsys fs, blk_t *blocknr, rec_len = (dirent->rec_len || fs->blocksize < 65536) ? dirent->rec_len : 65536; if (dirent->inode && - p->len == (dirent->name_len & 0xFF) && + p->len == (dirent->name_len & 0xFF) && strncmp(p->search_name, dirent->name, p->len) == 0) { printf("Entry found at logical block %lld, " diff --git a/debugfs/icheck.c b/debugfs/icheck.c index 01c78bcb..2f880c05 100644 --- a/debugfs/icheck.c +++ b/debugfs/icheck.c @@ -1,6 +1,6 @@ /* * icheck.c --- given a list of blocks, generate a list of inodes - * + * * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. */ @@ -48,7 +48,7 @@ static int icheck_proc(ext2_filsys fs EXT2FS_ATTR((unused)), } if (!bw->blocks_left) return BLOCK_ABORT; - + return 0; } @@ -62,7 +62,7 @@ void do_icheck(int argc, char **argv) struct ext2_inode inode; errcode_t retval; char *block_buf; - + if (argc < 2) { com_err(argv[0], 0, "Usage: icheck <block number> ..."); return; @@ -104,7 +104,7 @@ void do_icheck(int argc, char **argv) com_err("icheck", retval, "while starting inode scan"); goto error_out; } - + while (ino) { if (!inode.i_links_count) goto next; diff --git a/debugfs/logdump.c b/debugfs/logdump.c index 08e58f7d..fed98380 100644 --- a/debugfs/logdump.c +++ b/debugfs/logdump.c @@ -1,11 +1,11 @@ /* * logdump.c --- dump the contents of the journal out to a file - * + * * Authro: Stephen C. Tweedie, 2001 <sct@redhat.com> * Copyright (C) 2001 Red Hat, Inc. - * Based on portions Copyright (C) 1994 Theodore Ts'o. + * Based on portions Copyright (C) 1994 Theodore Ts'o. * - * This file may be redistributed under the terms of the GNU Public + * This file may be redistributed under the terms of the GNU Public * License. */ @@ -24,7 +24,7 @@ #include <utime.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif @@ -43,7 +43,7 @@ blk_t block_to_dump, bitmap_to_dump, inode_block_to_dump; unsigned int group_to_dump, inode_offset_to_dump; ext2_ino_t inode_to_dump; -struct journal_source +struct journal_source { enum journal_location where; int fd; @@ -60,7 +60,7 @@ static void dump_revoke_block(FILE *, char *, journal_superblock_t *, unsigned int, int, tid_t); static void dump_metadata_block(FILE *, struct journal_source *, - journal_superblock_t*, + journal_superblock_t*, unsigned int, unsigned int, int, tid_t); static void do_hexdump (FILE *, char *, int); @@ -76,7 +76,7 @@ void do_logdump(int argc, char **argv) int retval; char *out_fn; FILE *out_file; - + char *inode_spec = NULL; char *journal_fn = NULL; int journal_fd = 0; @@ -87,7 +87,7 @@ void do_logdump(int argc, char **argv) char *tmp; struct journal_source journal_source; struct ext2_super_block *es = NULL; - + journal_source.where = 0; journal_source.fd = 0; journal_source.file = 0; @@ -98,7 +98,7 @@ void do_logdump(int argc, char **argv) bitmap_to_dump = -1; inode_block_to_dump = ANY_BLOCK; inode_to_dump = -1; - + reset_getopt(); while ((c = getopt (argc, argv, "ab:ci:f:s")) != EOF) { switch (c) { @@ -152,11 +152,11 @@ void do_logdump(int argc, char **argv) / es->s_inodes_per_group); group_offset = ((inode_to_dump - 1) % es->s_inodes_per_group); - inodes_per_block = (current_fs->blocksize + inodes_per_block = (current_fs->blocksize / sizeof(struct ext2_inode)); - - inode_block_to_dump = - current_fs->group_desc[inode_group].bg_inode_table + + + inode_block_to_dump = + current_fs->group_desc[inode_group].bg_inode_table + (group_offset / inodes_per_block); inode_offset_to_dump = ((group_offset % inodes_per_block) * sizeof(struct ext2_inode)); @@ -178,7 +178,7 @@ void do_logdump(int argc, char **argv) } if (block_to_dump != ANY_BLOCK && current_fs != NULL) { - group_to_dump = ((block_to_dump - + group_to_dump = ((block_to_dump - es->s_first_data_block) / es->s_blocks_per_group); bitmap_to_dump = current_fs->group_desc[group_to_dump].bg_block_bitmap; @@ -195,7 +195,7 @@ void do_logdump(int argc, char **argv) journal_fn); goto errout; } - + journal_source.where = JOURNAL_IS_EXTERNAL; journal_source.fd = journal_fd; } else if ((journal_inum = es->s_journal_inum)) { @@ -206,17 +206,17 @@ void do_logdump(int argc, char **argv) goto errout; } memset(&journal_inode, 0, sizeof(struct ext2_inode)); - memcpy(&journal_inode.i_block[0], es->s_jnl_blocks, + memcpy(&journal_inode.i_block[0], es->s_jnl_blocks, EXT2_N_BLOCKS*4); journal_inode.i_size = es->s_jnl_blocks[16]; journal_inode.i_links_count = 1; journal_inode.i_mode = LINUX_S_IFREG | 0600; } else { - if (debugfs_read_inode(journal_inum, &journal_inode, + if (debugfs_read_inode(journal_inum, &journal_inode, argv[0])) goto errout; } - + retval = ext2fs_file_open2(current_fs, journal_inum, &journal_inode, 0, &journal_file); if (retval) { @@ -227,7 +227,7 @@ void do_logdump(int argc, char **argv) journal_source.file = journal_file; } else { char uuid[37]; - + uuid_unparse(es->s_journal_uuid, uuid); journal_fn = blkid_get_devname(NULL, "UUID", uuid); if (!journal_fn) @@ -269,12 +269,12 @@ print_usage: } -static int read_journal_block(const char *cmd, struct journal_source *source, +static int read_journal_block(const char *cmd, struct journal_source *source, off_t offset, char *buf, int size, unsigned int *got) { int retval; - + if (source->where == JOURNAL_IS_EXTERNAL) { if (lseek(source->fd, offset, SEEK_SET) < 0) { retval = errno; @@ -288,23 +288,23 @@ static int read_journal_block(const char *cmd, struct journal_source *source, } else retval = errno; } else { - retval = ext2fs_file_lseek(source->file, offset, + retval = ext2fs_file_lseek(source->file, offset, EXT2_SEEK_SET, NULL); if (retval) { com_err(cmd, retval, "while seeking in reading journal"); return retval; } - + retval = ext2fs_file_read(source->file, buf, size, got); } - + if (retval) com_err(cmd, retval, "while while reading journal"); else if (*got != (unsigned int) size) { com_err(cmd, 0, "short read (read %d, expected %d) while while reading journal", *got, size); retval = -1; } - + return retval; } @@ -326,7 +326,7 @@ static const char *type_to_name(int btype) } -static void dump_journal(char *cmdname, FILE *out_file, +static void dump_journal(char *cmdname, FILE *out_file, struct journal_source *source) { struct ext2_super_block *sb; @@ -338,12 +338,12 @@ static void dump_journal(char *cmdname, FILE *out_file, int retval; __u32 magic, sequence, blocktype; journal_header_t *header; - + tid_t transaction; unsigned int blocknr = 0; - + /* First, check to see if there's an ext2 superblock header */ - retval = read_journal_block(cmdname, source, 0, + retval = read_journal_block(cmdname, source, 0, buf, 2048, &got); if (retval) return; @@ -351,10 +351,10 @@ static void dump_journal(char *cmdname, FILE *out_file, jsb = (journal_superblock_t *) buf; sb = (struct ext2_super_block *) (buf+1024); #ifdef WORDS_BIGENDIAN - if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) + if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) ext2fs_swap_super(sb); #endif - + if ((be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) && (sb->s_magic == EXT2_SUPER_MAGIC) && (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { @@ -369,10 +369,10 @@ static void dump_journal(char *cmdname, FILE *out_file, (unsigned long) sb->s_blocks_count); } } - + /* Next, read the journal superblock */ - retval = read_journal_block(cmdname, source, blocknr*blocksize, + retval = read_journal_block(cmdname, source, blocknr*blocksize, jsb_buffer, 1024, &got); if (retval) return; @@ -393,29 +393,29 @@ static void dump_journal(char *cmdname, FILE *out_file, if (!blocknr) /* Empty journal, nothing to do. */ return; - + while (1) { - retval = read_journal_block(cmdname, source, + retval = read_journal_block(cmdname, source, blocknr*blocksize, buf, blocksize, &got); if (retval || got != blocksize) return; - + header = (journal_header_t *) buf; magic = be32_to_cpu(header->h_magic); sequence = be32_to_cpu(header->h_sequence); blocktype = be32_to_cpu(header->h_blocktype); - + if (magic != JFS_MAGIC_NUMBER) { fprintf (out_file, "No magic number at block %u: " "end of journal.\n", blocknr); return; } - + if (sequence != transaction) { fprintf (out_file, "Found sequence %u (not %u) at " - "block %u: end of journal.\n", + "block %u: end of journal.\n", sequence, transaction, blocknr); return; } @@ -423,13 +423,13 @@ static void dump_journal(char *cmdname, FILE *out_file, if (dump_descriptors) { fprintf (out_file, "Found expected sequence %u, " "type %u (%s) at block %u\n", - sequence, blocktype, + sequence, blocktype, type_to_name(blocktype), blocknr); } - + switch (blocktype) { case JFS_DESCRIPTOR_BLOCK: - dump_descriptor_block(out_file, source, buf, jsb, + dump_descriptor_block(out_file, source, buf, jsb, &blocknr, blocksize, transaction); continue; @@ -439,10 +439,10 @@ static void dump_journal(char *cmdname, FILE *out_file, blocknr++; WRAP(jsb, blocknr); continue; - + case JFS_REVOKE_BLOCK: dump_revoke_block(out_file, buf, jsb, - blocknr, blocksize, + blocknr, blocksize, transaction); blocknr++; WRAP(jsb, blocknr); @@ -457,10 +457,10 @@ static void dump_journal(char *cmdname, FILE *out_file, } -static void dump_descriptor_block(FILE *out_file, - struct journal_source *source, +static void dump_descriptor_block(FILE *out_file, + struct journal_source *source, char *buf, - journal_superblock_t *jsb, + journal_superblock_t *jsb, unsigned int *blockp, int blocksize, tid_t transaction) { @@ -470,20 +470,20 @@ static void dump_descriptor_block(FILE *out_file, unsigned int blocknr; __u32 tag_block; __u32 tag_flags; - + offset = sizeof(journal_header_t); blocknr = *blockp; - if (dump_all) + if (dump_all) fprintf(out_file, "Dumping descriptor block, sequence %u, at " "block %u:\n", transaction, blocknr); - + ++blocknr; WRAP(jsb, blocknr); - + do { - /* Work out the location of the current tag, and skip to + /* Work out the location of the current tag, and skip to * the next one... */ tagp = &buf[offset]; tag = (journal_block_tag_t *) tagp; @@ -493,40 +493,40 @@ static void dump_descriptor_block(FILE *out_file, end of this block. */ if (offset > blocksize) break; - + tag_block = be32_to_cpu(tag->t_blocknr); tag_flags = be32_to_cpu(tag->t_flags); if (!(tag_flags & JFS_FLAG_SAME_UUID)) offset += 16; - dump_metadata_block(out_file, source, jsb, - blocknr, tag_block, blocksize, + dump_metadata_block(out_file, source, jsb, + blocknr, tag_block, blocksize, transaction); ++blocknr; WRAP(jsb, blocknr); - + } while (!(tag_flags & JFS_FLAG_LAST_TAG)); - + *blockp = blocknr; } static void dump_revoke_block(FILE *out_file, char *buf, - journal_superblock_t *jsb EXT2FS_ATTR((unused)), - unsigned int blocknr, + journal_superblock_t *jsb EXT2FS_ATTR((unused)), + unsigned int blocknr, int blocksize EXT2FS_ATTR((unused)), tid_t transaction) { int offset, max; journal_revoke_header_t *header; unsigned int *entry, rblock; - - if (dump_all) + + if (dump_all) fprintf(out_file, "Dumping revoke block, sequence %u, at " "block %u:\n", transaction, blocknr); - + header = (journal_revoke_header_t *) buf; offset = sizeof(journal_revoke_header_t); max = be32_to_cpu(header->r_count); @@ -551,7 +551,7 @@ static void show_extent(FILE *out_file, int start_extent, int end_extent, __u32 first_block) { if (start_extent >= 0 && first_block != 0) - fprintf(out_file, "(%d+%u): %u ", + fprintf(out_file, "(%d+%u): %u ", start_extent, end_extent-start_extent, first_block); } @@ -564,79 +564,79 @@ static void show_indirect(FILE *out_file, const char *name, __u32 where) static void dump_metadata_block(FILE *out_file, struct journal_source *source, journal_superblock_t *jsb EXT2FS_ATTR((unused)), - unsigned int log_blocknr, - unsigned int fs_blocknr, + unsigned int log_blocknr, + unsigned int fs_blocknr, int blocksize, tid_t transaction) { unsigned int got; int retval; char buf[8192]; - + if (!(dump_all || (fs_blocknr == block_to_dump) || (fs_blocknr == inode_block_to_dump) || (fs_blocknr == bitmap_to_dump))) return; - + fprintf(out_file, " FS block %u logged at ", fs_blocknr); - if (!dump_all) + if (!dump_all) fprintf(out_file, "sequence %u, ", transaction); fprintf(out_file, "journal block %u\n", log_blocknr); - + /* There are two major special cases to parse: - * + * * If this block is a block * bitmap block, we need to give it special treatment so that we * can log any allocates and deallocates which affect the - * block_to_dump query block. - * + * block_to_dump query block. + * * If the block is an inode block for the inode being searched * for, then we need to dump the contents of that inode - * structure symbolically. + * structure symbolically. */ - + if (!(dump_contents && dump_all) && fs_blocknr != block_to_dump - && fs_blocknr != bitmap_to_dump + && fs_blocknr != bitmap_to_dump && fs_blocknr != inode_block_to_dump) return; - - retval = read_journal_block("logdump", source, + + retval = read_journal_block("logdump", source, blocksize * log_blocknr, buf, blocksize, &got); if (retval) return; - + if (fs_blocknr == bitmap_to_dump) { struct ext2_super_block *super; int offset; - + super = current_fs->super; offset = ((fs_blocknr - super->s_first_data_block) % super->s_blocks_per_group); - + fprintf(out_file, " (block bitmap for block %u: " - "block is %s)\n", + "block is %s)\n", block_to_dump, ext2fs_test_bit(offset, buf) ? "SET" : "CLEAR"); } - + if (fs_blocknr == inode_block_to_dump) { struct ext2_inode *inode; int first, prev, this, start_extent, i; - + fprintf(out_file, " (inode block for inode %u):\n", inode_to_dump); - + inode = (struct ext2_inode *) (buf + inode_offset_to_dump); internal_dump_inode(out_file, " ", inode_to_dump, inode, 0); - + /* Dump out the direct/indirect blocks here: * internal_dump_inode can only dump them from the main * on-disk inode, not from the journaled copy of the * inode. */ - + fprintf (out_file, " Blocks: "); first = prev = start_extent = -1; @@ -655,13 +655,13 @@ static void dump_metadata_block(FILE *out_file, struct journal_source *source, show_indirect(out_file, "IND", inode->i_block[i++]); show_indirect(out_file, "DIND", inode->i_block[i++]); show_indirect(out_file, "TIND", inode->i_block[i++]); - + fprintf(out_file, "\n"); } if (dump_contents) do_hexdump(out_file, buf, blocksize); - + } static void do_hexdump (FILE *out_file, char *buf, int blocksize) @@ -670,10 +670,10 @@ static void do_hexdump (FILE *out_file, char *buf, int blocksize) int *intp; char *charp; unsigned char c; - + intp = (int *) buf; charp = (char *) buf; - + for (i=0; i<blocksize; i+=16) { fprintf(out_file, " %04x: ", i); for (j=0; j<16; j+=4) diff --git a/debugfs/ls.c b/debugfs/ls.c index 1ceeb1be..906504e7 100644 --- a/debugfs/ls.c +++ b/debugfs/ls.c @@ -1,6 +1,6 @@ /* * ls.c --- list directories - * + * * Copyright (C) 1997 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. */ @@ -17,7 +17,7 @@ #include <sys/types.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif @@ -40,7 +40,7 @@ struct list_dir_struct { static const char *monstr[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - + static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)), int entry, struct ext2_dir_entry *dirent, @@ -127,7 +127,7 @@ void do_list_dir(int argc, char *argv[]) int c; int flags; struct list_dir_struct ls; - + ls.options = 0; if (check_fs_open(argv[0])) return; diff --git a/debugfs/lsdel.c b/debugfs/lsdel.c index f703c6b3..265753b4 100644 --- a/debugfs/lsdel.c +++ b/debugfs/lsdel.c @@ -1,6 +1,6 @@ /* * lsdel.c --- routines to try to help a user recover a deleted file. - * + * * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 * Theodore Ts'o. This file may be redistributed under the terms of * the GNU Public License. @@ -85,7 +85,7 @@ void do_lsdel(int argc, char **argv) char *tmp; time_t now; FILE *out; - + if (common_args_process(argc, argv, 1, 2, "ls_deleted_inodes", "[secs]", 0)) return; @@ -129,7 +129,7 @@ void do_lsdel(int argc, char **argv) "while starting inode scan"); goto error_out; } - + while (ino) { if ((inode.i_dtime == 0) || (secs && ((unsigned) abs(now - secs) > inode.i_dtime))) @@ -139,7 +139,7 @@ void do_lsdel(int argc, char **argv) lsd.num_blocks = 0; lsd.free_blocks = 0; lsd.bad_blocks = 0; - + retval = ext2fs_block_iterate2(current_fs, ino, BLOCK_FLAG_READ_ONLY, block_buf, lsdel_proc, &lsd); @@ -160,20 +160,20 @@ void do_lsdel(int argc, char **argv) exit(1); } } - + delarray[num_delarray].ino = ino; delarray[num_delarray].mode = inode.i_mode; delarray[num_delarray].uid = inode_uid(inode); delarray[num_delarray].size = inode.i_size; if (!LINUX_S_ISDIR(inode.i_mode)) - delarray[num_delarray].size |= + delarray[num_delarray].size |= ((__u64) inode.i_size_high << 32); delarray[num_delarray].dtime = inode.i_dtime; delarray[num_delarray].num_blocks = lsd.num_blocks; delarray[num_delarray].free_blocks = lsd.free_blocks; num_delarray++; } - + next: do { retval = ext2fs_get_next_inode(scan, &ino, &inode); @@ -186,22 +186,22 @@ void do_lsdel(int argc, char **argv) } out = open_pager(); - + fprintf(out, " Inode Owner Mode Size Blocks Time deleted\n"); - + qsort(delarray, num_delarray, sizeof(struct deleted_info), deleted_info_compare); - + for (i = 0; i < num_delarray; i++) { - fprintf(out, "%6u %6d %6o %6llu %6lld/%6lld %s", + fprintf(out, "%6u %6d %6o %6llu %6lld/%6lld %s", delarray[i].ino, delarray[i].uid, delarray[i].mode, delarray[i].size, - delarray[i].free_blocks, delarray[i].num_blocks, + delarray[i].free_blocks, delarray[i].num_blocks, time_to_string(delarray[i].dtime)); } fprintf(out, "%d deleted inodes found.\n", num_delarray); close_pager(out); - + error_out: free(block_buf); free(delarray); diff --git a/debugfs/ncheck.c b/debugfs/ncheck.c index bb7f5244..3381dd97 100644 --- a/debugfs/ncheck.c +++ b/debugfs/ncheck.c @@ -1,6 +1,6 @@ /* * ncheck.c --- given a list of inodes, generate a list of names - * + * * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. */ @@ -52,7 +52,7 @@ static int ncheck_proc(struct ext2_dir_entry *dirent, } if (!iw->inodes_left) return DIRENT_ABORT; - + return 0; } @@ -66,7 +66,7 @@ void do_ncheck(int argc, char **argv) struct ext2_inode inode; errcode_t retval; char *tmp; - + if (argc < 2) { com_err(argv[0], 0, "Usage: ncheck <inode number> ..."); return; @@ -105,7 +105,7 @@ void do_ncheck(int argc, char **argv) com_err("ncheck", retval, "while starting inode scan"); goto error_out; } - + while (ino) { if (!inode.i_links_count) goto next; @@ -121,7 +121,7 @@ void do_ncheck(int argc, char **argv) iw.position = 0; iw.parent = ino; - + retval = ext2fs_dir_iterate(current_fs, ino, 0, 0, ncheck_proc, &iw); if (retval) { @@ -155,7 +155,7 @@ void do_ncheck(int argc, char **argv) "while resolving pathname for inode %d (%d)", iinfo->parent, iinfo->ino); } - + printf("Inode\tPathname\n"); for (i=0, iinfo = iw.iarray; i < iw.num_inodes; i++, iinfo++) { if (iinfo->parent == 0) { diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c index 25343f0e..f36943a2 100644 --- a/debugfs/set_fields.c +++ b/debugfs/set_fields.c @@ -1,8 +1,8 @@ /* * set_fields.c --- set a superblock value - * + * * Copyright (C) 2000, 2001, 2002, 2003, 2004 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -97,12 +97,12 @@ static struct field_set_info super_fields[] = { { "block_group_nr", &set_sb.s_block_group_nr, 2, parse_uint }, { "feature_compat", &set_sb.s_feature_compat, 4, parse_uint }, { "feature_incompat", &set_sb.s_feature_incompat, 4, parse_uint }, - { "feature_ro_compat", &set_sb.s_feature_ro_compat, 4, parse_uint }, + { "feature_ro_compat", &set_sb.s_feature_ro_compat, 4, parse_uint }, { "uuid", &set_sb.s_uuid, 16, parse_uuid }, { "volume_name", &set_sb.s_volume_name, 16, parse_string }, { "last_mounted", &set_sb.s_last_mounted, 64, parse_string }, { "lastcheck", &set_sb.s_lastcheck, 4, parse_uint }, - { "algorithm_usage_bitmap", &set_sb.s_algorithm_usage_bitmap, + { "algorithm_usage_bitmap", &set_sb.s_algorithm_usage_bitmap, 4, parse_uint }, { "prealloc_blocks", &set_sb.s_prealloc_blocks, 1, parse_uint }, { "prealloc_dir_blocks", &set_sb.s_prealloc_dir_blocks, 1, @@ -120,7 +120,7 @@ static struct field_set_info super_fields[] = { { "default_mount_opts", &set_sb.s_default_mount_opts, 4, parse_uint }, { "first_meta_bg", &set_sb.s_first_meta_bg, 4, parse_uint }, { "mkfs_time", &set_sb.s_mkfs_time, 4, parse_time }, - { "jnl_blocks", &set_sb.s_jnl_blocks[0], 4, parse_uint, FLAG_ARRAY, + { "jnl_blocks", &set_sb.s_jnl_blocks[0], 4, parse_uint, FLAG_ARRAY, 17 }, { "blocks_count_hi", &set_sb.s_blocks_count_hi, 4, parse_uint }, { "r_blocks_count_hi", &set_sb.s_r_blocks_count_hi, 4, parse_uint }, @@ -151,7 +151,7 @@ static struct field_set_info inode_fields[] = { { "flags", &set_inode.i_flags, 4, parse_uint }, { "version", &set_inode.osd1.linux1.l_i_version, 4, parse_uint }, { "translator", &set_inode.osd1.hurd1.h_i_translator, 4, parse_uint }, - { "block", &set_inode.i_block[0], 4, parse_uint, FLAG_ARRAY, + { "block", &set_inode.i_block[0], 4, parse_uint, FLAG_ARRAY, EXT2_NDIR_BLOCKS }, { "block[IND]", &set_inode.i_block[EXT2_IND_BLOCK], 4, parse_uint }, { "block[DIND]", &set_inode.i_block[EXT2_DIND_BLOCK], 4, parse_uint }, @@ -218,7 +218,7 @@ static struct field_set_info *find_field(struct field_set_info *fields, else *delim = 0; } - /* + /* * Can we parse the number? */ if (idx) { @@ -353,7 +353,7 @@ static errcode_t parse_time(struct field_set_info *info, char *arg) static errcode_t parse_uuid(struct field_set_info *info, char *arg) { unsigned char * p = (unsigned char *) info->ptr; - + if ((strcasecmp(arg, "null") == 0) || (strcasecmp(arg, "clear") == 0)) { uuid_clear(p); @@ -397,7 +397,7 @@ static errcode_t parse_bmap(struct field_set_info *info, char *arg) } blk = num; - retval = ext2fs_bmap(current_fs, set_ino, &set_inode, 0, BMAP_SET, + retval = ext2fs_bmap(current_fs, set_ino, &set_inode, 0, BMAP_SET, array_idx, &blk); if (retval) { com_err("set_inode", retval, "while setting block map"); @@ -411,7 +411,7 @@ static errcode_t parse_gd_csum(struct field_set_info *info, char *arg) if (strcmp(arg, "calc") == 0) { ext2fs_group_desc_csum_set(current_fs, set_bg); set_gd = current_fs->group_desc[set_bg]; - printf("Checksum set to 0x%04x\n", + printf("Checksum set to 0x%04x\n", current_fs->group_desc[set_bg].bg_checksum); return 0; } @@ -458,7 +458,7 @@ static void print_possible_fields(struct field_set_info *fields) type = "set physical->logical block map"; strcpy(name, ss->name); if (ss->flags & FLAG_ARRAY) { - if (ss->max_idx > 0) + if (ss->max_idx > 0) sprintf(idx, "[%d]", ss->max_idx); else strcpy(idx, "[]"); @@ -476,7 +476,7 @@ void do_set_super(int argc, char *argv[]) "\t\"set_super_value -l\" will list the names of " "superblock fields\n\twhich can be set."; static struct field_set_info *ss; - + if ((argc == 2) && !strcmp(argv[1], "-l")) { print_possible_fields(super_fields); return; @@ -503,7 +503,7 @@ void do_set_inode(int argc, char *argv[]) "\t\"set_inode_field -l\" will list the names of " "the fields in an ext2 inode\n\twhich can be set."; static struct field_set_info *ss; - + if ((argc == 2) && !strcmp(argv[1], "-l")) { print_possible_fields(inode_fields); return; diff --git a/debugfs/unused.c b/debugfs/unused.c index 0eee8e62..818fef13 100644 --- a/debugfs/unused.c +++ b/debugfs/unused.c @@ -1,6 +1,6 @@ /* * unused.c --- quick and dirty unused space dumper - * + * * Copyright (C) 1997 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. */ @@ -17,7 +17,7 @@ #include <sys/types.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif diff --git a/debugfs/util.c b/debugfs/util.c index 4f9c44a9..e4ecb1fe 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -1,6 +1,6 @@ /* * util.c --- utilities for the debugfs program - * + * * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be * redistributed under the terms of the GNU Public License. * @@ -17,7 +17,7 @@ #include <signal.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif @@ -40,7 +40,7 @@ extern int optreset; /* defined by BSD, but not others */ * affairs is that BSD-derived versions of getopt() misbehave if * optind is set to 0 in order to reset getopt(), and glibc's getopt() * will core dump if optind is set 1 in order to reset getopt(). - * + * * More modern versions of BSD require that optreset be set to 1 in * order to reset getopt(). Sigh. Standards, anyone? * @@ -88,7 +88,7 @@ FILE *open_pager(void) pager = getenv("PAGER"); if (!pager) pager = find_pager(buf); - if (!pager || + if (!pager || (strcmp(pager, "__none__") == 0) || ((outfile = popen(pager, "w")) == 0)) return stdout; @@ -251,7 +251,7 @@ unsigned long parse_ulong(const char *str, const char *cmd, { char *tmp; unsigned long ret; - + ret = strtoul(str, &tmp, 0); if (*tmp == 0) { if (err) @@ -317,9 +317,9 @@ int common_inode_args_process(int argc, char *argv[], { if (common_args_process(argc, argv, 2, 2, argv[0], "<file>", flags)) return 1; - + *inode = string_to_inode(argv[1]); - if (!*inode) + if (!*inode) return 1; return 0; } diff --git a/e2fsck/argv_parse.c b/e2fsck/argv_parse.c index 404d9602..09af765f 100644 --- a/e2fsck/argv_parse.c +++ b/e2fsck/argv_parse.c @@ -1,7 +1,7 @@ /* * argv_parse.c --- utility function for parsing a string into a * argc, argv array. - * + * * This file defines a function argv_parse() which parsing a * passed-in string, handling double quotes and backslashes, and * creates an allocated argv vector which can be freed using the @@ -10,7 +10,7 @@ * See argv_parse.h for the formal definition of the functions. * * Copyright 1999 by Theodore Ts'o. - * + * * Permission to use, copy, modify, and distribute this software for * any purpose with or without fee is hereby granted, provided that * the above copyright notice and this permission notice appear in all diff --git a/e2fsck/argv_parse.h b/e2fsck/argv_parse.h index 84568e7b..86f4564e 100644 --- a/e2fsck/argv_parse.h +++ b/e2fsck/argv_parse.h @@ -3,7 +3,7 @@ * * This file defines the interface for the functions argv_parse() and * argv_free(). - * + * *********************************************************************** * int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv) * @@ -16,12 +16,12 @@ * ret_argc and ret_argv, respectively. *********************************************************************** * extern void argv_free(char **argv); - * + * * This function frees the argument vector created by argv_parse(). *********************************************************************** * * Copyright 1999 by Theodore Ts'o. - * + * * Permission to use, copy, modify, and distribute this software for * any purpose with or without fee is hereby granted, provided that * the above copyright notice and this permission notice appear in all diff --git a/e2fsck/badblocks.c b/e2fsck/badblocks.c index 72f88aa7..87c69953 100644 --- a/e2fsck/badblocks.c +++ b/e2fsck/badblocks.c @@ -1,6 +1,6 @@ /* * badblocks.c --- replace/append bad blocks to the bad block inode - * + * * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be * redistributed under the terms of the GNU Public License. */ @@ -45,7 +45,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, _("while sanity checking the bad blocks inode")); goto fatal; } - + /* * If we're appending to the bad blocks inode, read in the * current bad blocks. @@ -58,7 +58,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, goto fatal; } } - + /* * Now read in the bad blocks from the file; if * bad_blocks_file is null, then try to run the badblocks @@ -84,7 +84,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, } } retval = ext2fs_read_bb_FILE(fs, f, &bb_list, invalid_block); - if (bad_blocks_file) + if (bad_blocks_file) fclose(f); else pclose(f); @@ -93,7 +93,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, _("while reading in list of bad blocks from file")); goto fatal; } - + /* * Finally, update the bad blocks from the bad_block_map */ @@ -107,15 +107,15 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, ext2fs_badblocks_list_free(bb_list); return; - + fatal: ctx->flags |= E2F_FLAG_ABORT; return; - + } -static int check_bb_inode_blocks(ext2_filsys fs, - blk_t *block_nr, +static int check_bb_inode_blocks(ext2_filsys fs, + blk_t *block_nr, int blockcnt EXT2FS_ATTR((unused)), void *priv_data EXT2FS_ATTR((unused))) { diff --git a/e2fsck/dict.c b/e2fsck/dict.c index bccab8bc..722b5b1c 100644 --- a/e2fsck/dict.c +++ b/e2fsck/dict.c @@ -39,7 +39,7 @@ static const char rcsid[] = "$Id: dict.c,v 1.40.2.7 2000/11/13 01:36:44 kaz Exp /* * These macros provide short convenient names for structure members, * which are embellished with dict_ prefixes so that they are - * properly confined to the documented namespace. It's legal for a + * properly confined to the documented namespace. It's legal for a * program which uses dict to define, for instance, a macro called ``parent''. * Such a macro would interfere with the dnode_t struct definition. * In general, highly portable and reusable C modules which expose their @@ -150,7 +150,7 @@ static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil) * dict_next() successor function, verifying that the key of each node is * strictly lower than that of its successor, if duplicates are not allowed, * or lower or equal if duplicates are allowed. This function is used for - * debugging purposes. + * debugging purposes. */ #ifndef NDEBUG static int verify_bintree(dict_t *dict) @@ -209,7 +209,7 @@ static unsigned int verify_redblack(dnode_t *nil, dnode_t *root) if (root->color != dnode_black) return 0; return height_left + 1; - } + } return 1; } @@ -349,7 +349,7 @@ dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp) } #ifdef E2FSCK_NOTUSED -/* +/* * Initialize a dictionary in the likeness of another dictionary */ @@ -389,7 +389,7 @@ static void dict_clear(dict_t *dict) * debugging purposes, and should be placed in assert statements. Just because * this function succeeds doesn't mean that the tree is not corrupt. Certain * corruptions in the tree may simply cause undefined behavior. - */ + */ int dict_verify(dict_t *dict) { @@ -446,7 +446,7 @@ int dict_similar(const dict_t *left, const dict_t *right) /* * Locate a node in the dictionary having the given key. - * If the node is not found, a null a pointer is returned (rather than + * If the node is not found, a null a pointer is returned (rather than * a pointer that dictionary's nil sentinel node), otherwise a pointer to the * located node is returned. */ @@ -511,9 +511,9 @@ dnode_t *dict_lower_bound(dict_t *dict, const void *key) tentative = root; root = root->left; } - } + } } - + return tentative; } @@ -543,9 +543,9 @@ dnode_t *dict_upper_bound(dict_t *dict, const void *key) tentative = root; root = root->right; } - } + } } - + return tentative; } #endif @@ -727,10 +727,10 @@ dnode_t *dict_delete(dict_t *dict, dnode_t *delete) child = (delete->left != nil) ? delete->left : delete->right; - child->parent = delparent = delete->parent; + child->parent = delparent = delete->parent; if (delete == delparent->left) { - delparent->left = child; + delparent->left = child; } else { assert (delete == delparent->right); delparent->right = child; @@ -1058,7 +1058,7 @@ void dict_load_next(dict_load_t *load, dnode_t *newnode, const void *key) { dict_t *dict = load->dictptr; dnode_t *nil = &load->nilnode; - + assert (!dnode_is_in_a_dict(newnode)); assert (dict->nodecount < dict->maxcount); @@ -1164,7 +1164,7 @@ void dict_merge(dict_t *dest, dict_t *source) dict_load_t load; dnode_t *leftnode = dict_first(dest), *rightnode = dict_first(source); - assert (dict_similar(dest, source)); + assert (dict_similar(dest, source)); if (source == dest) return; @@ -1197,7 +1197,7 @@ void dict_merge(dict_t *dest, dict_t *source) leftnode = next; continue; } - + copyright: { dnode_t *next = dict_next(source, rightnode); @@ -1226,7 +1226,7 @@ typedef char input_t[256]; static int tokenize(char *string, ...) { - char **tokptr; + char **tokptr; va_list arglist; int tokcount = 0; @@ -1290,7 +1290,7 @@ static void construct(dict_t *d) dnode_t *dn; char *tok1, *tok2, *val; const char *key; - char *help = + char *help = "p turn prompt on\n" "q finish construction\n" "a <key> <val> add new entry\n"; diff --git a/e2fsck/dx_dirinfo.c b/e2fsck/dx_dirinfo.c index 322f5167..eba6adda 100644 --- a/e2fsck/dx_dirinfo.c +++ b/e2fsck/dx_dirinfo.c @@ -11,7 +11,7 @@ /* * This subroutine is called during pass1 to create a directory info * entry. During pass1, the passed-in parent is 0; it will get filled - * in during pass2. + * in during pass2. */ void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks) { @@ -31,7 +31,7 @@ void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks) * sizeof (struct dx_dir_info), "directory map"); } - + if (ctx->dx_dir_info_count >= ctx->dx_dir_info_size) { old_size = ctx->dx_dir_info_size * sizeof(struct dx_dir_info); ctx->dx_dir_info_size += 10; @@ -59,12 +59,12 @@ void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks) if (ctx->dx_dir_info[i-1].ino < ino) break; dir = &ctx->dx_dir_info[i]; - if (dir->ino != ino) + if (dir->ino != ino) for (j = ctx->dx_dir_info_count++; j > i; j--) ctx->dx_dir_info[j] = ctx->dx_dir_info[j-1]; } else dir = &ctx->dx_dir_info[ctx->dx_dir_info_count++]; - + dir->ino = ino; dir->numblocks = num_blocks; dir->hashversion = 0; @@ -112,7 +112,7 @@ void e2fsck_free_dx_dir_info(e2fsck_t ctx) { int i; struct dx_dir_info *dir; - + if (ctx->dx_dir_info) { dir = ctx->dx_dir_info; for (i=0; i < ctx->dx_dir_info_count; i++) { diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index de2e5325..bfa78fce 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -1,6 +1,6 @@ /* * e2fsck.c - a consistency checker for the new extended file system. - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -15,7 +15,7 @@ #include "problem.h" /* - * This function allocates an e2fsck context + * This function allocates an e2fsck context */ errcode_t e2fsck_allocate_context(e2fsck_t *ret) { @@ -26,13 +26,13 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret) retval = ext2fs_get_mem(sizeof(struct e2fsck_struct), &context); if (retval) return retval; - + memset(context, 0, sizeof(struct e2fsck_struct)); context->process_inode_size = 256; context->ext_attr_ver = 2; context->blocks_per_page = 1; - + time_env = getenv("E2FSCK_TIME"); if (time_env) context->now = strtoul(time_env, NULL, 0); @@ -159,7 +159,7 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx) /* Reset the superblock to the user's requested value */ ctx->superblock = ctx->use_superblock; - + return 0; } @@ -167,7 +167,7 @@ void e2fsck_free_context(e2fsck_t ctx) { if (!ctx) return; - + e2fsck_reset_context(ctx); if (ctx->blkid) blkid_put_cache(ctx->blkid); @@ -177,10 +177,10 @@ void e2fsck_free_context(e2fsck_t ctx) if (ctx->filesystem_name) ext2fs_free_mem(&ctx->filesystem_name); - + if (ctx->device_name) ext2fs_free_mem(&ctx->device_name); - + ext2fs_free_mem(&ctx); } @@ -208,7 +208,7 @@ int e2fsck_run(e2fsck_t ctx) } ctx->flags |= E2F_FLAG_SETJMP_OK; #endif - + for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) { if (ctx->flags & E2F_FLAG_RUN_RETURN) break; @@ -217,7 +217,7 @@ int e2fsck_run(e2fsck_t ctx) (void) (ctx->progress)(ctx, 0, 0, 0); } ctx->flags &= ~E2F_FLAG_SETJMP_OK; - + if (ctx->flags & E2F_FLAG_RUN_RETURN) return (ctx->flags & E2F_FLAG_RUN_RETURN); return 0; diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index 5a4a0de0..53c8f544 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -1,9 +1,9 @@ /* * e2fsck.h - * + * * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be * redistributed under the terms of the GNU Public License. - * + * */ #ifndef _E2FSCK_H @@ -114,9 +114,9 @@ struct dx_dirblock_info { blk_t phys; int flags; blk_t parent; - ext2_dirhash_t min_hash; + ext2_dirhash_t min_hash; ext2_dirhash_t max_hash; - ext2_dirhash_t node_min_hash; + ext2_dirhash_t node_min_hash; ext2_dirhash_t node_max_hash; }; @@ -169,7 +169,7 @@ struct resource_track { #define E2F_FLAG_PROG_BAR 0x0020 /* Progress bar on screen */ #define E2F_FLAG_PROG_SUPPRESS 0x0040 /* Progress suspended */ #define E2F_FLAG_JOURNAL_INODE 0x0080 /* Create a new ext3 journal inode */ -#define E2F_FLAG_SB_SPECIFIED 0x0100 /* The superblock was explicitly +#define E2F_FLAG_SB_SPECIFIED 0x0100 /* The superblock was explicitly * specified by the user */ #define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */ #define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */ @@ -265,7 +265,7 @@ struct e2fsck_struct { */ ext2_ino_t lost_and_found; int bad_lost_and_found; - + /* * Directory information */ @@ -311,7 +311,7 @@ struct e2fsck_struct { unsigned int progress_last_time; int interactive; /* Are we connected directly to a tty? */ char start_meta[2], stop_meta[2]; - + /* File counts */ __u32 fs_directory_count; __u32 fs_regular_count; @@ -386,16 +386,16 @@ extern void e2fsck_add_dir_info(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent) extern void e2fsck_free_dir_info(e2fsck_t ctx); extern int e2fsck_get_num_dirinfo(e2fsck_t ctx); extern struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx); -extern struct dir_info *e2fsck_dir_info_iter(e2fsck_t ctx, +extern struct dir_info *e2fsck_dir_info_iter(e2fsck_t ctx, struct dir_info_iter *); extern void e2fsck_dir_info_iter_end(e2fsck_t ctx, struct dir_info_iter *); -extern int e2fsck_dir_info_set_parent(e2fsck_t ctx, ext2_ino_t ino, +extern int e2fsck_dir_info_set_parent(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent); -extern int e2fsck_dir_info_set_dotdot(e2fsck_t ctx, ext2_ino_t ino, +extern int e2fsck_dir_info_set_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t dotdot); -extern int e2fsck_dir_info_get_parent(e2fsck_t ctx, ext2_ino_t ino, +extern int e2fsck_dir_info_get_parent(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t *parent); -extern int e2fsck_dir_info_get_dotdot(e2fsck_t ctx, ext2_ino_t ino, +extern int e2fsck_dir_info_get_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t *dotdot); /* dx_dirinfo.c */ @@ -431,7 +431,7 @@ extern void e2fsck_move_ext3_journal(e2fsck_t ctx); extern int e2fsck_fix_ext3_journal_hint(e2fsck_t ctx); /* pass1.c */ -extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags, +extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags, ext2_icount_t *ret); extern void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool); extern int e2fsck_pass1_check_device_inode(ext2_filsys fs, @@ -451,7 +451,7 @@ extern int e2fsck_reconnect_file(e2fsck_t ctx, ext2_ino_t inode); extern errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir, int num, int gauranteed_size); extern ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix); -extern errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino, +extern errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino, int adj); diff --git a/e2fsck/ea_refcount.c b/e2fsck/ea_refcount.c index 6420c728..daaedc4b 100644 --- a/e2fsck/ea_refcount.c +++ b/e2fsck/ea_refcount.c @@ -1,6 +1,6 @@ /* * ea_refcount.c - * + * * Copyright (C) 2001 Theodore Ts'o. This file may be * redistributed under the terms of the GNU Public License. */ @@ -18,7 +18,7 @@ * follows. We keep a sorted array of first EA blocks and its * reference counts. Once the refcount has dropped to zero, it is * removed from the array to save memory space. Once the EA block is - * checked, its bit is set in the block_ea_map bitmap. + * checked, its bit is set in the block_ea_map bitmap. */ struct ea_refcount_el { blk_t ea_blk; @@ -118,7 +118,7 @@ static struct ea_refcount_el *insert_refcount_el(ext2_refcount_t refcount, new_size = refcount->size + 100; #ifdef DEBUG printf("Reallocating refcount %d entries...\n", new_size); -#endif +#endif retval = ext2fs_resize_mem((size_t) refcount->size * sizeof(struct ea_refcount_el), (size_t) new_size * @@ -170,7 +170,7 @@ retry: } if (refcount->count == 0) return 0; - + if (refcount->cursor >= refcount->count) refcount->cursor = 0; if (blk == refcount->list[refcount->cursor].ea_blk) @@ -193,7 +193,7 @@ retry: range = 0; else if (blk > highval) range = 1; - else + else range = ((float) (blk - lowval)) / (highval - lowval); mid = low + ((int) (range * (high-low))); @@ -227,7 +227,7 @@ errcode_t ea_refcount_fetch(ext2_refcount_t refcount, blk_t blk, int *ret) { struct ea_refcount_el *el; - + el = get_refcount_el(refcount, blk, 0); if (!el) { *ret = 0; @@ -298,7 +298,7 @@ blk_t ea_refcount_intr_next(ext2_refcount_t refcount, int *ret) { struct ea_refcount_el *list; - + while (1) { if (refcount->cursor >= refcount->count) return 0; @@ -320,7 +320,7 @@ errcode_t ea_refcount_validate(ext2_refcount_t refcount, FILE *out) errcode_t ret = 0; int i; const char *bad = "bad refcount"; - + if (refcount->count > refcount->size) { fprintf(out, "%s: count > size\n", bad); return EXT2_ET_INVALID_ARGUMENT; @@ -460,7 +460,7 @@ int main(int argc, char **argv) case BCODE_LIST: ea_refcount_intr_begin(refcount); while (1) { - blk = ea_refcount_intr_next(refcount, + blk = ea_refcount_intr_next(refcount, &arg); if (!blk) break; @@ -472,7 +472,7 @@ int main(int argc, char **argv) refcount_collapse(refcount); break; } - + } } diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c index 16d6d4fa..7bae4abd 100644 --- a/e2fsck/ehandler.c +++ b/e2fsck/ehandler.c @@ -1,7 +1,7 @@ /* * ehandler.c --- handle bad block errors which come up during the * course of an e2fsck session. - * + * * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed * under the terms of the GNU Public License. */ @@ -77,7 +77,7 @@ static errcode_t e2fsck_handle_write_error(io_channel channel, const char *p; ext2_filsys fs = (ext2_filsys) channel->app_data; e2fsck_t ctx; - + ctx = (e2fsck_t) fs->priv_data; /* @@ -95,7 +95,7 @@ static errcode_t e2fsck_handle_write_error(io_channel channel, } return 0; } - + if (operation) printf(_("Error writing block %lu (%s) while %s. "), block, error_message(error), operation); diff --git a/e2fsck/emptydir.c b/e2fsck/emptydir.c index 6baab76e..e03db564 100644 --- a/e2fsck/emptydir.c +++ b/e2fsck/emptydir.c @@ -1,6 +1,6 @@ /* * emptydir.c --- clear empty directory blocks - * + * * Copyright (C) 1998 Theodore Ts'o * * %Begin-Header% @@ -52,7 +52,7 @@ empty_dir_info init_empty_dir(e2fsck_t ctx) retval = ext2fs_init_dblist(ctx->fs, &edi->empty_dblist); if (retval) goto errout; - + retval = ext2fs_allocate_block_bitmap(ctx->fs, _("empty dirblocks"), &edi->empty_dir_blocks); if (retval) @@ -122,7 +122,7 @@ int empty_pass1(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, empty_dir_info edi = (empty_dir_info) priv_data; blk_t block, new_block; errcode_t retval; - + if (blockcnt < 0) return 0; block = *block_nr; @@ -150,7 +150,7 @@ static int fix_directory(ext2_filsys fs, void *priv_data) { errcode_t retval; - + empty_dir_info edi = (empty_dir_info) priv_data; edi->logblk = 0; diff --git a/e2fsck/extend.c b/e2fsck/extend.c index 3a92c0ed..2a849b21 100644 --- a/e2fsck/extend.c +++ b/e2fsck/extend.c @@ -1,7 +1,7 @@ /* * extend.c --- extend a file so that it has at least a specified * number of blocks. - * + * * Copyright (C) 1993, 1994, 1995 Theodore Ts'o. * * This file may be redistributed under the terms of the GNU Public diff --git a/e2fsck/flushb.c b/e2fsck/flushb.c index c2075502..95ca6f8d 100644 --- a/e2fsck/flushb.c +++ b/e2fsck/flushb.c @@ -2,7 +2,7 @@ * flushb.c --- This routine flushes the disk buffers for a disk * * Copyright 1997, 2000, by Theodore Ts'o. - * + * * WARNING: use of flushb on some older 2.2 kernels on a heavily loaded * system will corrupt filesystems. This program is not really useful * beyond for benchmarking scripts. @@ -33,12 +33,12 @@ static void usage(void) { fprintf(stderr, _("Usage: %s disk\n"), progname); exit(1); -} - +} + int main(int argc, char **argv) { int fd; - + progname = argv[0]; if (argc != 2) usage(); diff --git a/e2fsck/iscan.c b/e2fsck/iscan.c index 7e1bbd30..e9fa0763 100644 --- a/e2fsck/iscan.c +++ b/e2fsck/iscan.c @@ -60,7 +60,7 @@ static void PRS(int argc, char *argv[]) setbuf(stdout, NULL); setbuf(stderr, NULL); initialize_ext2_error_table(); - + if (argc && *argv) program_name = *argv; while ((c = getopt (argc, argv, "FI")) != EOF) @@ -91,7 +91,7 @@ static void PRS(int argc, char *argv[]) close(fd); } } - + int main (int argc, char *argv[]) { errcode_t retval = 0; @@ -101,7 +101,7 @@ int main (int argc, char *argv[]) __u32 num_inodes = 0; struct ext2_inode inode; ext2_inode_scan scan; - + init_resource_track(&global_rtrack); PRS(argc, argv); @@ -115,7 +115,7 @@ int main (int argc, char *argv[]) } ehandler_init(fs->io); - + retval = ext2fs_open_inode_scan(fs, inode_buffer_blocks, &scan); if (retval) { com_err(program_name, retval, _("while opening inode scan")); @@ -133,9 +133,9 @@ int main (int argc, char *argv[]) break; num_inodes++; } - + print_resource_track(NULL, &global_rtrack); printf(_("%u inodes scanned.\n"), num_inodes); - + exit(0); } diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h index f9e32b23..0e4f9518 100644 --- a/e2fsck/jfs_user.h +++ b/e2fsck/jfs_user.h @@ -45,7 +45,7 @@ typedef struct kdev_s *kdev_t; #define unlock_buffer(bh) do {} while(0) #define buffer_req(bh) 1 #define do_readahead(journal, start) do {} while(0) - + extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ typedef struct { @@ -72,12 +72,12 @@ typedef unsigned int __be32; /* * We use the standard libext2fs portability tricks for inline - * functions. + * functions. */ extern lkmem_cache_t * do_cache_create(int len); extern void do_cache_destroy(lkmem_cache_t *cache); extern size_t journal_tag_bytes(journal_t *journal); - + #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) #ifdef E2FSCK_INCLUDE_INLINE_FUNCS #define _INLINE_ extern diff --git a/e2fsck/journal.c b/e2fsck/journal.c index b701d19d..10f5095f 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -58,7 +58,7 @@ int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys) return 0; } - retval= ext2fs_bmap(inode->i_ctx->fs, inode->i_ino, + retval= ext2fs_bmap(inode->i_ctx->fs, inode->i_ino, &inode->i_ext2, NULL, 0, block, &pblk); *phys = pblk; return (retval); @@ -83,7 +83,7 @@ struct buffer_head *getblk(kdev_t kdev, blk_t blocknr, int blocksize) bh->b_ctx = kdev->k_ctx; if (kdev->k_dev == K_DEV_FS) bh->b_io = kdev->k_ctx->fs->io; - else + else bh->b_io = kdev->k_ctx->journal_io; bh->b_size = blocksize; bh->b_blocknr = blocknr; @@ -97,7 +97,7 @@ void sync_blockdev(kdev_t kdev) if (kdev->k_dev == K_DEV_FS) io = kdev->k_ctx->fs->io; - else + else io = kdev->k_ctx->journal_io; io_channel_flush(io); @@ -111,28 +111,28 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) for (; nr > 0; --nr) { bh = *bhp++; if (rw == READ && !bh->b_uptodate) { - jfs_debug(3, "reading block %lu/%p\n", + jfs_debug(3, "reading block %lu/%p\n", (unsigned long) bh->b_blocknr, (void *) bh); - retval = io_channel_read_blk(bh->b_io, + retval = io_channel_read_blk(bh->b_io, bh->b_blocknr, 1, bh->b_data); if (retval) { com_err(bh->b_ctx->device_name, retval, - "while reading block %lu\n", + "while reading block %lu\n", (unsigned long) bh->b_blocknr); bh->b_err = retval; continue; } bh->b_uptodate = 1; } else if (rw == WRITE && bh->b_dirty) { - jfs_debug(3, "writing block %lu/%p\n", + jfs_debug(3, "writing block %lu/%p\n", (unsigned long) bh->b_blocknr, (void *) bh); - retval = io_channel_write_blk(bh->b_io, + retval = io_channel_write_blk(bh->b_io, bh->b_blocknr, 1, bh->b_data); if (retval) { com_err(bh->b_ctx->device_name, retval, - "while writing block %lu\n", + "while writing block %lu\n", (unsigned long) bh->b_blocknr); bh->b_err = retval; continue; @@ -141,7 +141,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) bh->b_uptodate = 1; } else { jfs_debug(3, "no-op %s for block %lu\n", - rw == READ ? "read" : "write", + rw == READ ? "read" : "write", (unsigned long) bh->b_blocknr); } } @@ -284,7 +284,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) tried_backup_jnl) goto errout; memset(&j_inode->i_ext2, 0, sizeof(struct ext2_inode)); - memcpy(&j_inode->i_ext2.i_block[0], sb->s_jnl_blocks, + memcpy(&j_inode->i_ext2.i_block[0], sb->s_jnl_blocks, EXT2_N_BLOCKS*4); j_inode->i_ext2.i_size = sb->s_jnl_blocks[16]; j_inode->i_ext2.i_links_count = 1; @@ -306,9 +306,9 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) } pb.last_block = -1; retval = ext2fs_block_iterate2(ctx->fs, j_inode->i_ino, - BLOCK_FLAG_HOLE, 0, + BLOCK_FLAG_HOLE, 0, process_journal_block, &pb); - if ((pb.last_block+1) * ctx->fs->blocksize < + if ((pb.last_block+1) * ctx->fs->blocksize < j_inode->i_ext2.i_size) { retval = EXT2_ET_JOURNAL_TOO_SMALL; goto try_backup_journal; @@ -390,7 +390,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) sizeof(jsuper)); brelse(bh); #ifdef WORDS_BIGENDIAN - if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) + if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) ext2fs_swap_super(&jsuper); #endif if (jsuper.s_magic != EXT2_SUPER_MAGIC || @@ -520,7 +520,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal) jsb->s_nr_users) clear_v2_journal_fields(journal); break; - + case JFS_SUPERBLOCK_V2: journal->j_format_version = 2; if (ntohl(jsb->s_nr_users) > 1 && @@ -540,7 +540,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal) case JFS_COMMIT_BLOCK: case JFS_REVOKE_BLOCK: return EXT2_ET_CORRUPT_SUPERBLOCK; - + /* If we don't understand the superblock major type, but there * is a magic number, then it is likely to be a new format we * just don't understand, so leave it alone. */ @@ -550,7 +550,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal) if (JFS_HAS_INCOMPAT_FEATURE(journal, ~JFS_KNOWN_INCOMPAT_FEATURES)) return EXT2_ET_UNSUPP_FEATURE; - + if (JFS_HAS_RO_COMPAT_FEATURE(journal, ~JFS_KNOWN_ROCOMPAT_FEATURES)) return EXT2_ET_RO_UNSUPP_FEATURE; @@ -596,7 +596,7 @@ static void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb, /* Leave a valid existing V1 superblock signature alone. * Anything unrecognisable we overwrite with a new V2 * signature. */ - + if (jsb->s_header.h_magic != htonl(JFS_MAGIC_NUMBER) || jsb->s_header.h_blocktype != htonl(JFS_SUPERBLOCK_V1)) { jsb->s_header.h_magic = htonl(JFS_MAGIC_NUMBER); @@ -604,7 +604,7 @@ static void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb, } /* Zero out everything else beyond the superblock header */ - + p = ((char *) jsb) + sizeof(journal_header_t); memset (p, 0, ctx->fs->blocksize-sizeof(journal_header_t)); @@ -670,7 +670,7 @@ static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal, io_channel_close(ctx->journal_io); ctx->journal_io = 0; } - + #ifndef USE_INODE_IO if (journal->j_inode) ext2fs_free_mem(&journal->j_inode); @@ -788,7 +788,7 @@ no_has_journal: * ignore the fact that journal apparently has data; * accidentally replaying over valid data would be far * worse than skipping a questionable recovery. - * + * * XXX should we abort with a fatal error here? What * will the ext3 kernel code do if a filesystem with * !NEEDS_RECOVERY but with a non-zero @@ -820,11 +820,11 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx) retval = journal_init_revoke(journal, 1024); if (retval) goto errout; - + retval = -journal_recover(journal); if (retval) goto errout; - + if (journal->j_failed_commit) { pctx.ino = journal->j_failed_commit; fix_problem(ctx, PR_0_JNL_TXN_CORRUPT, &pctx); @@ -839,7 +839,7 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx) journal->j_superblock->s_errno = 0; mark_buffer_dirty(journal->j_sb_buffer); } - + errout: journal_destroy_revoke(journal); journal_destroy_revoke_caches(); @@ -864,7 +864,7 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx) ext2fs_flush(ctx->fs); /* Force out any modifications */ recover_retval = recover_ext3_journal(ctx); - + /* * Reload the filesystem context to get up-to-date data from disk * because journal recovery will change the filesystem under us. @@ -906,7 +906,7 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx) errcode_t retval; const char * const * cpp; int group, mount_flags; - + clear_problem_context(&pctx); /* @@ -945,7 +945,7 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx) */ if (sb->s_journal_inum == EXT2_JOURNAL_INO) return; - + /* * The journal inode had better have only one link and not be readable. */ @@ -981,7 +981,7 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx) pctx.str = *cpp; if (!fix_problem(ctx, PR_0_MOVE_JOURNAL, &pctx)) return; - + /* * OK, we've done all the checks, let's actually move the * journal inode. Errors at this point mean we need to force diff --git a/e2fsck/message.c b/e2fsck/message.c index 47366716..f79b73c4 100644 --- a/e2fsck/message.c +++ b/e2fsck/message.c @@ -76,7 +76,7 @@ * @o orphaned * @p problem in * @r root inode - * @s should be + * @s should be * @S superblock * @u unattached * @v device @@ -199,7 +199,7 @@ static void print_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino) fputs(_(special_inode_name[ino]), stdout); return; } - + retval = ext2fs_get_pathname(fs, dir, ino, &path); if (retval) fputs("???", stdout); @@ -212,14 +212,14 @@ static void print_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino) /* * This function handles the '@' expansion. We allow recursive * expansion; an @ expression can contain further '@' and '%' - * expressions. + * expressions. */ static _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch, struct problem_context *pctx, int *first, int recurse) { const char **cpp, *str; - + /* Search for the abbreviation */ for (cpp = abbrevs; *cpp; cpp++) { if (ch == *cpp[0]) @@ -239,7 +239,7 @@ static _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch, /* * This function expands '%IX' expressions */ -static _INLINE_ void expand_inode_expression(char ch, +static _INLINE_ void expand_inode_expression(char ch, struct problem_context *ctx) { struct ext2_inode *inode; @@ -250,7 +250,7 @@ static _INLINE_ void expand_inode_expression(char ch, if (!ctx || !ctx->inode) goto no_inode; - + inode = ctx->inode; large_inode = (struct ext2_inode_large *) inode; @@ -317,17 +317,17 @@ static _INLINE_ void expand_inode_expression(char ch, printf("%d", inode_gid(*inode)); break; case 't': - if (LINUX_S_ISREG(inode->i_mode)) + if (LINUX_S_ISREG(inode->i_mode)) printf(_("regular file")); - else if (LINUX_S_ISDIR(inode->i_mode)) + else if (LINUX_S_ISDIR(inode->i_mode)) printf(_("directory")); - else if (LINUX_S_ISCHR(inode->i_mode)) + else if (LINUX_S_ISCHR(inode->i_mode)) printf(_("character device")); - else if (LINUX_S_ISBLK(inode->i_mode)) + else if (LINUX_S_ISBLK(inode->i_mode)) printf(_("block device")); - else if (LINUX_S_ISFIFO(inode->i_mode)) + else if (LINUX_S_ISFIFO(inode->i_mode)) printf(_("named pipe")); - else if (LINUX_S_ISLNK(inode->i_mode)) + else if (LINUX_S_ISLNK(inode->i_mode)) printf(_("symbolic link")); else if (LINUX_S_ISSOCK(inode->i_mode)) printf(_("socket")); @@ -350,12 +350,12 @@ static _INLINE_ void expand_dirent_expression(char ch, { struct ext2_dir_entry *dirent; int len; - + if (!ctx || !ctx->dirent) goto no_dirent; - + dirent = ctx->dirent; - + switch (ch) { case 'i': printf("%u", dirent->inode); @@ -389,7 +389,7 @@ static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch, { if (!ctx) goto no_context; - + switch (ch) { case '%': fputc('%', stdout); @@ -468,7 +468,7 @@ static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch, printf("%%%c", ch); break; } -} +} void print_e2fsck_message(e2fsck_t ctx, const char *msg, struct problem_context *pctx, int first, diff --git a/e2fsck/mtrace.c b/e2fsck/mtrace.c index 0e03247d..f34f19a9 100644 --- a/e2fsck/mtrace.c +++ b/e2fsck/mtrace.c @@ -47,7 +47,7 @@ static __ptr_t (*tr_old_malloc_hook) __P ((size_t size)); static __ptr_t (*tr_old_realloc_hook) __P ((__ptr_t ptr, size_t size)); /* - * Added by TYT, 10/10/93 --- so that we can print + * Added by TYT, 10/10/93 --- so that we can print */ FILE *malloc_get_mallstream() { diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index f2f72edd..8bbf7feb 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1,13 +1,13 @@ /* * pass1.c -- pass #1 of e2fsck: sequential scan of the inode table - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * Pass 1 of e2fsck iterates over all the inodes in the filesystems, * and applies the following tests to each inode: * @@ -56,7 +56,7 @@ #endif static int process_block(ext2_filsys fs, blk_t *blocknr, - e2_blkcnt_t blockcnt, blk_t ref_blk, + e2_blkcnt_t blockcnt, blk_t ref_blk, int ref_offset, void *priv_data); static int process_bad_block(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, blk_t ref_blk, @@ -72,7 +72,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf); static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b); static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan, dgrp_t group, void * priv_data); -static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, +static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, char *block_buf, int adjust_sign); /* static char *describe_illegal_block(ext2_filsys fs, blk_t block); */ @@ -126,9 +126,9 @@ static void unwind_pass1(ext2_filsys fs EXT2FS_ATTR((unused))) * * Note: this routine is now also used to check FIFO's and Sockets, * since they have the same requirement; the i_block fields should be - * zero. + * zero. */ -int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)), +int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)), struct ext2_inode *inode) { int i; @@ -152,7 +152,7 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)), * the kernel has been fixed we can change this... */ if (inode->i_flags & (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL)) { - for (i=4; i < EXT2_N_BLOCKS; i++) + for (i=4; i < EXT2_N_BLOCKS; i++) if (inode->i_block[i]) return 0; } @@ -254,18 +254,18 @@ static void check_immutable(e2fsck_t ctx, struct problem_context *pctx) static void check_size(e2fsck_t ctx, struct problem_context *pctx) { struct ext2_inode *inode = pctx->inode; - + if ((inode->i_size == 0) && (inode->i_size_high == 0)) return; - + if (!fix_problem(ctx, PR_1_SET_NONZSIZE, pctx)) return; - + inode->i_size = 0; inode->i_size_high = 0; e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1"); } - + static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx) { struct ext2_super_block *sb = ctx->fs->super; @@ -286,14 +286,14 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx) /* scan all entry's headers first */ /* take finish entry 0UL into account */ - remain = storage_size - sizeof(__u32); + remain = storage_size - sizeof(__u32); while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { __u32 hash; /* header eats this space */ remain -= sizeof(struct ext2_ext_attr_entry); - + /* is attribute name valid? */ if (EXT2_EXT_ATTR_SIZE(entry->e_name_len) > remain) { pctx->num = entry->e_name_len; @@ -362,11 +362,11 @@ static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx) #if 0 printf("inode #%u, i_extra_size %d\n", pctx->ino, inode->i_extra_isize); -#endif +#endif /* i_extra_isize must cover i_extra_isize + i_pad1 at least */ min = sizeof(inode->i_extra_isize) + sizeof(inode->i_pad1); max = EXT2_INODE_SIZE(sb) - EXT2_GOOD_OLD_INODE_SIZE; - /* + /* * For now we will allow i_extra_isize to be 0, but really * implementations should never allow i_extra_isize to be 0 */ @@ -388,7 +388,7 @@ static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx) } } -/* +/* * Check to see if the inode might really be a directory, despite i_mode * * This is a lot of complexity for something for which I'm not really @@ -423,7 +423,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx, return; /* Invalid block, can't be dir */ } - if ((LINUX_S_ISCHR(inode->i_mode) || LINUX_S_ISBLK(inode->i_mode)) && + if ((LINUX_S_ISCHR(inode->i_mode) || LINUX_S_ISBLK(inode->i_mode)) && (inode->i_links_count == 1) && !not_device) return; @@ -456,13 +456,13 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx, if (fix_problem(ctx, PR_1_TREAT_AS_DIRECTORY, pctx)) { inode->i_mode = (inode->i_mode & 07777) | LINUX_S_IFDIR; - e2fsck_write_inode_full(ctx, pctx->ino, inode, - EXT2_INODE_SIZE(ctx->fs->super), + e2fsck_write_inode_full(ctx, pctx->ino, inode, + EXT2_INODE_SIZE(ctx->fs->super), "check_is_really_dir"); } } -extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags, +extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags, ext2_icount_t *ret) { unsigned int threshold; @@ -513,7 +513,7 @@ void e2fsck_pass1(e2fsck_t ctx) int imagic_fs, extent_fs; int busted_fs_time = 0; int inode_size; - + #ifdef RESOURCE_TRACK init_resource_track(&rtrack, ctx->fs->io); #endif @@ -628,7 +628,7 @@ void e2fsck_pass1(e2fsck_t ctx) "block interate buffer"); e2fsck_use_inode_shortcuts(ctx, 1); old_op = ehandler_operation(_("opening inode scan")); - pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks, + pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks, &scan); ehandler_operation(old_op); if (pctx.errcode) { @@ -652,7 +652,7 @@ void e2fsck_pass1(e2fsck_t ctx) while (1) { old_op = ehandler_operation(_("getting next inode from scan")); - pctx.errcode = ext2fs_get_next_inode_full(scan, &ino, + pctx.errcode = ext2fs_get_next_inode_full(scan, &ino, inode, inode_size); ehandler_operation(old_op); if (ctx->flags & E2F_FLAG_SIGNAL_MASK) @@ -675,7 +675,7 @@ void e2fsck_pass1(e2fsck_t ctx) pctx.inode = inode; ctx->stashed_ino = ino; if (inode->i_links_count) { - pctx.errcode = ext2fs_icount_store(ctx->inode_link_info, + pctx.errcode = ext2fs_icount_store(ctx->inode_link_info, ino, inode->i_links_count); if (pctx.errcode) { pctx.num = inode->i_links_count; @@ -700,10 +700,10 @@ void e2fsck_pass1(e2fsck_t ctx) * extent_header_verify is ok. If the inode is cleared, * no need to swap... so no extra swapping here. */ - if ((inode->i_flags & EXT4_EXTENTS_FL) && !extent_fs && + if ((inode->i_flags & EXT4_EXTENTS_FL) && !extent_fs && (inode->i_links_count || (ino == EXT2_BAD_INO) || (ino == EXT2_ROOT_INO) || (ino == EXT2_JOURNAL_INO))) { - if ((ext2fs_extent_header_verify(inode->i_block, + if ((ext2fs_extent_header_verify(inode->i_block, sizeof(inode->i_block)) == 0) && fix_problem(ctx, PR_1_EXTENT_FEATURE, &pctx)) { sb->s_feature_incompat |= EXT3_FEATURE_INCOMPAT_EXTENTS; @@ -713,7 +713,7 @@ void e2fsck_pass1(e2fsck_t ctx) clear_inode: e2fsck_clear_inode(ctx, ino, inode, 0, "pass1"); if (ino == EXT2_BAD_INO) - ext2fs_mark_inode_bitmap(ctx->inode_used_map, + ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino); continue; } @@ -742,12 +742,12 @@ void e2fsck_pass1(e2fsck_t ctx) #else ehp = inode->i_block; #endif - if ((ext2fs_extent_header_verify(ehp, + if ((ext2fs_extent_header_verify(ehp, sizeof(inode->i_block)) == 0) && (fix_problem(ctx, PR_1_UNSET_EXTENT_FL, &pctx))) { inode->i_flags |= EXT4_EXTENTS_FL; #ifdef WORDS_BIGENDIAN - memcpy(inode->i_block, tmp_block, + memcpy(inode->i_block, tmp_block, sizeof(inode->i_block)); #endif e2fsck_write_inode(ctx, ino, inode, "pass1"); @@ -756,7 +756,7 @@ void e2fsck_pass1(e2fsck_t ctx) if (ino == EXT2_BAD_INO) { struct process_block_struct pb; - + pctx.errcode = ext2fs_copy_bitmap(ctx->block_found_map, &pb.fs_meta_blocks); if (pctx.errcode) { @@ -773,7 +773,7 @@ void e2fsck_pass1(e2fsck_t ctx) pb.inode = inode; pb.pctx = &pctx; pb.ctx = ctx; - pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, + pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, block_buf, process_bad_block, &pb); ext2fs_free_block_bitmap(pb.fs_meta_blocks); if (pctx.errcode) { @@ -830,17 +830,17 @@ void e2fsck_pass1(e2fsck_t ctx) } if ((inode->i_links_count || inode->i_blocks || inode->i_blocks || inode->i_block[0]) && - fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR, + fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR, &pctx)) { memset(inode, 0, inode_size); ext2fs_icount_store(ctx->inode_link_info, ino, 0); - e2fsck_write_inode_full(ctx, ino, inode, + e2fsck_write_inode_full(ctx, ino, inode, inode_size, "pass1"); } } else if (ino < EXT2_FIRST_INODE(fs->super)) { int problem = 0; - + ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino); if (ino == EXT2_BOOT_LOADER_INO) { if (LINUX_S_ISDIR(inode->i_mode)) @@ -868,7 +868,7 @@ void e2fsck_pass1(e2fsck_t ctx) * orphaned list linked list. They should have gotten * dealt with by now, unless the list had somehow been * corrupted. - * + * * FIXME: In the future, inodes which are still in use * (and which are therefore) pending truncation should * be handled specially. Right now we just clear the @@ -889,10 +889,10 @@ void e2fsck_pass1(e2fsck_t ctx) "pass1"); } } - + /* * This code assumes that deleted inodes have - * i_links_count set to 0. + * i_links_count set to 0. */ if (!inode->i_links_count) { if (!inode->i_dtime && inode->i_mode) { @@ -913,7 +913,7 @@ void e2fsck_pass1(e2fsck_t ctx) * we now assume that the case of non-zero * i_links_count and non-zero dtime means that we * should keep the file, not delete it. - * + * */ if (inode->i_dtime) { if (fix_problem(ctx, PR_1_SET_DTIME, &pctx)) { @@ -921,7 +921,7 @@ void e2fsck_pass1(e2fsck_t ctx) e2fsck_write_inode(ctx, ino, inode, "pass1"); } } - + ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino); switch (fs->super->s_creator_os) { case EXT2_OS_HURD: @@ -931,12 +931,12 @@ void e2fsck_pass1(e2fsck_t ctx) default: frag = fsize = 0; } - + if (inode->i_faddr || frag || fsize || (LINUX_S_ISDIR(inode->i_mode) && inode->i_dir_acl)) mark_inode_bad(ctx, ino); if ((fs->super->s_creator_os == EXT2_OS_LINUX) && - !(fs->super->s_feature_ro_compat & + !(fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) && (inode->osd2.linux2.l_i_blocks_hi != 0)) mark_inode_bad(ctx, ino); @@ -988,7 +988,7 @@ void e2fsck_pass1(e2fsck_t ctx) check_size(ctx, &pctx); ctx->fs_blockdev_count++; } else if (LINUX_S_ISLNK (inode->i_mode) && - e2fsck_pass1_check_symlink(fs, ino, inode, + e2fsck_pass1_check_symlink(fs, ino, inode, block_buf)) { check_immutable(ctx, &pctx); ctx->fs_symlinks_count++; @@ -1058,7 +1058,7 @@ void e2fsck_pass1(e2fsck_t ctx) ea_refcount_free(ctx->refcount_extra); ctx->refcount_extra = 0; } - + if (ctx->invalid_bitmaps) handle_fs_bad_blocks(ctx); @@ -1084,12 +1084,12 @@ void e2fsck_pass1(e2fsck_t ctx) e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode, "recreate inode"); inode->i_mtime = ctx->now; - e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode, + e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode, "recreate inode"); fs->block_map = save_bmap; ctx->flags &= ~E2F_FLAG_RESIZE_INODE; } - + if (ctx->flags & E2F_FLAG_RESTART) { /* * Only the master copy of the superblock and block @@ -1112,7 +1112,7 @@ void e2fsck_pass1(e2fsck_t ctx) ext2fs_free_mem(&inodes_to_process); endit: e2fsck_use_inode_shortcuts(ctx, 0); - + ext2fs_free_mem(&block_buf); ext2fs_free_mem(&inode); @@ -1128,7 +1128,7 @@ endit: * When the inode_scan routines call this callback at the end of the * glock group, call process_inodes. */ -static errcode_t scan_callback(ext2_filsys fs, +static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan EXT2FS_ATTR((unused)), dgrp_t group, void * priv_data) { @@ -1137,7 +1137,7 @@ static errcode_t scan_callback(ext2_filsys fs, scan_struct = (struct scan_callback_struct *) priv_data; ctx = scan_struct->ctx; - + process_inodes((e2fsck_t) fs->priv_data, scan_struct->block_buf); if (ctx->progress) @@ -1159,7 +1159,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf) const char *old_operation; char buf[80]; struct problem_context pctx; - + #if 0 printf("begin process_inodes: "); #endif @@ -1174,7 +1174,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf) for (i=0; i < process_inode_count; i++) { pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode; pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino; - + #if 0 printf("%u ", pctx.ino); #endif @@ -1201,7 +1201,7 @@ static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b) const struct process_inode_block *ib_b = (const struct process_inode_block *) b; int ret; - + ret = (ib_a->inode.i_block[EXT2_IND_BLOCK] - ib_b->inode.i_block[EXT2_IND_BLOCK]); if (ret == 0) @@ -1218,7 +1218,7 @@ static void mark_inode_bad(e2fsck_t ctx, ino_t ino) if (!ctx->inode_bad_map) { clear_problem_context(&pctx); - + pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs, _("bad inode map"), &ctx->inode_bad_map); if (pctx.errcode) { @@ -1239,7 +1239,7 @@ static void mark_inode_bad(e2fsck_t ctx, ino_t ino) static void alloc_bb_map(e2fsck_t ctx) { struct problem_context pctx; - + clear_problem_context(&pctx); pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs, _("inode in bad block map"), @@ -1259,7 +1259,7 @@ static void alloc_bb_map(e2fsck_t ctx) static void alloc_imagic_map(e2fsck_t ctx) { struct problem_context pctx; - + clear_problem_context(&pctx); pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs, _("imagic inode map"), @@ -1283,9 +1283,9 @@ static void alloc_imagic_map(e2fsck_t ctx) static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block) { struct problem_context pctx; - + clear_problem_context(&pctx); - + if (ext2fs_fast_test_block_bitmap(ctx->block_found_map, block)) { if (!ctx->block_dup_map) { pctx.errcode = ext2fs_allocate_block_bitmap(ctx->fs, @@ -1293,7 +1293,7 @@ static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block) &ctx->block_dup_map); if (pctx.errcode) { pctx.num = 3; - fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, + fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx); /* Should never get here */ ctx->flags |= E2F_FLAG_ABORT; @@ -1313,7 +1313,7 @@ static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block) * EA blocks that had extra references as accounted for in * ctx->refcount_extra. */ -static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, +static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, char *block_buf, int adjust_sign) { struct ext2_ext_attr_header *header; @@ -1324,7 +1324,7 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, int count; clear_problem_context(&pctx); - + ea_refcount_intr_begin(refcount); while (1) { if ((blk = ea_refcount_intr_next(refcount, &count)) == 0) @@ -1566,7 +1566,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx, retval = io_channel_read_blk(fs->io, blk, 1, block_buf); if (retval && fix_problem(ctx, PR_1_HTREE_BADROOT, pctx)) return 1; - + /* XXX should check that beginning matches a directory */ root = (struct ext2_dx_root_info *) (block_buf + 24); @@ -1580,7 +1580,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx, (root->hash_version != EXT2_HASH_TEA) && fix_problem(ctx, PR_1_HTREE_HASHV, pctx)) return 1; - + if ((root->unused_flags & EXT2_HASH_FLAG_INCOMPAT) && fix_problem(ctx, PR_1_HTREE_INCOMPAT, pctx)) return 1; @@ -1589,7 +1589,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx, if ((root->indirect_levels > 1) && fix_problem(ctx, PR_1_HTREE_DEPTH, pctx)) return 1; - + return 0; } @@ -1791,7 +1791,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, int dirty_inode = 0; int extent_fs; __u64 size; - + pb.ino = ino; pb.num_blocks = 0; pb.last_block = -1; @@ -1853,7 +1853,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, "check_blocks"); return; } - + if (pb.is_dir) { while (1) { struct ext2_db_entry *entry; @@ -1863,7 +1863,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, (entry->blk != 0) || (entry->blockcnt == 0)) break; - /* printf("Dropping ino %lu blk %lu blockcnt %d\n", + /* printf("Dropping ino %lu blk %lu blockcnt %d\n", entry->ino, entry->blk, entry->blockcnt); */ ext2fs_dblist_drop_last(fs->dblist); if (ext2fs_dblist_get_last(fs->dblist, &entry) || @@ -1888,7 +1888,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, !(inode->i_flags & EXT2_INDEX_FL) && ((inode->i_size / fs->blocksize) >= 3)) ext2fs_u32_list_add(ctx->dirs_to_hash, ino); - + if (!pb.num_blocks && pb.is_dir) { if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) { e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks"); @@ -1908,7 +1908,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, #endif if (pb.is_dir) { int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super); - if (inode->i_size & (fs->blocksize - 1)) + if (inode->i_size & (fs->blocksize - 1)) bad_size = 5; else if (nblock > (pb.last_block + 1)) bad_size = 1; @@ -2095,7 +2095,7 @@ static int process_block(ext2_filsys fs, printf("Process_block, inode %lu, block %u, #%d\n", p->ino, blk, blockcnt); #endif - + /* * Simplistic fragmentation check. We merely require that the * file be contiguous. (Which can never be true for really @@ -2120,7 +2120,7 @@ static int process_block(ext2_filsys fs, problem = PR_1_TOOBIG_REG; if (!p->is_dir && !p->is_reg && blockcnt > 0) problem = PR_1_TOOBIG_SYMLINK; - + if (blk < fs->super->s_first_data_block || blk >= fs->super->s_blocks_count) problem = PR_1_ILLEGAL_BLOCK_NUM; @@ -2149,7 +2149,7 @@ static int process_block(ext2_filsys fs, } if (p->ino == EXT2_RESIZE_INO) { - /* + /* * The resize inode has already be sanity checked * during pass #0 (the superblock checks). All we * have to do is mark the double indirect block as @@ -2200,11 +2200,11 @@ static int process_bad_block(ext2_filsys fs, if (!blk) return 0; - + p = (struct process_block_struct *) priv_data; ctx = p->ctx; pctx = p->pctx; - + pctx->ino = EXT2_BAD_INO; pctx->blk = blk; pctx->blkcount = blockcnt; @@ -2225,10 +2225,10 @@ static int process_bad_block(ext2_filsys fs, *block_nr = 0; return BLOCK_CHANGED; } - } else if (ext2fs_test_block_bitmap(ctx->block_found_map, + } else if (ext2fs_test_block_bitmap(ctx->block_found_map, blk)) { p->bbcheck = 1; - if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK, + if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK, pctx)) { *block_nr = 0; return BLOCK_CHANGED; @@ -2239,7 +2239,7 @@ static int process_bad_block(ext2_filsys fs, mark_block_used(ctx, blk); return 0; } -#if 0 +#if 0 printf ("DEBUG: Marking %u as bad.\n", blk); #endif ctx->fs_badblocks_count++; @@ -2257,7 +2257,7 @@ static int process_bad_block(ext2_filsys fs, * Try to find the where the filesystem block was used... */ first_block = fs->super->s_first_data_block; - + for (i = 0; i < fs->group_desc_count; i++ ) { pctx->group = i; pctx->blk = blk; @@ -2343,7 +2343,7 @@ static int process_bad_block(ext2_filsys fs, return 0; } -static void new_table_block(e2fsck_t ctx, blk_t first_block, int group, +static void new_table_block(e2fsck_t ctx, blk_t first_block, int group, const char *name, int num, blk_t *new_block) { ext2_filsys fs = ctx->fs; @@ -2426,7 +2426,7 @@ static void handle_fs_bad_blocks(e2fsck_t ctx) } if (ctx->invalid_inode_table_flag[i]) { new_table_block(ctx, first_block, i, _("inode table"), - fs->inode_blocks_per_group, + fs->inode_blocks_per_group, &fs->group_desc[i].bg_inode_table); ctx->flags |= E2F_FLAG_RESTART; } @@ -2445,9 +2445,9 @@ static void mark_table_blocks(e2fsck_t ctx) dgrp_t i; int j; struct problem_context pctx; - + clear_problem_context(&pctx); - + for (i = 0; i < fs->group_desc_count; i++) { pctx.group = i; @@ -2474,9 +2474,9 @@ static void mark_table_blocks(e2fsck_t ctx) } } } - + /* - * Mark block used for the block bitmap + * Mark block used for the block bitmap */ if (fs->group_desc[i].bg_block_bitmap) { if (ext2fs_test_block_bitmap(ctx->block_found_map, @@ -2490,10 +2490,10 @@ static void mark_table_blocks(e2fsck_t ctx) ext2fs_mark_block_bitmap(ctx->block_found_map, fs->group_desc[i].bg_block_bitmap); } - + } /* - * Mark block used for the inode bitmap + * Mark block used for the inode bitmap */ if (fs->group_desc[i].bg_inode_bitmap) { if (ext2fs_test_block_bitmap(ctx->block_found_map, @@ -2502,7 +2502,7 @@ static void mark_table_blocks(e2fsck_t ctx) if (fix_problem(ctx, PR_1_IB_CONFLICT, &pctx)) { ctx->invalid_inode_bitmap_flag[i]++; ctx->invalid_bitmaps++; - } + } } else { ext2fs_mark_block_bitmap(ctx->block_found_map, fs->group_desc[i].bg_inode_bitmap); @@ -2510,7 +2510,7 @@ static void mark_table_blocks(e2fsck_t ctx) } } } - + /* * Thes subroutines short circuits ext2fs_get_blocks and * ext2fs_check_directory; we use them since we already have the inode @@ -2522,7 +2522,7 @@ static errcode_t pass1_get_blocks(ext2_filsys fs, ext2_ino_t ino, { e2fsck_t ctx = (e2fsck_t) fs->priv_data; int i; - + if ((ino != ctx->stashed_ino) || !ctx->stashed_inode) return EXT2_ET_CALLBACK_NOTHANDLED; @@ -2573,7 +2573,7 @@ static errcode_t e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal, blk_t new_block; if (ctx->block_found_map) { - retval = ext2fs_new_block(fs, (blk_t) goal, + retval = ext2fs_new_block(fs, (blk_t) goal, ctx->block_found_map, &new_block); if (retval) return retval; @@ -2588,7 +2588,7 @@ static errcode_t e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal, if (retval) return retval; } - + *ret = new_block; return (0); } @@ -2599,10 +2599,10 @@ static void e2fsck_block_alloc_stats(ext2_filsys fs, blk64_t blk, int inuse) if (ctx->block_found_map) { if (inuse > 0) - ext2fs_mark_block_bitmap(ctx->block_found_map, + ext2fs_mark_block_bitmap(ctx->block_found_map, (blk_t) blk); else - ext2fs_unmark_block_bitmap(ctx->block_found_map, + ext2fs_unmark_block_bitmap(ctx->block_found_map, (blk_t) blk); } } diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c index 06cf87b4..809bd7f7 100644 --- a/e2fsck/pass1b.c +++ b/e2fsck/pass1b.c @@ -4,7 +4,7 @@ * This file contains pass1B, pass1C, and pass1D of e2fsck. They are * only invoked if pass 1 discovered blocks which are in use by more * than one inode. - * + * * Pass1B scans the data blocks of all the inodes again, generating a * complete list of duplicate blocks and which inodes have claimed * them. @@ -17,14 +17,14 @@ * blocks, the user is prompted if s/he would like to clone the file * (so that the file gets a fresh copy of the duplicated blocks) or * simply to delete the file. - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <time.h> @@ -83,7 +83,7 @@ struct dup_inode { }; static int process_pass1b_block(ext2_filsys fs, blk_t *blocknr, - e2_blkcnt_t blockcnt, blk_t ref_blk, + e2_blkcnt_t blockcnt, blk_t ref_blk, int ref_offset, void *priv_data); static void delete_file(e2fsck_t ctx, ext2_ino_t ino, struct dup_inode *dp, char *block_buf); @@ -169,7 +169,7 @@ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk, /* * Free a duplicate inode record */ -static void inode_dnode_free(dnode_t *node, +static void inode_dnode_free(dnode_t *node, void *context EXT2FS_ATTR((unused))) { struct dup_inode *di; @@ -186,7 +186,7 @@ static void inode_dnode_free(dnode_t *node, /* * Free a duplicate block record */ -static void block_dnode_free(dnode_t *node, +static void block_dnode_free(dnode_t *node, void *context EXT2FS_ATTR((unused))) { struct dup_block *db; @@ -210,7 +210,7 @@ void e2fsck_pass1_dupblocks(e2fsck_t ctx, char *block_buf) struct problem_context pctx; clear_problem_context(&pctx); - + pctx.errcode = ext2fs_allocate_inode_bitmap(fs, _("multiply claimed inode map"), &inode_dup_map); if (pctx.errcode) { @@ -223,7 +223,7 @@ void e2fsck_pass1_dupblocks(e2fsck_t ctx, char *block_buf) dict_init(&blk_dict, DICTCOUNT_T_MAX, dict_int_cmp); dict_set_allocator(&ino_dict, NULL, inode_dnode_free, NULL); dict_set_allocator(&blk_dict, NULL, block_dnode_free, NULL); - + pass1b(ctx, block_buf); pass1c(ctx, block_buf); pass1d(ctx, block_buf); @@ -255,9 +255,9 @@ static void pass1b(e2fsck_t ctx, char *block_buf) ext2_inode_scan scan; struct process_block_struct pb; struct problem_context pctx; - + clear_problem_context(&pctx); - + if (!(ctx->options & E2F_OPT_PREEN)) fix_problem(ctx, PR_1B_PASS_HEADER, &pctx); pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks, @@ -315,7 +315,7 @@ static void pass1b(e2fsck_t ctx, char *block_buf) static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t *block_nr, e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), - blk_t ref_blk EXT2FS_ATTR((unused)), + blk_t ref_blk EXT2FS_ATTR((unused)), int ref_offset EXT2FS_ATTR((unused)), void *priv_data) { @@ -326,10 +326,10 @@ static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)), return 0; p = (struct process_block_struct *) priv_data; ctx = p->ctx; - + if (!ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr)) return 0; - + /* OK, this is a duplicate block */ if (p->ino != EXT2_BAD_INO) { p->pctx->blk = *block_nr; @@ -339,7 +339,7 @@ static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)), ext2fs_mark_inode_bitmap(inode_dup_map, p->ino); add_dupe(ctx, p->ino, *block_nr, p->inode); - + return 0; } @@ -356,9 +356,9 @@ struct search_dir_struct { static int search_dirent_proc(ext2_ino_t dir, int entry, struct ext2_dir_entry *dirent, - int offset EXT2FS_ATTR((unused)), + int offset EXT2FS_ATTR((unused)), int blocksize EXT2FS_ATTR((unused)), - char *buf EXT2FS_ATTR((unused)), + char *buf EXT2FS_ATTR((unused)), void *priv_data) { struct search_dir_struct *sd; @@ -369,7 +369,7 @@ static int search_dirent_proc(ext2_ino_t dir, int entry, if (dirent->inode > sd->max_inode) /* Should abort this inode, but not everything */ - return 0; + return 0; if ((dirent->inode < sd->first_inode) || (entry < DIRENT_OTHER_FILE) || !ext2fs_test_inode_bitmap(inode_dup_map, dirent->inode)) @@ -408,7 +408,7 @@ static void pass1c(e2fsck_t ctx, char *block_buf) sd.max_inode = fs->super->s_inodes_count; ext2fs_dblist_dir_iterate(fs->dblist, 0, block_buf, search_dirent_proc, &sd); -} +} static void pass1d(e2fsck_t ctx, char *block_buf) { @@ -424,9 +424,9 @@ static void pass1d(e2fsck_t ctx, char *block_buf) dnode_t *n, *m; struct block_el *s; struct inode_el *r; - + clear_problem_context(&pctx); - + if (!(ctx->options & E2F_OPT_PREEN)) fix_problem(ctx, PR_1D_PASS_HEADER, &pctx); e2fsck_read_bitmaps(ctx); @@ -461,7 +461,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf) file_ok = 0; meta_data = 1; } - + /* * Add all inodes used by this block to the * shared[] --- which is a unique list, so @@ -491,10 +491,10 @@ static void pass1d(e2fsck_t ctx, char *block_buf) fix_problem(ctx, PR_1D_DUP_FILE, &pctx); pctx.blkcount = 0; pctx.num = 0; - + if (meta_data) fix_problem(ctx, PR_1D_SHARE_METADATA, &pctx); - + for (i = 0; i < shared_len; i++) { m = dict_lookup(&ino_dict, INT_TO_VOIDPTR(shared[i])); if (!m) @@ -570,10 +570,10 @@ static int delete_file_block(ext2_filsys fs, ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr); ext2fs_block_alloc_stats(fs, *block_nr, -1); } - + return 0; } - + static void delete_file(e2fsck_t ctx, ext2_ino_t ino, struct dup_inode *dp, char* block_buf) { @@ -591,7 +591,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino, e2fsck_read_inode(ctx, ino, &inode, "delete_file"); if (ext2fs_inode_has_valid_blocks(&inode)) - pctx.errcode = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_READ_ONLY, + pctx.errcode = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_READ_ONLY, block_buf, delete_file_block, &pb); if (pctx.errcode) fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx); @@ -623,7 +623,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino, */ if ((count == 0) || ext2fs_test_block_bitmap(ctx->block_dup_map, - inode.i_file_acl)) + inode.i_file_acl)) delete_file_block(fs, &inode.i_file_acl, BLOCK_COUNT_EXTATTR, 0, 0, &pb); } @@ -651,7 +651,7 @@ static int clone_file_block(ext2_filsys fs, e2fsck_t ctx; ctx = cs->ctx; - + if (HOLE_BLKADDR(*block_nr)) return 0; @@ -702,7 +702,7 @@ static int clone_file_block(ext2_filsys fs, } return 0; } - + static int clone_file(e2fsck_t ctx, ext2_ino_t ino, struct dup_inode *dp, char* block_buf) { @@ -758,7 +758,7 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino, */ n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk)); if (!n) { - com_err("clone_file", 0, + com_err("clone_file", 0, _("internal error: couldn't lookup EA " "block record for %u"), blk); retval = 0; /* OK to stumble on... */ @@ -770,9 +770,9 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino, continue; n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode)); if (!n) { - com_err("clone_file", 0, + com_err("clone_file", 0, _("internal error: couldn't lookup EA " - "inode record for %u"), + "inode record for %u"), ino_el->inode); retval = 0; /* OK to stumble on... */ goto errout; @@ -801,7 +801,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block) ext2_filsys fs = ctx->fs; blk_t first_block; dgrp_t i; - + first_block = fs->super->s_first_data_block; for (i = 0; i < fs->group_desc_count; i++) { @@ -811,7 +811,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block) (test_block <= first_block + fs->desc_blocks)) return 1; } - + /* Check the inode table */ if ((fs->group_desc[i].bg_inode_table) && (test_block >= fs->group_desc[i].bg_inode_table) && @@ -823,7 +823,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block) if ((test_block == fs->group_desc[i].bg_block_bitmap) || (test_block == fs->group_desc[i].bg_inode_bitmap)) return 1; - + first_block += fs->super->s_blocks_per_group; } return 0; diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 1992479b..c36bfcf4 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -1,13 +1,13 @@ /* * pass2.c --- check directory structure - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * Pass 2 of e2fsck iterates through all active directory inodes, and * applies to following tests to each directory entry in the directory * blocks in the inodes: @@ -16,7 +16,7 @@ * least 8 bytes, and no more than the remaining space * left in the directory block. * - The length of the name in the directory entry (name_len) - * should be less than (rec_len - 8). + * should be less than (rec_len - 8). * - The inode number in the directory entry should be within * legal bounds. * - The inode number should refer to a in-use inode. @@ -70,7 +70,7 @@ static int update_dir_block(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, blk_t ref_block, - int ref_offset, + int ref_offset, void *priv_data); static void clear_htree(e2fsck_t ctx, ext2_ino_t ino); static int htree_depth(struct dx_dir_info *dx_dir, @@ -82,7 +82,7 @@ struct check_dir_struct { struct problem_context pctx; int count, max; e2fsck_t ctx; -}; +}; void e2fsck_pass2(e2fsck_t ctx) { @@ -114,12 +114,12 @@ void e2fsck_pass2(e2fsck_t ctx) if (!(ctx->options & E2F_OPT_PREEN)) fix_problem(ctx, PR_2_PASS_HEADER, &cd.pctx); - e2fsck_setup_tdb_icount(ctx, EXT2_ICOUNT_OPT_INCREMENT, + e2fsck_setup_tdb_icount(ctx, EXT2_ICOUNT_OPT_INCREMENT, &ctx->inode_count); if (ctx->inode_count) cd.pctx.errcode = 0; - else - cd.pctx.errcode = ext2fs_create_icount2(fs, + else + cd.pctx.errcode = ext2fs_create_icount2(fs, EXT2_ICOUNT_OPT_INCREMENT, 0, ctx->inode_link_info, &ctx->inode_count); @@ -148,7 +148,7 @@ void e2fsck_pass2(e2fsck_t ctx) if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) ext2fs_dblist_sort(fs->dblist, special_dir_block_cmp); - + cd.pctx.errcode = ext2fs_dblist_iterate(fs->dblist, check_dir_block, &cd); if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART) @@ -195,7 +195,7 @@ void e2fsck_pass2(e2fsck_t ctx) if (dx_db->flags & DX_FLAG_LAST) dx_parent->max_hash = dx_db->max_hash; } - + for (b=0, dx_db = dx_dir->dx_block; b < dx_dir->numblocks; b++, dx_db++) { @@ -220,7 +220,7 @@ void e2fsck_pass2(e2fsck_t ctx) } } /* - * This test doesn't apply for the root block + * This test doesn't apply for the root block * at block #0 */ if (b && @@ -277,7 +277,7 @@ void e2fsck_pass2(e2fsck_t ctx) ext2fs_mark_super_dirty(fs); } } - + #ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME2) { e2fsck_clear_progbar(ctx); @@ -333,10 +333,10 @@ static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b) if (!db_a->blockcnt && db_b->blockcnt) return -1; - + if (db_a->blk != db_b->blk) return (int) (db_a->blk - db_b->blk); - + if (db_a->ino != db_b->ino) return (int) (db_a->ino - db_b->ino); @@ -357,7 +357,7 @@ static int check_dot(e2fsck_t ctx, int created = 0; int rec_len, new_len; int problem = 0; - + if (!dirent->inode) problem = PR_2_MISSING_DOT; else if (((dirent->name_len & 0xFF) != 1) || @@ -414,7 +414,7 @@ static int check_dotdot(e2fsck_t ctx, ext2_ino_t ino, struct problem_context *pctx) { int rec_len, problem = 0; - + if (!dirent->inode) problem = PR_2_MISSING_DOT_DOT; else if (((dirent->name_len & 0xFF) != 2) || @@ -441,7 +441,7 @@ static int check_dotdot(e2fsck_t ctx, dirent->name[1] = '.'; dirent->name[2] = '\0'; return 1; - } + } return 0; } if (e2fsck_dir_info_set_dotdot(ctx, ino, dirent->inode)) { @@ -457,13 +457,13 @@ static int check_dotdot(e2fsck_t ctx, */ static int check_name(e2fsck_t ctx, struct ext2_dir_entry *dirent, - ext2_ino_t dir_ino EXT2FS_ATTR((unused)), + ext2_ino_t dir_ino EXT2FS_ATTR((unused)), struct problem_context *pctx) { int i; int fixup = -1; int ret = 0; - + for ( i = 0; i < (dirent->name_len & 0xFF); i++) { if (dirent->name[i] == '/' || dirent->name[i] == '\0') { if (fixup < 0) { @@ -520,7 +520,7 @@ static _INLINE_ int check_filetype(e2fsck_t ctx, if (fix_problem(ctx, filetype ? PR_2_BAD_FILETYPE : PR_2_SET_FILETYPE, pctx) == 0) return 0; - + dirent->name_len = (dirent->name_len & 0xFF) | should_be << 8; return 1; } @@ -544,7 +544,7 @@ static void parse_int_node(ext2_filsys fs, if (db->blockcnt == 0) { root = (struct ext2_dx_root_info *) (block_buf + 24); - + #ifdef DX_DEBUG printf("Root node dump:\n"); printf("\t Reserved zero: %u\n", root->reserved_zero); @@ -561,9 +561,9 @@ static void parse_int_node(ext2_filsys fs, limit = (struct ext2_dx_countlimit *) ent; #ifdef DX_DEBUG - printf("Number of entries (count): %d\n", + printf("Number of entries (count): %d\n", ext2fs_le16_to_cpu(limit->count)); - printf("Number of entries (limit): %d\n", + printf("Number of entries (limit): %d\n", ext2fs_le16_to_cpu(limit->limit)); #endif @@ -581,7 +581,7 @@ static void parse_int_node(ext2_filsys fs, goto clear_and_exit; count = expect_limit; } - + for (i=0; i < count; i++) { prev_hash = hash; hash = i ? (ext2fs_le32_to_cpu(ent[i].hash) & ~1) : 0; @@ -614,7 +614,7 @@ static void parse_int_node(ext2_filsys fs, max_hash = hash; dx_db->node_min_hash = hash; if ((i+1) < count) - dx_db->node_max_hash = + dx_db->node_max_hash = ext2fs_le32_to_cpu(ent[i+1].hash) & ~1; else { dx_db->node_max_hash = 0xfffffffe; @@ -640,7 +640,7 @@ clear_and_exit: /* * Given a busted directory, try to salvage it somehow. - * + * */ static void salvage_directory(ext2_filsys fs, struct ext2_dir_entry *dirent, @@ -739,15 +739,15 @@ static int check_dir_block(ext2_filsys fs, if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART) return DIRENT_ABORT; - + if (ctx->progress && (ctx->progress)(ctx, 2, cd->count++, cd->max)) return DIRENT_ABORT; - + /* - * Make sure the inode is still in use (could have been + * Make sure the inode is still in use (could have been * deleted in the duplicate/bad blocks pass. */ - if (!(ext2fs_test_inode_bitmap(ctx->inode_used_map, ino))) + if (!(ext2fs_test_inode_bitmap(ctx->inode_used_map, ino))) return 0; cd->pctx.ino = ino; @@ -762,7 +762,7 @@ static int check_dir_block(ext2_filsys fs, return 0; block_nr = db->blk; } - + if (db->blockcnt) dot_state = 2; else @@ -776,7 +776,7 @@ static int check_dir_block(ext2_filsys fs, printf("In process_dir_block block %lu, #%d, inode %lu\n", block_nr, db->blockcnt, ino); #endif - + old_op = ehandler_operation(_("reading directory block")); cd->pctx.errcode = ext2fs_read_dir_block(fs, block_nr, buf); ehandler_operation(0); @@ -793,7 +793,7 @@ static int check_dir_block(ext2_filsys fs, dx_dir = e2fsck_get_dx_dir_info(ctx, ino); if (dx_dir && dx_dir->numblocks) { if (db->blockcnt >= dx_dir->numblocks) { - if (fix_problem(ctx, PR_2_UNEXPECTED_HTREE_BLOCK, + if (fix_problem(ctx, PR_2_UNEXPECTED_HTREE_BLOCK, &pctx)) { clear_htree(ctx, ino); dx_dir->numblocks = 0; @@ -807,7 +807,7 @@ static int check_dir_block(ext2_filsys fs, dx_db->phys = block_nr; dx_db->min_hash = ~0; dx_db->max_hash = 0; - + dirent = (struct ext2_dir_entry *) buf; rec_len = (dirent->rec_len || fs->blocksize < 65536) ? dirent->rec_len : 65536; @@ -832,8 +832,8 @@ static int check_dir_block(ext2_filsys fs, } else if ((dirent->inode == 0) && (rec_len == fs->blocksize) && (dirent->name_len == 0) && - (ext2fs_le16_to_cpu(limit->limit) == - ((fs->blocksize-8) / + (ext2fs_le16_to_cpu(limit->limit) == + ((fs->blocksize-8) / sizeof(struct ext2_dx_entry)))) dx_db->type = DX_DIRBLOCK_NODE; } @@ -887,12 +887,12 @@ out_htree: goto next; } } - if (!dirent->inode) + if (!dirent->inode) goto next; - + /* * Make sure the inode listed is a legal one. - */ + */ if (((dirent->inode != EXT2_ROOT_INO) && (dirent->inode < EXT2_FIRST_INODE(fs->super))) || (dirent->inode > fs->super->s_inodes_count)) { @@ -916,7 +916,7 @@ out_htree: problem = PR_2_DUP_DOT; } else if ((dot_state > 1) && ((dirent->name_len & 0xFF) == 2) && - (dirent->name[0] == '.') && + (dirent->name[0] == '.') && (dirent->name[1] == '.')) { /* * If there's a '..' entry in anything other @@ -1078,7 +1078,7 @@ out_htree: } cd->pctx.ino2 = 0; } else { - (void) e2fsck_dir_info_set_parent(ctx, + (void) e2fsck_dir_info_set_parent(ctx, dirent->inode, ino); } } @@ -1097,7 +1097,7 @@ out_htree: dups_found++; } else dict_alloc_insert(&de_dict, dirent, dirent); - + ext2fs_icount_increment(ctx->inode_count, dirent->inode, &links); if (links > 1) @@ -1164,7 +1164,7 @@ static int deallocate_inode_block(ext2_filsys fs, void *priv_data) { e2fsck_t ctx = (e2fsck_t) priv_data; - + if (HOLE_BLKADDR(*block_nr)) return 0; if ((*block_nr < fs->super->s_first_data_block) || @@ -1174,7 +1174,7 @@ static int deallocate_inode_block(ext2_filsys fs, ext2fs_block_alloc_stats(fs, *block_nr, -1); return 0; } - + /* * This fuction deallocates an inode */ @@ -1184,7 +1184,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf) struct ext2_inode inode; struct problem_context pctx; __u32 count; - + e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode"); e2fsck_clear_inode(ctx, ino, &inode, 0, "deallocate_inode"); clear_problem_context(&pctx); @@ -1240,7 +1240,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf) static void clear_htree(e2fsck_t ctx, ext2_ino_t ino) { struct ext2_inode inode; - + e2fsck_read_inode(ctx, ino, &inode, "clear_htree"); inode.i_flags = inode.i_flags & ~EXT2_INDEX_FL; e2fsck_write_inode(ctx, ino, &inode, "clear_htree"); @@ -1308,7 +1308,7 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir, not_fixed++; problem = 0; } - + if (inode.i_faddr) { if (fix_problem(ctx, PR_2_FADDR_ZERO, &pctx)) { inode.i_faddr = 0; @@ -1345,7 +1345,7 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir, } if ((fs->super->s_creator_os == EXT2_OS_LINUX) && - !(fs->super->s_feature_ro_compat & + !(fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) && (inode.osd2.linux2.l_i_blocks_hi != 0)) { pctx.num = inode.osd2.linux2.l_i_blocks_hi; @@ -1389,7 +1389,7 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir, */ static int allocate_dir_block(e2fsck_t ctx, struct ext2_db_entry *db, - char *buf EXT2FS_ATTR((unused)), + char *buf EXT2FS_ATTR((unused)), struct problem_context *pctx) { ext2_filsys fs = ctx->fs; @@ -1405,7 +1405,7 @@ static int allocate_dir_block(e2fsck_t ctx, * them. */ e2fsck_read_bitmaps(ctx); - + /* * First, find a free block */ @@ -1473,7 +1473,7 @@ static int update_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t *block_nr, e2_blkcnt_t blockcnt, blk_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *priv_data) { struct ext2_db_entry *db; diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index 4ef14465..a14bc5d5 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -7,14 +7,14 @@ * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * Pass #3 assures that all directories are connected to the * filesystem tree, using the following algorithm: * * First, the root directory is checked to make sure it exists; if * not, e2fsck will offer to create a new one. It is then marked as * "done". - * + * * Then, pass3 interates over all directory inodes; for each directory * it attempts to trace up the filesystem tree, using dirinfo.parent * until it reaches a directory which has been marked "done". If it @@ -24,7 +24,7 @@ * twice, then it has detected a filesystem loop, and it will again * offer to reconnect the directory to /lost+found in to break the * filesystem loop. - * + * * Pass 3 also contains the subroutine, e2fsck_reconnect_file() to * reconnect inodes to /lost+found; this subroutine is also used by * pass 4. e2fsck_reconnect_file() calls get_lost_and_found(), which @@ -48,7 +48,7 @@ static void fix_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent); static ext2fs_inode_bitmap inode_loop_detect = 0; static ext2fs_inode_bitmap inode_done_map = 0; - + void e2fsck_pass3(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; @@ -104,7 +104,7 @@ void e2fsck_pass3(e2fsck_t ctx) if (ctx->progress) if ((ctx->progress)(ctx, 3, 0, maxdirs)) goto abort_exit; - + iter = e2fsck_dir_info_iter_begin(ctx); while ((dir = e2fsck_dir_info_iter(ctx, iter)) != 0) { if (ctx->flags & E2F_FLAG_SIGNAL_MASK) @@ -128,7 +128,7 @@ void e2fsck_pass3(e2fsck_t ctx) * optimized, do it here. */ e2fsck_rehash_directories(ctx); - + abort_exit: e2fsck_free_dir_info(ctx); if (inode_loop_detect) { @@ -159,9 +159,9 @@ static void check_root(e2fsck_t ctx) struct ext2_inode inode; char * block; struct problem_context pctx; - + clear_problem_context(&pctx); - + if (ext2fs_test_inode_bitmap(ctx->inode_used_map, EXT2_ROOT_INO)) { /* * If the root inode is not a directory, die here. The @@ -183,7 +183,7 @@ static void check_root(e2fsck_t ctx) } e2fsck_read_bitmaps(ctx); - + /* * First, find a free block */ @@ -240,7 +240,7 @@ static void check_root(e2fsck_t ctx) ctx->flags |= E2F_FLAG_ABORT; return; } - + /* * Miscellaneous bookkeeping... */ @@ -261,7 +261,7 @@ static void check_root(e2fsck_t ctx) * the lost+found. We have to do loop detection; if we ever discover * a loop, we treat that as a disconnected directory and offer to * reparent it to lost+found. - * + * * However, loop detection is expensive, because for very large * filesystems, the inode_loop_detect bitmap is huge, and clearing it * is non-trivial. Loops in filesystems are also a rare error case, @@ -302,7 +302,7 @@ static int check_directory(e2fsck_t ctx, ext2_ino_t dir, * reparent it to lost+found */ if (!parent || - (loop_pass && + (loop_pass && (ext2fs_test_inode_bitmap(inode_loop_detect, parent)))) { pctx->ino = ino; @@ -310,7 +310,7 @@ static int check_directory(e2fsck_t ctx, ext2_ino_t dir, if (e2fsck_reconnect_file(ctx, pctx->ino)) ext2fs_unmark_valid(fs); else { - fix_dotdot(ctx, pctx->ino, + fix_dotdot(ctx, pctx->ino, ctx->lost_and_found); parent = ctx->lost_and_found; } @@ -334,7 +334,7 @@ static int check_directory(e2fsck_t ctx, ext2_ino_t dir, pctx->errcode = ext2fs_allocate_inode_bitmap(fs, _("inode loop detection bitmap"), &inode_loop_detect); if (pctx->errcode) { pctx->num = 1; - fix_problem(ctx, + fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, pctx); ctx->flags |= E2F_FLAG_ABORT; return -1; @@ -380,7 +380,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix) return ctx->lost_and_found; clear_problem_context(&pctx); - + retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name, sizeof(name)-1, 0, &ino); if (retval && !fix) @@ -390,7 +390,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix) ctx->lost_and_found = ino; return ino; } - + /* Lost+found isn't a directory! */ if (!fix) return 0; @@ -419,7 +419,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix) * them. */ e2fsck_read_bitmaps(ctx); - + /* * First, find a free block */ @@ -531,7 +531,7 @@ int e2fsck_reconnect_file(e2fsck_t ctx, ext2_ino_t ino) fix_problem(ctx, PR_3_NO_LPF, &pctx); return 1; } - + sprintf(name, "#%u", ino); if (ext2fs_read_inode(fs, ino, &inode) == 0) file_type = ext2_file_type(inode.i_mode); @@ -539,7 +539,7 @@ int e2fsck_reconnect_file(e2fsck_t ctx, ext2_ino_t ino) if (retval == EXT2_ET_DIR_NO_SPACE) { if (!fix_problem(ctx, PR_3_EXPAND_LF_DIR, &pctx)) return 1; - retval = e2fsck_expand_directory(ctx, ctx->lost_and_found, + retval = e2fsck_expand_directory(ctx, ctx->lost_and_found, 1, 0); if (retval) { pctx.errcode = retval; @@ -567,7 +567,7 @@ errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino, int adj) ext2_filsys fs = ctx->fs; errcode_t retval; struct ext2_inode inode; - + if (!ino) return 0; @@ -593,7 +593,7 @@ errcode_t e2fsck_adjust_inode_count(e2fsck_t ctx, ext2_ino_t ino, int adj) ext2fs_icount_decrement(ctx->inode_link_info, ino, 0); inode.i_links_count--; } - + retval = ext2fs_write_inode(fs, ino, &inode); if (retval) return retval; @@ -627,7 +627,7 @@ static int fix_dotdot_proc(struct ext2_dir_entry *dirent, return 0; clear_problem_context(&pctx); - + retval = e2fsck_adjust_inode_count(fp->ctx, dirent->inode, -1); if (retval) { pctx.errcode = retval; @@ -641,7 +641,7 @@ static int fix_dotdot_proc(struct ext2_dir_entry *dirent, dirent->inode = fp->parent; if (fp->ctx->fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE) - dirent->name_len = (dirent->name_len & 0xFF) | + dirent->name_len = (dirent->name_len & 0xFF) | (EXT2_FT_DIR << 8); else dirent->name_len = dirent->name_len & 0xFF; @@ -665,7 +665,7 @@ static void fix_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent) #if 0 printf("Fixing '..' of inode %lu to be %lu...\n", ino, parent); #endif - + clear_problem_context(&pctx); pctx.ino = ino; retval = ext2fs_dir_iterate(fs, ino, DIRENT_FLAG_INCLUDE_EMPTY, @@ -712,7 +712,7 @@ static int expand_dir_proc(ext2_filsys fs, e2fsck_t ctx; ctx = es->ctx; - + if (es->guaranteed_size && blockcnt >= es->guaranteed_size) return BLOCK_ABORT; @@ -744,7 +744,7 @@ static int expand_dir_proc(ext2_filsys fs, } memset(block, 0, fs->blocksize); retval = io_channel_write_blk(fs->io, new_blk, 1, block); - } + } if (retval) { es->err = retval; return BLOCK_ABORT; @@ -754,7 +754,7 @@ static int expand_dir_proc(ext2_filsys fs, ext2fs_mark_block_bitmap(ctx->block_found_map, new_blk); ext2fs_block_alloc_stats(fs, new_blk, +1); es->newblocks++; - + if (es->num == 0) return (BLOCK_CHANGED | BLOCK_ABORT); else @@ -768,7 +768,7 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir, errcode_t retval; struct expand_dir_struct es; struct ext2_inode inode; - + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; @@ -781,14 +781,14 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir, retval = ext2fs_check_directory(fs, dir); if (retval) return retval; - + es.num = num; es.guaranteed_size = guaranteed_size; es.last_block = 0; es.err = 0; es.newblocks = 0; es.ctx = ctx; - + retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND, 0, expand_dir_proc, &es); @@ -801,7 +801,7 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir, retval = ext2fs_read_inode(fs, dir, &inode); if (retval) return retval; - + inode.i_size = (es.last_block + 1) * fs->blocksize; ext2fs_iblk_add_blocks(fs, &inode, es.newblocks); diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c index ebc19a8e..7248483d 100644 --- a/e2fsck/pass4.c +++ b/e2fsck/pass4.c @@ -20,7 +20,7 @@ /* * This routine is called when an inode is not connected to the * directory tree. - * + * * This subroutine returns 1 then the caller shouldn't bother with the * rest of the pass 4 tests. */ @@ -42,7 +42,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i, clear_problem_context(&pctx); pctx.ino = i; pctx.inode = inode; - + if (EXT2_INODE_SIZE(fs->super) -EXT2_GOOD_OLD_INODE_SIZE -extra_size >0) eamagic = *(__u32 *)(((char *)inode) +EXT2_GOOD_OLD_INODE_SIZE + extra_size); @@ -55,7 +55,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i, if (!inode->i_blocks && eamagic != EXT2_EXT_ATTR_MAGIC && (LINUX_S_ISREG(inode->i_mode) || LINUX_S_ISDIR(inode->i_mode))) { if (fix_problem(ctx, PR_4_ZERO_LEN_INODE, &pctx)) { - e2fsck_clear_inode(ctx, i, inode, 0, + e2fsck_clear_inode(ctx, i, inode, 0, "disconnect_inode"); /* * Fix up the bitmaps... @@ -66,7 +66,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i, return 0; } } - + /* * Prompt to reconnect. */ @@ -98,7 +98,7 @@ void e2fsck_pass4(e2fsck_t ctx) __u16 link_count, link_counted; char *buf = 0; int group, maxgroup; - + #ifdef RESOURCE_TRACK init_resource_track(&rtrack, ctx->fs->io); #endif diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c index cc17820b..65822d90 100644 --- a/e2fsck/pass5.c +++ b/e2fsck/pass5.c @@ -1,13 +1,13 @@ /* * pass5.c --- check block and inode bitmaps against on-disk bitmaps - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include "e2fsck.h" @@ -24,7 +24,7 @@ void e2fsck_pass5(e2fsck_t ctx) struct resource_track rtrack; #endif struct problem_context pctx; - + #ifdef MTRACE mtrace_print("Pass 5"); #endif @@ -32,7 +32,7 @@ void e2fsck_pass5(e2fsck_t ctx) #ifdef RESOURCE_TRACK init_resource_track(&rtrack, ctx->fs->io); #endif - + clear_problem_context(&pctx); if (!(ctx->options & E2F_OPT_PREEN)) @@ -571,7 +571,7 @@ static void check_inode_end(e2fsck_t ctx) if (save_inodes_count == end) return; - /* protect loop from wrap-around if end is maxed */ + /* protect loop from wrap-around if end is maxed */ for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) { if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) { if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) { @@ -616,7 +616,7 @@ static void check_block_end(e2fsck_t ctx) if (save_blocks_count == end) return; - /* Protect loop from wrap-around if end is maxed */ + /* Protect loop from wrap-around if end is maxed */ for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) { if (!ext2fs_test_block_bitmap(fs->block_map, i)) { if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) { diff --git a/e2fsck/problemP.h b/e2fsck/problemP.h index 21264fa7..61611898 100644 --- a/e2fsck/problemP.h +++ b/e2fsck/problemP.h @@ -39,5 +39,5 @@ struct latch_descr { #define PR_NO_NOMSG 0x010000 /* Don't print a message if e2fsck -n */ #define PR_PREEN_NO 0x020000 /* Use No as an answer if preening */ #define PR_PREEN_NOHDR 0x040000 /* Don't print the preen header */ -#define PR_CONFIG 0x080000 /* This problem has been customized +#define PR_CONFIG 0x080000 /* This problem has been customized from the config file */ diff --git a/e2fsck/profile.c b/e2fsck/profile.c index 4aac6366..ef439f2a 100644 --- a/e2fsck/profile.c +++ b/e2fsck/profile.c @@ -1,6 +1,6 @@ /* * profile.c -- A simple configuration file parsing "library in a file" - * + * * The profile library was originally written by Theodore Ts'o in 1995 * for use in the MIT Kerberos v5 library. It has been * modified/enhanced/bug-fixed over time by other members of the MIT @@ -18,16 +18,16 @@ * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * Copyright (C) 1985-2005 by the Massachusetts Institute of Technology. - * + * * All rights reserved. - * + * * Export of this software from the United States of America may require * a specific license from the United States Government. It is the * responsibility of any person or organization contemplating export to * obtain such a license before exporting. - * + * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright @@ -41,11 +41,11 @@ * M.I.T. makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * + * */ #ifdef HAVE_UNISTD_H @@ -218,12 +218,12 @@ static errcode_t profile_get_value(profile_t profile, const char *name, * object. */ -static int compstr(const void *m1, const void *m2) +static int compstr(const void *m1, const void *m2) { const char *s1 = *((const char * const *) m1); const char *s2 = *((const char * const *) m2); - return strcmp(s1, s2); + return strcmp(s1, s2); } static void free_list(char **list) @@ -232,7 +232,7 @@ static void free_list(char **list) if (list == 0) return; - + for (cp = list; *cp; cp++) free(*cp); free(list); @@ -295,7 +295,7 @@ errout: return retval; } -errcode_t +errcode_t profile_init(const char **files, profile_t *ret_profile) { const char **fs; @@ -327,7 +327,7 @@ profile_init(const char **files, profile_t *ret_profile) *last = new_file; last = &new_file->next; } - } else if ((retval != ENOTDIR) && + } else if ((retval != ENOTDIR) && strcmp(*fs, default_filename)) goto errout; @@ -359,7 +359,7 @@ errout: return retval; } -void +void profile_release(profile_t profile) { prf_file_t p, next; @@ -431,7 +431,7 @@ errcode_t profile_set_default(profile_t profile, const char *def_string) if (retval) { errout: if (syntax_err_cb) - (syntax_err_cb)(prf->filespec, retval, + (syntax_err_cb)(prf->filespec, retval, state.line_num); free(line); if (prf->root) @@ -494,7 +494,7 @@ errcode_t profile_open_file(const char * filespec, } expanded_filename = malloc(len); if (expanded_filename == 0) { - profile_free_file(prf); + profile_free_file(prf); return errno; } if (home_env) { @@ -583,7 +583,7 @@ errcode_t profile_update_file(prf_file_t prf) retval = parse_line(buf, &state); if (retval) { if (syntax_err_cb) - (syntax_err_cb)(prf->filespec, retval, + (syntax_err_cb)(prf->filespec, retval, state.line_num); fclose(f); return retval; @@ -686,7 +686,7 @@ static errcode_t parse_line(char *line, struct parse_state *state) struct profile_node *node; int do_subsection = 0; void *iter = 0; - + state->line_num++; if (state->state == STATE_GET_OBRACE) { cp = skip_over_blanks(line); @@ -726,7 +726,7 @@ static errcode_t parse_line(char *line, struct parse_state *state) if (*cp == 0) return PROF_SECTION_SYNTAX; } - retval = profile_find_node(state->root_section, cp, 0, 1, + retval = profile_find_node(state->root_section, cp, 0, 1, &iter, &state->current_section); if (retval == PROF_NO_SECTION) { retval = profile_add_node(state->root_section, @@ -746,7 +746,7 @@ static errcode_t parse_line(char *line, struct parse_state *state) cp++; } /* - * Spaces or comments after ']' should not be fatal + * Spaces or comments after ']' should not be fatal */ cp = skip_over_blanks(cp); if (!end_or_comment(*cp)) @@ -902,7 +902,7 @@ static void dump_profile(struct profile_node *root, int level, struct profile_node *p; void *iter; long retval; - + iter = 0; do { retval = profile_find_node(root, 0, 0, 0, &iter, &p); @@ -1024,16 +1024,16 @@ errcode_t profile_write_tree_to_buffer(struct profile_node *root, /* * prof_tree.c --- these routines maintain the parse tree of the * config file. - * + * * All of the details of how the tree is stored is abstracted away in * this file; all of the other profile routines build, access, and * modify the tree via the accessor functions found in this file. * * Each node may represent either a relation or a section header. - * + * * A section header must have its value field set to 0, and may a one * or more child nodes, pointed to by first_child. - * + * * A relation has as its value a pointer to allocated memory * containing a string. Its first_child pointer must be null. * @@ -1048,7 +1048,7 @@ void profile_free_node(struct profile_node *node) if (node->magic != PROF_MAGIC_NODE) return; - + if (node->name) free(node->name); if (node->value) @@ -1059,7 +1059,7 @@ void profile_free_node(struct profile_node *node) profile_free_node(child); } node->magic = 0; - + free(node); } @@ -1156,7 +1156,7 @@ errcode_t profile_add_node(struct profile_node *section, const char *name, /* * Find the place to insert the new node. We look for the - * place *after* the last match of the node name, since + * place *after* the last match of the node name, since * order matters. */ for (p=section->first_child, last = 0; p; last = p, p = p->next) { @@ -1191,7 +1191,7 @@ errcode_t profile_add_node(struct profile_node *section, const char *name, * section which matches the name; don't return relations. If value * is non-NULL, then only return relations which match the requested * value. (The value argument is ignored if section_flag is non-zero.) - * + * * The first time this routine is called, the state pointer must be * null. When this profile_find_node_relation() returns, if the state * pointer is non-NULL, then this routine should be called again. @@ -1210,7 +1210,7 @@ errcode_t profile_find_node(struct profile_node *section, const char *name, CHECK_MAGIC(p); } else p = section->first_child; - + for (; p; p = p->next) { if (name && (strcmp(p->name, name))) continue; @@ -1260,7 +1260,7 @@ errcode_t profile_find_node(struct profile_node *section, const char *name, /* * This is a general-purpose iterator for returning all nodes that - * match the specified name array. + * match the specified name array. */ struct profile_iterator { prf_magic_t magic; @@ -1275,7 +1275,7 @@ struct profile_iterator { int num; }; -errcode_t +errcode_t profile_iterator_create(profile_t profile, const char *const *names, int flags, void **ret_iter) { @@ -1346,7 +1346,7 @@ errcode_t profile_node_iterator(void **iter_p, struct profile_node **ret_node, * If the file has changed, then the node pointer is invalid, * so we'll have search the file again looking for it. */ - if (iter->node && (iter->file && + if (iter->node && (iter->file && iter->file->upd_serial != iter->file_serial)) { iter->flags &= ~PROFILE_ITER_FINAL_SEEN; skip_num = iter->num; @@ -1483,13 +1483,13 @@ errcode_t profile_get_value(profile_t profile, const char *name, *ret_value = value; else retval = PROF_NO_RELATION; - + cleanup: profile_iterator_free(&state); return retval; } -errcode_t +errcode_t profile_get_string(profile_t profile, const char *name, const char *subname, const char *subsubname, const char *def_val, char **ret_string) @@ -1498,7 +1498,7 @@ profile_get_string(profile_t profile, const char *name, const char *subname, errcode_t retval; if (profile) { - retval = profile_get_value(profile, name, subname, + retval = profile_get_value(profile, name, subname, subsubname, &value); if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION) value = def_val; @@ -1506,7 +1506,7 @@ profile_get_string(profile_t profile, const char *name, const char *subname, return retval; } else value = def_val; - + if (value) { *ret_string = malloc(strlen(value)+1); if (*ret_string == 0) @@ -1517,7 +1517,7 @@ profile_get_string(profile_t profile, const char *name, const char *subname, return 0; } -errcode_t +errcode_t profile_get_integer(profile_t profile, const char *name, const char *subname, const char *subsubname, int def_val, int *ret_int) { @@ -1552,15 +1552,15 @@ profile_get_integer(profile_t profile, const char *name, const char *subname, /* Garbage in string. */ if (end_value != value + strlen (value)) return PROF_BAD_INTEGER; - - + + *ret_int = ret_long; return 0; } -errcode_t +errcode_t profile_get_uint(profile_t profile, const char *name, const char *subname, - const char *subsubname, unsigned int def_val, + const char *subsubname, unsigned int def_val, unsigned int *ret_int) { const char *value; @@ -1594,7 +1594,7 @@ profile_get_uint(profile_t profile, const char *name, const char *subname, /* Garbage in string. */ if (end_value != value + strlen (value)) return PROF_BAD_INTEGER; - + *ret_int = ret_long; return 0; } @@ -1613,7 +1613,7 @@ static errcode_t profile_parse_boolean(const char *s, int *ret_boolean) { const char *const *p; - + if (ret_boolean == NULL) return PROF_EINVAL; @@ -1630,11 +1630,11 @@ profile_parse_boolean(const char *s, int *ret_boolean) return 0; } } - + return PROF_BAD_BOOLEAN; } -errcode_t +errcode_t profile_get_boolean(profile_t profile, const char *name, const char *subname, const char *subsubname, int def_val, int *ret_boolean) { @@ -1652,16 +1652,16 @@ profile_get_boolean(profile_t profile, const char *name, const char *subname, return 0; } else if (retval) return retval; - + return profile_parse_boolean (value, ret_boolean); } -errcode_t +errcode_t profile_iterator(void **iter_p, char **ret_name, char **ret_value) { char *name, *value; errcode_t retval; - + retval = profile_node_iterator(iter_p, 0, &name, &value); if (retval) return retval; @@ -1734,19 +1734,19 @@ static void do_cmd(profile_t profile, char **argv) if (subname) subsubname = names[2]; if (subsubname && names[3]) { - fprintf(stderr, + fprintf(stderr, "Only 3 levels are allowed with query1\n"); retval = EINVAL; } else - retval = profile_get_value(profile, name, subname, + retval = profile_get_value(profile, name, subname, subsubname, &value); print_status = PRINT_VALUE; } else if (!strcmp(cmd, "list_sections")) { - retval = profile_get_subsection_names(profile, names, + retval = profile_get_subsection_names(profile, names, &values); print_status = PRINT_VALUES; } else if (!strcmp(cmd, "list_relations")) { - retval = profile_get_relation_names(profile, names, + retval = profile_get_relation_names(profile, names, &values); print_status = PRINT_VALUES; } else if (!strcmp(cmd, "dump")) { @@ -1813,7 +1813,7 @@ static void do_batchmode(profile_t profile) } profile_release(profile); exit(0); - + } void syntax_err_report(const char *filename, long err, int line_num) @@ -1830,7 +1830,7 @@ int main(int argc, char **argv) profile_t profile; long retval; char *cmd; - + if (argc < 2) { fprintf(stderr, "Usage: %s filename [cmd argset]\n", program_name); exit(1); @@ -1839,7 +1839,7 @@ int main(int argc, char **argv) initialize_prof_error_table(); profile_set_syntax_err_cb(syntax_err_report); - + retval = profile_init_path(argv[1], &profile); if (retval) { com_err(program_name, retval, "while initializing profile"); diff --git a/e2fsck/profile.h b/e2fsck/profile.h index b974f3c6..0c17732e 100644 --- a/e2fsck/profile.h +++ b/e2fsck/profile.h @@ -7,16 +7,16 @@ * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * Copyright (C) 1985-2005 by the Massachusetts Institute of Technology. - * + * * All rights reserved. - * + * * Export of this software from the United States of America may require * a specific license from the United States Government. It is the * responsibility of any person or organization contemplating export to * obtain such a license before exporting. - * + * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright @@ -30,7 +30,7 @@ * M.I.T. makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. @@ -41,7 +41,7 @@ typedef struct _profile_t *profile_t; -typedef void (*profile_syntax_err_cb_t)(const char *file, long err, +typedef void (*profile_syntax_err_cb_t)(const char *file, long err, int line_num); /* @@ -65,7 +65,7 @@ long profile_set_default (profile_t profile, const char *def_string); long profile_get_string - (profile_t profile, const char *name, const char *subname, + (profile_t profile, const char *name, const char *subname, const char *subsubname, const char *def_val, char **ret_string); long profile_get_integer @@ -75,7 +75,7 @@ long profile_get_integer long profile_get_uint (profile_t profile, const char *name, const char *subname, - const char *subsubname, unsigned int def_val, + const char *subsubname, unsigned int def_val, unsigned int *ret_int); long profile_get_boolean @@ -89,7 +89,7 @@ long profile_iterator_create void profile_iterator_free (void **iter_p); - + long profile_iterator (void **iter_p, char **ret_name, char **ret_value); diff --git a/e2fsck/profile_helpers.c b/e2fsck/profile_helpers.c index dcbdd32e..c6b5c444 100644 --- a/e2fsck/profile_helpers.c +++ b/e2fsck/profile_helpers.c @@ -9,7 +9,7 @@ * relation that is listed more than once. This functionality can all * be done using the profile_iterator abstraction, but it is less * convenient. - * + * * Copyright (C) 2006 by Theodore Ts'o. * * %Begin-Header% @@ -89,7 +89,7 @@ static errcode_t add_to_list(struct profile_string_list *list, char *str) { char **newlist; int newmax; - + if (list->num+1 >= list->max) { newmax = list->max + 10; newlist = realloc(list->list, newmax * sizeof(char *)); @@ -119,8 +119,8 @@ static int is_list_member(struct profile_string_list *list, const char *str) return 1; } return 0; -} - +} + /* * This function frees a null-terminated list as returned by * profile_get_values. @@ -131,7 +131,7 @@ void profile_free_list(char **list) if (list == 0) return; - + for (cp = list; *cp; cp++) free(*cp); free(list); @@ -168,7 +168,7 @@ profile_get_values(profile_t profile, const char *const *names, end_list(&values, ret_values); return 0; - + cleanup: end_list(&values, 0); return retval; @@ -178,7 +178,7 @@ cleanup: * This function will return the list of the names of subections in the * under the specified section name. */ -errcode_t +errcode_t profile_get_subsection_names(profile_t profile, const char **names, char ***ret_names) { @@ -204,7 +204,7 @@ profile_get_subsection_names(profile_t profile, const char **names, end_list(&values, ret_names); return 0; - + cleanup: end_list(&values, 0); return retval; @@ -214,7 +214,7 @@ cleanup: * This function will return the list of the names of relations in the * under the specified section name. */ -errcode_t +errcode_t profile_get_relation_names(profile_t profile, const char **names, char ***ret_names) { @@ -244,20 +244,20 @@ profile_get_relation_names(profile_t profile, const char **names, end_list(&values, ret_names); return 0; - + cleanup: end_list(&values, 0); return retval; } -void +void profile_release_string(char *str) { free(str); } -errcode_t +errcode_t profile_init_path(const char * filepath, profile_t *ret_profile) { @@ -272,7 +272,7 @@ profile_init_path(const char * filepath, if (*s == ':') n_entries++; } - + /* the array is NULL terminated */ filenames = (char **) malloc((n_entries+1) * sizeof(char*)); if (filenames == 0) @@ -298,7 +298,7 @@ profile_init_path(const char * filepath, /* cap the array */ filenames[i] = 0; - retval = profile_init((const char **) filenames, + retval = profile_init((const char **) filenames, ret_profile); /* count back down and free the entries */ diff --git a/e2fsck/region.c b/e2fsck/region.c index 9ccb684a..0cec6a92 100644 --- a/e2fsck/region.c +++ b/e2fsck/region.c @@ -1,6 +1,6 @@ /* * region.c --- code which manages allocations within a region. - * + * * Copyright (C) 2001 Theodore Ts'o. * * %Begin-Header% @@ -154,7 +154,7 @@ void region_print(region_t region, FILE *f) { struct region_el *r; int i = 0; - + fprintf(f, "Printing region (min=%d. max=%d)\n\t", region->min, region->max); for (r = region->allocated; r; r = r->next) { @@ -171,7 +171,7 @@ int main(int argc, char **argv) int pc = 0, ret; region_addr_t start, end, len; - + while (1) { switch (bcode_program[pc++]) { case BCODE_END: diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index 6c7d0510..6c24bdd4 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -1,13 +1,13 @@ /* * rehash.c --- rebuild hash tree directories - * + * * Copyright (C) 2002 Theodore Ts'o * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * This algorithm is designed for simplicity of implementation and to * pack the directory as much as possible. It however requires twice * as much memory as the size of the directory. The maximum size @@ -36,7 +36,7 @@ * -------------------------------------------------------- * ^ ptr ^ptr * tail new head old - * + * * This is going to be a pain in the tuckus to implement, and will * require a lot more disk accesses. So I'm going to skip it for now; * it's only really going to be an issue for really, really big @@ -90,7 +90,7 @@ static int fill_dir_block(ext2_filsys fs, char *dir; unsigned int offset, dir_offset; int rec_len, hash_alg; - + if (blockcnt < 0) return 0; @@ -162,7 +162,7 @@ static int fill_dir_block(ext2_filsys fs, return BLOCK_ABORT; } } - + return 0; } @@ -205,7 +205,7 @@ static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b) const struct hash_entry *he_a = (const struct hash_entry *) a; const struct hash_entry *he_b = (const struct hash_entry *) b; int ret; - + if (he_a->hash > he_b->hash) ret = 1; else if (he_a->hash < he_b->hash) @@ -221,7 +221,7 @@ static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b) return ret; } -static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir, +static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir, int blocks) { void *new_mem; @@ -280,7 +280,7 @@ static void mutate_name(char *str, __u16 *len) { int i; __u16 l = *len & 0xFF, h = *len & 0xff00; - + /* * First check to see if it looks the name has been mutated * already @@ -323,7 +323,7 @@ static void mutate_name(char *str, __u16 *len) } else { if (str[0] == '~') str[0] = 'a'; - else + else str[0]++; } break; @@ -341,7 +341,7 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs, char new_name[256]; __u16 new_len; int hash_alg; - + clear_problem_context(&pctx); pctx.ino = ino; @@ -378,7 +378,7 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs, new_len & 0xFF))) continue; mutate_name(new_name, &new_len); - + j = -1; } new_name[new_len & 0xFF] = 0; @@ -408,7 +408,7 @@ static errcode_t copy_dir_entries(ext2_filsys fs, int i, rec_len, left; ext2_dirhash_t prev_hash; int offset; - + outdir->max = 0; retval = alloc_size_dir(fs, outdir, (fd->dir_size / fs->blocksize) + 2); @@ -473,7 +473,7 @@ static struct ext2_dx_root_info *set_root_node(ext2_filsys fs, char *buf, if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE) filetype = EXT2_FT_DIR << 8; - + memset(buf, 0, fs->blocksize); dir = (struct ext2_dir_entry *) buf; dir->inode = ino; @@ -486,7 +486,7 @@ static struct ext2_dx_root_info *set_root_node(ext2_filsys fs, char *buf, dir->name[1] = '.'; dir->name_len = 2 | filetype; dir->rec_len = fs->blocksize - 12; - + root = (struct ext2_dx_root_info *) (buf+24); root->reserved_zero = 0; root->hash_version = fs->super->s_def_hash_version; @@ -511,7 +511,7 @@ static struct ext2_dx_entry *set_int_node(ext2_filsys fs, char *buf) dir = (struct ext2_dir_entry *) buf; dir->inode = 0; dir->rec_len = fs->blocksize; - + limits = (struct ext2_dx_countlimit *) (buf+8); limits->limit = (fs->blocksize - 8) / sizeof(struct ext2_dx_entry); limits->count = 0; @@ -535,7 +535,7 @@ static errcode_t calculate_tree(ext2_filsys fs, char * block_start; int i, c1, c2, nblks; int limit_offset, root_offset; - + root_info = set_root_node(fs, outdir->buf, ino, parent); root_offset = limit_offset = ((char *) root_info - outdir->buf) + root_info->info_length; @@ -564,7 +564,7 @@ static errcode_t calculate_tree(ext2_filsys fs, return ENOSPC; if (c2 == 0) { if (limit) - limit->limit = limit->count = + limit->limit = limit->count = ext2fs_cpu_to_le16(limit->limit); root = (struct ext2_dx_entry *) (outdir->buf + root_offset); @@ -612,7 +612,7 @@ static int write_dir_block(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, blk_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *priv_data) { struct write_dir_struct *wd = (struct write_dir_struct *) priv_data; @@ -684,7 +684,7 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino) char *dir_buf = 0; struct fill_dir_struct fd; struct out_dir outdir; - + outdir.max = outdir.num = 0; outdir.buf = 0; outdir.hashes = 0; @@ -753,7 +753,7 @@ resort: retval = copy_dir_entries(fs, &fd, &outdir); if (retval) goto errout; - + free(dir_buf); dir_buf = 0; if (!fd.compress) { @@ -762,7 +762,7 @@ resort: if (retval) goto errout; } - + retval = write_directory(ctx, fs, &outdir, ino, fd.compress); if (retval) goto errout; @@ -800,7 +800,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx) return; e2fsck_get_lost_and_found(ctx, 0); - + clear_problem_context(&pctx); dir_index = ctx->fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX; @@ -809,7 +809,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx) dirinfo_iter = e2fsck_dir_info_iter_begin(ctx); max = e2fsck_get_num_dirinfo(ctx); } else { - retval = ext2fs_u32_list_iterate_begin(ctx->dirs_to_hash, + retval = ext2fs_u32_list_iterate_begin(ctx->dirs_to_hash, &iter); if (retval) { pctx.errcode = retval; @@ -820,7 +820,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx) } while (1) { if (all_dirs) { - if ((dir = e2fsck_dir_info_iter(ctx, + if ((dir = e2fsck_dir_info_iter(ctx, dirinfo_iter)) == 0) break; ino = dir->ino; @@ -852,7 +852,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx) e2fsck_dir_info_iter_end(ctx, dirinfo_iter); else ext2fs_u32_list_iterate_end(iter); - + if (ctx->dirs_to_hash) ext2fs_u32_list_free(ctx->dirs_to_hash); ctx->dirs_to_hash = 0; diff --git a/e2fsck/revoke.c b/e2fsck/revoke.c index 1665099e..c43e40e9 100644 --- a/e2fsck/revoke.c +++ b/e2fsck/revoke.c @@ -1,6 +1,6 @@ /* * linux/fs/revoke.c - * + * * Written by Stephen C. Tweedie <sct@redhat.com>, 2000 * * Copyright 2000 Red Hat corp --- All Rights Reserved @@ -15,10 +15,10 @@ * Revoke is the mechanism used to prevent old log records for deleted * metadata from being replayed on top of newer data using the same * blocks. The revoke mechanism is used in two separate places: - * + * * + Commit: during commit we write the entire list of the current * transaction's revoked blocks to the journal - * + * * + Recovery: during recovery we record the transaction ID of all * revoked blocks. If there are multiple revoke records in the log * for a single block, only the last one counts, and if there is a log @@ -29,7 +29,7 @@ * single transaction: * * Block is revoked and then journaled: - * The desired end result is the journaling of the new block, so we + * The desired end result is the journaling of the new block, so we * cancel the revoke before the transaction commits. * * Block is journaled and then revoked: @@ -41,7 +41,7 @@ * transaction must have happened after the block was journaled and so * the revoke must take precedence. * - * Block is revoked and then written as data: + * Block is revoked and then written as data: * The data write is allowed to succeed, but the revoke is _not_ * cancelled. We still need to prevent old log records from * overwriting the new data. We don't even need to clear the revoke @@ -54,7 +54,7 @@ * buffer has not been revoked, and cancel_revoke * need do nothing. * RevokeValid set, Revoked set: - * buffer has been revoked. + * buffer has been revoked. */ #ifndef __KERNEL__ @@ -78,11 +78,11 @@ static lkmem_cache_t *revoke_table_cache; journal replay, this involves recording the transaction ID of the last transaction to revoke this block. */ -struct jbd_revoke_record_s +struct jbd_revoke_record_s { struct list_head hash; tid_t sequence; /* Used for recovery only */ - unsigned long blocknr; + unsigned long blocknr; }; @@ -91,8 +91,8 @@ struct jbd_revoke_table_s { /* It is conceivable that we might want a larger hash table * for recovery. Must be a power of two. */ - int hash_size; - int hash_shift; + int hash_size; + int hash_shift; struct list_head *hash_table; }; @@ -111,7 +111,7 @@ static inline int hash(journal_t *journal, unsigned long block) { struct jbd_revoke_table_s *table = journal->j_revoke; int hash_shift = table->hash_shift; - + return ((block << (hash_shift - 6)) ^ (block >> 13) ^ (block << (hash_shift - 12))) & (table->hash_size - 1); @@ -156,7 +156,7 @@ static struct jbd_revoke_record_s *find_revoke_record(journal_t *journal, { struct list_head *hash_list; struct jbd_revoke_record_s *record; - + hash_list = &journal->j_revoke->hash_table[hash(journal, blocknr)]; record = (struct jbd_revoke_record_s *) hash_list->next; @@ -185,7 +185,7 @@ int __init journal_init_revoke_caches(void) return -ENOMEM; } return 0; -} +} void journal_destroy_revoke_caches(void) { @@ -200,13 +200,13 @@ void journal_destroy_revoke_caches(void) int journal_init_revoke(journal_t *journal, int hash_size) { int shift, tmp; - + J_ASSERT (journal->j_revoke == NULL); - + journal->j_revoke = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL); if (!journal->j_revoke) return -ENOMEM; - + /* Check that the hash_size is a power of two */ J_ASSERT ((hash_size & (hash_size-1)) == 0); @@ -225,10 +225,10 @@ int journal_init_revoke(journal_t *journal, int hash_size) journal->j_revoke = NULL; return -ENOMEM; } - + for (tmp = 0; tmp < hash_size; tmp++) INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]); - + return 0; } @@ -239,16 +239,16 @@ void journal_destroy_revoke(journal_t *journal) struct jbd_revoke_table_s *table; struct list_head *hash_list; int i; - + table = journal->j_revoke; if (!table) return; - + for (i=0; i<table->hash_size; i++) { hash_list = &table->hash_table[i]; J_ASSERT (list_empty(hash_list)); } - + kfree(table->hash_table); kmem_cache_free(revoke_table_cache, table); journal->j_revoke = NULL; @@ -257,22 +257,22 @@ void journal_destroy_revoke(journal_t *journal) #ifdef __KERNEL__ -/* +/* * journal_revoke: revoke a given buffer_head from the journal. This * prevents the block from being replayed during recovery if we take a * crash after this current transaction commits. Any subsequent * metadata writes of the buffer in this transaction cancel the - * revoke. + * revoke. * * Note that this call may block --- it is up to the caller to make * sure that there are no further calls to journal_write_metadata * before the revoke is complete. In ext3, this implies calling the * revoke before clearing the block bitmap when we are deleting - * metadata. + * metadata. * * Revoke performs a journal_forget on any buffer_head passed in as a * parameter, but does _not_ forget the buffer_head if the bh was only - * found implicitly. + * found implicitly. * * bh_in may not be a journalled buffer - it may have come off * the hash tables without an attached journal_head. @@ -281,7 +281,7 @@ void journal_destroy_revoke(journal_t *journal) * by one. */ -int journal_revoke(handle_t *handle, unsigned long blocknr, +int journal_revoke(handle_t *handle, unsigned long blocknr, struct buffer_head *bh_in) { struct buffer_head *bh = NULL; @@ -379,7 +379,7 @@ int journal_cancel_revoke(handle_t *handle, struct journal_head *jh) int need_cancel; int did_revoke = 0; /* akpm: debug */ struct buffer_head *bh = jh2bh(jh); - + jbd_debug(4, "journal_head %p, cancelling revoke\n", jh); /* Is the existing Revoke bit valid? If so, we trust it, and @@ -422,7 +422,7 @@ int journal_cancel_revoke(handle_t *handle, struct journal_head *jh) __brelse(bh2); } } - + return did_revoke; } @@ -434,7 +434,7 @@ int journal_cancel_revoke(handle_t *handle, struct journal_head *jh) * Called with the journal lock held. */ -void journal_write_revoke_records(journal_t *journal, +void journal_write_revoke_records(journal_t *journal, transaction_t *transaction) { struct journal_head *descriptor; @@ -443,38 +443,38 @@ void journal_write_revoke_records(journal_t *journal, struct list_head *hash_list; int i, offset, count; - descriptor = NULL; + descriptor = NULL; offset = 0; count = 0; revoke = journal->j_revoke; - + for (i = 0; i < revoke->hash_size; i++) { hash_list = &revoke->hash_table[i]; while (!list_empty(hash_list)) { - record = (struct jbd_revoke_record_s *) + record = (struct jbd_revoke_record_s *) hash_list->next; write_one_revoke_record(journal, transaction, - &descriptor, &offset, + &descriptor, &offset, record); count++; list_del(&record->hash); kmem_cache_free(revoke_record_cache, record); } } - if (descriptor) + if (descriptor) flush_descriptor(journal, descriptor, offset); jbd_debug(1, "Wrote %d revoke records\n", count); } -/* +/* * Write out one revoke record. We need to create a new descriptor - * block if the old one is full or if we have not already created one. + * block if the old one is full or if we have not already created one. */ -static void write_one_revoke_record(journal_t *journal, +static void write_one_revoke_record(journal_t *journal, transaction_t *transaction, - struct journal_head **descriptorp, + struct journal_head **descriptorp, int *offsetp, struct jbd_revoke_record_s *record) { @@ -499,7 +499,7 @@ static void write_one_revoke_record(journal_t *journal, descriptor = NULL; } } - + if (!descriptor) { descriptor = journal_get_descriptor_buffer(journal); if (!descriptor) @@ -516,22 +516,22 @@ static void write_one_revoke_record(journal_t *journal, offset = sizeof(journal_revoke_header_t); *descriptorp = descriptor; } - - * ((unsigned int *)(&jh2bh(descriptor)->b_data[offset])) = + + * ((unsigned int *)(&jh2bh(descriptor)->b_data[offset])) = htonl(record->blocknr); offset += 4; *offsetp = offset; } -/* +/* * Flush a revoke descriptor out to the journal. If we are aborting, * this is a noop; otherwise we are generating a buffer which needs to * be waited for during commit, so it has to go onto the appropriate * journal buffer list. */ -static void flush_descriptor(journal_t *journal, - struct journal_head *descriptor, +static void flush_descriptor(journal_t *journal, + struct journal_head *descriptor, int offset) { journal_revoke_header_t *header; @@ -541,7 +541,7 @@ static void flush_descriptor(journal_t *journal, __brelse(jh2bh(descriptor)); return; } - + header = (journal_revoke_header_t *) jh2bh(descriptor)->b_data; header->r_count = htonl(offset); set_bit(BH_JWrite, &jh2bh(descriptor)->b_state); @@ -554,7 +554,7 @@ static void flush_descriptor(journal_t *journal, #endif -/* +/* * Revoke support for recovery. * * Recovery needs to be able to: @@ -565,7 +565,7 @@ static void flush_descriptor(journal_t *journal, * check whether a given block in a given transaction should be replayed * (ie. has not been revoked by a revoke record in that or a subsequent * transaction) - * + * * empty the revoke table after recovery. */ @@ -573,15 +573,15 @@ static void flush_descriptor(journal_t *journal, * First, setting revoke records. We create a new revoke record for * every block ever revoked in the log as we scan it for recovery, and * we update the existing records if we find multiple revokes for a - * single block. + * single block. */ -int journal_set_revoke(journal_t *journal, - unsigned long blocknr, +int journal_set_revoke(journal_t *journal, + unsigned long blocknr, tid_t sequence) { struct jbd_revoke_record_s *record; - + record = find_revoke_record(journal, blocknr); if (record) { /* If we have multiple occurences, only record the @@ -589,23 +589,23 @@ int journal_set_revoke(journal_t *journal, if (tid_gt(sequence, record->sequence)) record->sequence = sequence; return 0; - } + } return insert_revoke_hash(journal, blocknr, sequence); } -/* +/* * Test revoke records. For a given block referenced in the log, has * that block been revoked? A revoke record with a given transaction * sequence number revokes all blocks in that transaction and earlier * ones, but later transactions still need replayed. */ -int journal_test_revoke(journal_t *journal, +int journal_test_revoke(journal_t *journal, unsigned long blocknr, tid_t sequence) { struct jbd_revoke_record_s *record; - + record = find_revoke_record(journal, blocknr); if (!record) return 0; @@ -625,9 +625,9 @@ void journal_clear_revoke(journal_t *journal) struct list_head *hash_list; struct jbd_revoke_record_s *record; struct jbd_revoke_table_s *revoke; - + revoke = journal->j_revoke; - + for (i = 0; i < revoke->hash_size; i++) { hash_list = &revoke->hash_table[i]; while (!list_empty(hash_list)) { diff --git a/e2fsck/scantest.c b/e2fsck/scantest.c index 9727a9ff..ed586b1c 100644 --- a/e2fsck/scantest.c +++ b/e2fsck/scantest.c @@ -55,7 +55,7 @@ struct resource_track global_rtrack; void init_resource_track(struct resource_track *track) { struct rusage r; - + track->brk_start = sbrk(0); gettimeofday(&track->time_start, 0); getrusage(RUSAGE_SELF, &r); @@ -100,7 +100,7 @@ int main (int argc, char *argv[]) printf(_("size of inode=%d\n"), sizeof(inode)); device_name = "/dev/hda3"; - + init_resource_track(&global_rtrack); retval = ext2fs_open(device_name, 0, @@ -133,11 +133,11 @@ int main (int argc, char *argv[]) exit(1); } } - + ext2fs_close(fs); - + print_resource_track(&global_rtrack); - + return exit_value; } diff --git a/e2fsck/super.c b/e2fsck/super.c index f5abac94..1bacbc74 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -1,6 +1,6 @@ /* * e2fsck.c - superblock checks - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -102,7 +102,7 @@ static int release_inode_block(ext2_filsys fs, if (blockcnt < 0) { int i, limit; blk_t *bp; - + pb->errcode = io_channel_read_blk(fs->io, blk, 1, pb->buf); if (pb->errcode) @@ -140,11 +140,11 @@ static int release_inode_block(ext2_filsys fs, *block_nr = 0; retval |= BLOCK_CHANGED; } - + ext2fs_block_alloc_stats(fs, blk, -1); return retval; } - + /* * This function releases an inode. Returns 1 if an inconsistency was * found. If the inode has a link count, then it is being truncated and @@ -180,7 +180,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, pb.truncate_offset = 0; } pb.truncated_blocks = 0; - retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, + retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, block_buf, release_inode_block, &pb); if (retval) { com_err("release_inode_blocks", retval, @@ -246,7 +246,7 @@ static int release_orphan_inodes(e2fsck_t ctx) */ if (fs->super->s_state & EXT2_ERROR_FS) return 0; - + if ((ino < EXT2_FIRST_INODE(fs->super)) || (ino > fs->super->s_inodes_count)) { clear_problem_context(&pctx); @@ -258,7 +258,7 @@ static int release_orphan_inodes(e2fsck_t ctx) block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4, "block iterate buffer"); e2fsck_read_bitmaps(ctx); - + while (ino) { e2fsck_read_inode(ctx, ino, &inode, "release_orphan_inodes"); clear_problem_context(&pctx); @@ -317,11 +317,11 @@ static void check_resize_inode(e2fsck_t ctx) clear_problem_context(&pctx); - /* - * If the resize inode feature isn't set, then + /* + * If the resize inode feature isn't set, then * s_reserved_gdt_blocks must be zero. */ - if (!(fs->super->s_feature_compat & + if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) { if (fs->super->s_reserved_gdt_blocks) { pctx.num = fs->super->s_reserved_gdt_blocks; @@ -337,17 +337,17 @@ static void check_resize_inode(e2fsck_t ctx) pctx.ino = EXT2_RESIZE_INO; retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); if (retval) { - if (fs->super->s_feature_compat & + if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) ctx->flags |= E2F_FLAG_RESIZE_INODE; return; } - /* - * If the resize inode feature isn't set, check to make sure + /* + * If the resize inode feature isn't set, check to make sure * the resize inode is cleared; then we're done. */ - if (!(fs->super->s_feature_compat & + if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) { for (i=0; i < EXT2_N_BLOCKS; i++) { if (inode.i_block[i]) @@ -362,7 +362,7 @@ static void check_resize_inode(e2fsck_t ctx) return; } - /* + /* * The resize inode feature is enabled; check to make sure the * only block in use is the double indirect block */ @@ -398,13 +398,13 @@ static void check_resize_inode(e2fsck_t ctx) gdt_off = fs->desc_blocks; pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks; - for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4; + for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4; i++, gdt_off++, pblk++) { gdt_off %= fs->blocksize/4; if (dind_buf[gdt_off] != pblk) goto resize_inode_invalid; retval = ext2fs_read_ind_block(fs, pblk, ind_buf); - if (retval) + if (retval) goto resize_inode_invalid; ind_off = 0; for (j = 1; j < fs->group_desc_count; j++) { @@ -510,7 +510,7 @@ void check_super_block(e2fsck_t ctx) MIN_CHECK | MAX_CHECK, inodes_per_block, ipg_max); check_super_value(ctx, "r_blocks_count", sb->s_r_blocks_count, MAX_CHECK, 0, sb->s_blocks_count / 2); - check_super_value(ctx, "reserved_gdt_blocks", + check_super_value(ctx, "reserved_gdt_blocks", sb->s_reserved_gdt_blocks, MAX_CHECK, 0, fs->blocksize/4); inode_size = EXT2_INODE_SIZE(sb); @@ -524,7 +524,7 @@ void check_super_block(e2fsck_t ctx) ctx->flags |= E2F_FLAG_ABORT; /* never get here! */ return; } - + if ((ctx->flags & E2F_FLAG_GOT_DEVSIZE) && (ctx->num_blocks < sb->s_blocks_count)) { pctx.blk = sb->s_blocks_count; @@ -544,7 +544,7 @@ void check_super_block(e2fsck_t ctx) } should_be = sb->s_frags_per_group >> - (sb->s_log_block_size - sb->s_log_frag_size); + (sb->s_log_block_size - sb->s_log_frag_size); if (sb->s_blocks_per_group != should_be) { pctx.blk = sb->s_blocks_per_group; pctx.blk2 = should_be; @@ -701,7 +701,7 @@ void check_super_block(e2fsck_t ctx) ext2fs_mark_super_dirty(fs); } } - + if ((sb->s_free_blocks_count > sb->s_blocks_count) || (sb->s_free_inodes_count > sb->s_inodes_count)) ext2fs_unmark_valid(fs); @@ -717,7 +717,7 @@ void check_super_block(e2fsck_t ctx) } clear_problem_context(&pctx); - + #ifndef EXT2_SKIP_UUID /* * If the UUID field isn't assigned, assign it. @@ -795,7 +795,7 @@ void check_super_block(e2fsck_t ctx) 0, 0, &buggy_init_scripts); ctx->time_fudge = buggy_init_scripts ? 86400 : 0; - /* + /* * Check to see if the superblock last mount time or last * write time is in the future. */ diff --git a/e2fsck/unix.c b/e2fsck/unix.c index be576848..07549b92 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1,6 +1,6 @@ /* * unix.c - The unix-specific code for e2fsck - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -119,7 +119,7 @@ static void show_stats(e2fsck_t ctx) frag_percent = (10000 * ctx->fs_fragmented) / inodes_used; frag_percent = (frag_percent + 5) / 10; - + if (!verbose) { printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %u/%u blocks\n"), ctx->device_name, inodes_used, inodes, @@ -236,7 +236,7 @@ static int is_on_batt(void) f = fopen("/proc/apm", "r"); if (f) { - if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4) + if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4) acflag = 1; fclose(f); return (acflag != 1); @@ -246,7 +246,7 @@ static int is_on_batt(void) while ((de=readdir(d)) != NULL) { if (!strncmp(".", de->d_name, 1)) continue; - snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state", + snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state", de->d_name); f = fopen(fname, "r"); if (!f) @@ -280,14 +280,14 @@ static void check_if_skip(e2fsck_t ctx) time_t lastcheck; profile_get_boolean(ctx->profile, "options", - "defer_check_on_battery", 0, 1, + "defer_check_on_battery", 0, 1, &defer_check_on_battery); if (!defer_check_on_battery) batt = 0; if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag) return; - + lastcheck = fs->super->s_lastcheck; if (lastcheck > ctx->now) lastcheck -= ctx->time_fudge; @@ -303,7 +303,7 @@ static void check_if_skip(e2fsck_t ctx) (unsigned) fs->super->s_max_mnt_count)) { reason = _(" has been mounted %u times without being checked"); reason_arg = fs->super->s_mnt_count; - if (batt && (fs->super->s_mnt_count < + if (batt && (fs->super->s_mnt_count < (unsigned) fs->super->s_max_mnt_count*2)) reason = 0; } else if (fs->super->s_checkinterval && (ctx->now < lastcheck)) { @@ -311,11 +311,11 @@ static void check_if_skip(e2fsck_t ctx) if (batt) reason = 0; } else if (fs->super->s_checkinterval && - ((ctx->now - lastcheck) >= + ((ctx->now - lastcheck) >= ((time_t) fs->super->s_checkinterval))) { reason = _(" has gone %u days without being checked"); reason_arg = (ctx->now - fs->super->s_lastcheck)/(3600*24); - if (batt && ((ctx->now - fs->super->s_lastcheck) < + if (batt && ((ctx->now - fs->super->s_lastcheck) < fs->super->s_checkinterval*2)) reason = 0; } @@ -333,7 +333,7 @@ static void check_if_skip(e2fsck_t ctx) next_check = 100000; if (fs->super->s_max_mnt_count > 0) { next_check = fs->super->s_max_mnt_count - fs->super->s_mnt_count; - if (next_check <= 0) + if (next_check <= 0) next_check = 1; } if (fs->super->s_checkinterval && @@ -341,7 +341,7 @@ static void check_if_skip(e2fsck_t ctx) next_check = 1; if (next_check <= 5) { if (next_check == 1) { - if (batt) + if (batt) fputs(_(" (check deferred; on battery)"), stdout); else @@ -372,7 +372,7 @@ static float calc_percent(struct percent_tbl *tbl, int pass, int curr, int max) { float percent; - + if (pass <= 0) return 0.0; if (pass > tbl->max_pass || max == 0) @@ -386,7 +386,7 @@ extern void e2fsck_clear_progbar(e2fsck_t ctx) { if (!(ctx->flags & E2F_FLAG_PROG_BAR)) return; - + printf("%s%s\r%s", ctx->start_meta, spaces + (sizeof(spaces) - 80), ctx->stop_meta); fflush(stdout); @@ -409,7 +409,7 @@ int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent, /* * Calculate the new progress position. If the * percentage hasn't changed, then we skip out right - * away. + * away. */ fixed_percent = (int) ((10 * percent) + 0.5); if (ctx->progress_last_percent == fixed_percent) @@ -454,7 +454,7 @@ int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent, else fputs(" \r", stdout); fputs(ctx->stop_meta, stdout); - + if (fixed_percent == 1000) e2fsck_clear_progbar(ctx); fflush(stdout); @@ -470,9 +470,9 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass, if (pass == 0) return 0; - + if (ctx->progress_fd) { - snprintf(buf, sizeof(buf), "%d %lu %lu %s\n", + snprintf(buf, sizeof(buf), "%d %lu %lu %s\n", pass, cur, max, ctx->device_name); write(ctx->progress_fd, buf, strlen(buf)); } else { @@ -594,7 +594,7 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts) static void syntax_err_report(const char *filename, long err, int line_num) { - fprintf(stderr, + fprintf(stderr, _("Syntax error in e2fsck config file (%s, line #%d)\n\t%s\n"), filename, line_num, error_message(err)); exit(FSCK_ERROR); @@ -640,7 +640,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) add_error_table(&et_ext2_error_table); add_error_table(&et_prof_error_table); blkid_get_cache(&ctx->blkid, NULL); - + if (argc && *argv) ctx->program_name = *argv; else @@ -681,7 +681,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) case 'a': if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) { conflict_opt: - fatal_error(ctx, + fatal_error(ctx, _("Only one of the options -p/-a, -n or -y may be specified.")); } ctx->options |= E2F_OPT_PREEN; @@ -780,11 +780,11 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) ctx->options |= E2F_OPT_READONLY; ctx->io_options = strchr(argv[optind], '?'); - if (ctx->io_options) + if (ctx->io_options) *ctx->io_options++ = 0; ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0); if (!ctx->filesystem_name) { - com_err(ctx->program_name, 0, _("Unable to resolve '%s'"), + com_err(ctx->program_name, 0, _("Unable to resolve '%s'"), argv[optind]); fatal_error(ctx, 0); } @@ -895,7 +895,7 @@ int main (int argc, char *argv[]) int sysval, sys_page_size = 4096; __u32 features[3]; char *cp; - + clear_problem_context(&pctx); #ifdef MTRACE mtrace(); @@ -916,7 +916,7 @@ int main (int argc, char *argv[]) "out of date!\n")); show_version_only++; } - + retval = PRS(argc, argv, &ctx); if (retval) { com_err("e2fsck", retval, @@ -924,7 +924,7 @@ int main (int argc, char *argv[]) exit(FSCK_ERROR); } reserve_stdio_fds(); - + #ifdef RESOURCE_TRACK init_resource_track(&ctx->global_rtrack, NULL); #endif @@ -938,9 +938,9 @@ int main (int argc, char *argv[]) error_message(EXT2_ET_BASE), lib_ver_date); exit(FSCK_OK); } - + check_mount(ctx); - + if (!(ctx->options & E2F_OPT_PREEN) && !(ctx->options & E2F_OPT_NO) && !(ctx->options & E2F_OPT_YES)) { @@ -963,22 +963,22 @@ restart: flags |= EXT2_FLAG_EXCLUSIVE; if (ctx->superblock && ctx->blocksize) { - retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, + retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, flags, ctx->superblock, ctx->blocksize, io_ptr, &fs); } else if (ctx->superblock) { int blocksize; for (blocksize = EXT2_MIN_BLOCK_SIZE; blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) { - retval = ext2fs_open2(ctx->filesystem_name, + retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, flags, ctx->superblock, blocksize, io_ptr, &fs); if (!retval) break; } - } else - retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, + } else + retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, flags, 0, 0, io_ptr, &fs); if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) && !(ctx->flags & E2F_FLAG_SB_SPECIFIED) && @@ -991,7 +991,7 @@ restart: } if (!fs || (fs->group_desc_count > 1)) { printf(_("%s: %s trying backup blocks...\n"), - ctx->program_name, + ctx->program_name, retval ? _("Superblock invalid,") : _("Group descriptors look bad...")); get_backup_sb(ctx, fs, ctx->filesystem_name, io_ptr); @@ -1005,11 +1005,11 @@ restart: (retval == EXT2_ET_RO_UNSUPP_FEATURE)) && fs && fs->super) { sb = fs->super; - features[0] = (sb->s_feature_compat & + features[0] = (sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP); - features[1] = (sb->s_feature_incompat & + features[1] = (sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP); - features[2] = (sb->s_feature_ro_compat & + features[2] = (sb->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP); if (features[0] || features[1] || features[2]) goto print_unsupp_features; @@ -1077,8 +1077,8 @@ restart: if (pctx.errcode == EBUSY) { ext2fs_close(fs); need_restart++; - pctx.errcode = - ext2fs_get_device_size(ctx->filesystem_name, + pctx.errcode = + ext2fs_get_device_size(ctx->filesystem_name, blocksize, &ctx->num_blocks); } @@ -1174,20 +1174,20 @@ restart: */ features[0] = sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP; features[1] = sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP; - features[2] = (sb->s_feature_ro_compat & + features[2] = (sb->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP); print_unsupp_features: if (features[0] || features[1] || features[2]) { int i, j; __u32 *mask = features, m; - fprintf(stderr, _("%s has unsupported feature(s):"), + fprintf(stderr, _("%s has unsupported feature(s):"), ctx->filesystem_name); for (i=0; i <3; i++,mask++) { for (j=0,m=1; j < 32; j++, m<<=1) { if (*mask & m) - fprintf(stderr, " %s", + fprintf(stderr, " %s", e2p_feature2string(i, m)); } } @@ -1283,7 +1283,7 @@ print_unsupp_features: fs->super->s_feature_compat &= ~EXT3_FEATURE_COMPAT_HAS_JOURNAL; fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; - com_err(ctx->program_name, 0, + com_err(ctx->program_name, 0, _("Couldn't determine journal size")); goto no_journal; } @@ -1342,7 +1342,7 @@ no_journal: } } if (!ext2fs_test_valid(fs) || - ((exit_value & FSCK_CANCELED) && + ((exit_value & FSCK_CANCELED) && (sb->s_state & EXT2_ERROR_FS))) { printf(_("\n%s: ********** WARNING: Filesystem still has " "errors **********\n\n"), ctx->device_name); @@ -1353,11 +1353,11 @@ no_journal: int allow_cancellation; profile_get_boolean(ctx->profile, "options", - "allow_cancellation", 0, 0, + "allow_cancellation", 0, 0, &allow_cancellation); exit_value &= ~FSCK_NONDESTRUCT; if (allow_cancellation && ext2fs_test_valid(fs) && - (sb->s_state & EXT2_VALID_FS) && + (sb->s_state & EXT2_VALID_FS) && !(sb->s_state & EXT2_ERROR_FS)) exit_value = 0; } else { diff --git a/e2fsck/util.c b/e2fsck/util.c index fc350392..256100c1 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -1,6 +1,6 @@ /* * util.c --- miscellaneous utilities - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -42,7 +42,7 @@ extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ void fatal_error(e2fsck_t ctx, const char *msg) { - if (msg) + if (msg) fprintf (stderr, "e2fsck: %s\n", msg); if (ctx->fs && ctx->fs->io) { if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL) @@ -74,11 +74,11 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size, return ret; } -char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)), +char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)), const char *str, int len) { char *ret; - + if (!str) return NULL; if (!len) @@ -272,7 +272,7 @@ void init_resource_track(struct resource_track *track, io_channel channel) struct rusage r; #endif io_stats io_start = 0; - + track->brk_start = sbrk(0); gettimeofday(&track->time_start, 0); #ifdef HAVE_GETRUSAGE @@ -327,7 +327,7 @@ void print_resource_track(const char *desc, struct resource_track *track, #ifdef HAVE_MALLINFO #define kbytes(x) (((x) + 1023) / 1024) - + malloc_info = mallinfo(); printf(_("Memory used: %dk/%dk (%dk/%dk), "), kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd), @@ -335,7 +335,7 @@ void print_resource_track(const char *desc, struct resource_track *track, #else printf(_("Memory used: %d, "), (int) (((char *) sbrk(0)) - ((char *) track->brk_start))); -#endif +#endif #ifdef HAVE_GETRUSAGE getrusage(RUSAGE_SELF, &r); @@ -359,7 +359,7 @@ void print_resource_track(const char *desc, struct resource_track *track, channel->manager->get_stats(channel, &delta); if (delta) { bytes_read = delta->bytes_read - track->bytes_read; - bytes_written = delta->bytes_written - + bytes_written = delta->bytes_written - track->bytes_written; } printf("I/O read: %lluMB, write: %lluMB, rate: %.2fMB/s\n", @@ -443,7 +443,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, void *buf = NULL; int blocksize; blk_t superblock, ret_sb = 8193; - + if (fs && fs->super) { ret_sb = (fs->super->s_blocks_per_group + fs->super->s_first_data_block); @@ -453,7 +453,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, } return ret_sb; } - + if (ctx) { if (ctx->blocksize) { ret_sb = ctx->blocksize * 8; @@ -518,22 +518,22 @@ int ext2_file_type(unsigned int mode) if (LINUX_S_ISDIR(mode)) return EXT2_FT_DIR; - + if (LINUX_S_ISCHR(mode)) return EXT2_FT_CHRDEV; - + if (LINUX_S_ISBLK(mode)) return EXT2_FT_BLKDEV; - + if (LINUX_S_ISLNK(mode)) return EXT2_FT_SYMLINK; if (LINUX_S_ISFIFO(mode)) return EXT2_FT_FIFO; - + if (LINUX_S_ISSOCK(mode)) return EXT2_FT_SOCK; - + return 0; } diff --git a/ext2ed/blockbitmap_com.c b/ext2ed/blockbitmap_com.c index 355feb03..996bbeb4 100644 --- a/ext2ed/blockbitmap_com.c +++ b/ext2ed/blockbitmap_com.c @@ -41,9 +41,9 @@ and dispatches a show command to show the new entry. { unsigned long entry_num; char *ptr,buffer [80]; - - - + + + ptr=parse_word (command_line,buffer); /* Get the requested entry */ if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n"); @@ -53,15 +53,15 @@ and dispatches a show command to show the new entry. entry_num=atol (buffer); - + if (entry_num >= file_system_info.super_block.s_blocks_per_group) { /* Check if it is a valid entry number */ wprintw (command_win,"Error - Entry number out of bounds\n"); refresh_command_win ();return; } - - - + + + block_bitmap_info.entry_num=entry_num; /* If it is, just change entry_num and */ strcpy (buffer,"show");dispatch (buffer); /* dispatch a show command */ } @@ -77,7 +77,7 @@ This function passes to the next entry in the bitmap. We just call the above ent { long entry_offset=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); @@ -93,7 +93,7 @@ void type_ext2_block_bitmap___prev (char *command_line) { long entry_offset=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); @@ -117,25 +117,25 @@ we need to allocate, and call allocate_block for each one. { long entry_num,num=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); /* Get the number of blocks to allocate */ if (*ptr!=0) { ptr=parse_word (ptr,buffer); num=atol (buffer); } - + entry_num=block_bitmap_info.entry_num; /* Check for limits */ if (num > file_system_info.super_block.s_blocks_per_group-entry_num) { - wprintw (command_win,"Error - There aren't that much blocks in the group\n"); - refresh_command_win ();return; + wprintw (command_win,"Error - There aren't that much blocks in the group\n"); + refresh_command_win ();return; } - + while (num) { /* And call allocate_block */ allocate_block (entry_num); /* for each block */ num--;entry_num++; } - + dispatch ("show"); /* Show the result */ } @@ -146,24 +146,24 @@ void type_ext2_block_bitmap___deallocate (char *command_line) { long entry_num,num=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); num=atol (buffer); } - + entry_num=block_bitmap_info.entry_num; if (num > file_system_info.super_block.s_blocks_per_group-entry_num) { - wprintw (command_win,"Error - There aren't that much blocks in the group\n"); - refresh_command_win ();return; + wprintw (command_win,"Error - There aren't that much blocks in the group\n"); + refresh_command_win ();return; } - + while (num) { deallocate_block (entry_num); num--;entry_num++; } - + dispatch ("show"); } @@ -175,7 +175,7 @@ void allocate_block (long entry_num) { unsigned char bit_mask=1; int byte_offset,j; - + byte_offset=entry_num/8; /* Find the correct byte - entry_num/8 */ /* The position inside the byte is entry_num %8 */ for (j=0;j<entry_num%8;j++) @@ -190,12 +190,12 @@ void deallocate_block (long entry_num) { unsigned char bit_mask=1; int byte_offset,j; - + byte_offset=entry_num/8; for (j=0;j<entry_num%8;j++) bit_mask*=2; bit_mask^=0xff; - + type_data.u.buffer [byte_offset] &= bit_mask; } @@ -215,7 +215,7 @@ The current position (as known from block_bitmap_info.entry_num) is highlighted. ptr=type_data.u.buffer; show_pad_info.line=0;show_pad_info.max_line=-1; - + wmove (show_pad,0,0); for (i=0,entry_num=0;i<file_system_info.super_block.s_blocks_per_group/8;i++,ptr++) { for (j=1;j<=128;j*=2) { /* j contains the and bit mask */ @@ -240,24 +240,24 @@ The current position (as known from block_bitmap_info.entry_num) is highlighted. show_pad_info.max_line++; } } - - refresh_show_pad (); + + refresh_show_pad (); show_info (); /* Show the usual information */ /* Show the group number */ wmove (show_win,1,0); wprintw (show_win,"Block bitmap of block group %ld\n",block_bitmap_info.group_num); /* Show the block number */ - + block_num=block_bitmap_info.entry_num+block_bitmap_info.group_num*file_system_info.super_block.s_blocks_per_group; - block_num+=file_system_info.super_block.s_first_data_block; + block_num+=file_system_info.super_block.s_first_data_block; wprintw (show_win,"Status of block %ld - ",block_num); /* and the allocation status */ ptr=type_data.u.buffer+block_bitmap_info.entry_num/8; j=1; for (i=block_bitmap_info.entry_num % 8;i>0;i--) j*=2; - if ((*ptr) & j) + if ((*ptr) & j) wprintw (show_win,"Allocated\n"); else wprintw (show_win,"Free\n"); diff --git a/ext2ed/dir_com.c b/ext2ed/dir_com.c index c6b194e0..b023e7a3 100644 --- a/ext2ed/dir_com.c +++ b/ext2ed/dir_com.c @@ -49,20 +49,20 @@ directories. { struct ext2_inode *ptr; - + ptr=&type_data.u.t_ext2_inode; /* type_data contains the inode */ - + info_ptr->inode_ptr=ptr; info_ptr->inode_offset=device_offset; /* device offset contains the inode's offset */ - + /* Reset the current position to the start */ - info_ptr->global_block_num=ptr->i_block [0]; + info_ptr->global_block_num=ptr->i_block [0]; info_ptr->global_block_offset=ptr->i_block [0]*file_system_info.block_size; info_ptr->block_num=0; info_ptr->file_offset=0; /* Set the size of the directory */ - + info_ptr->blocks_count=(ptr->i_size+file_system_info.block_size-1)/file_system_info.block_size; info_ptr->file_length=ptr->i_size; @@ -73,9 +73,9 @@ directories. info_ptr->dir_entry_offset=0; /* Find dir_entries_count */ - + info_ptr->dir_entries_count=count_dir_entries (); /* Set the total number of entries */ - + return (1); } @@ -86,34 +86,34 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in This routine runs on all directory entries in the current directory. For each entry, action is called. We'll act according to the return code of action: - + ABORT - Current dir entry is returned. CONTINUE - Continue searching. FOUND - Current dir entry is returned. - + If the last entry is reached, it is returned, along with an ABORT status. - - status is updated to the returned code of action. + + status is updated to the returned code of action. */ { struct struct_file_info info; /* Temporary variables used to */ struct ext2_dir_entry_2 *dir_entry_ptr; /* contain the current search entries */ int return_code, next; - + info=first_file_info; /* Start from the first entry - Read it */ low_read (info.buffer,file_system_info.block_size,info.global_block_offset); dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset); - + while (info.file_offset < info.file_length) { /* While we haven't reached the end */ - + *status=return_code=action (&info); /* Call the client function to test */ - /* the current entry */ + /* the current entry */ if (return_code==ABORT || return_code==FOUND) return (info); /* Stop, if so asked */ /* Pass to the next entry */ - + dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset); info.dir_entry_num++; @@ -131,16 +131,16 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in info.global_block_num=file_block_to_global_block (info.block_num,&info); info.global_block_offset=info.global_block_num*file_system_info.block_size; info.file_offset=info.block_num*file_system_info.block_size; - info.dir_entry_offset=0; + info.dir_entry_offset=0; /* read it and update the pointer */ - + low_read (info.buffer,file_system_info.block_size,info.global_block_offset); dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset); - + } - + } - + *status=ABORT;return (info); /* There was no match */ } @@ -155,7 +155,7 @@ The client function is action_count, which just tell search_dir_entries to conti { int status; - + return (search_dir_entries (&action_count,&status).dir_entry_num); } @@ -187,7 +187,7 @@ void type_dir___cd (char *command_line) 1 and into 2/3/4. 3. It is the first part of the path that we need to search for in the current directory. We search for it using - search_dir_entries, which accepts the action_name function as the client function. + search_dir_entries, which accepts the action_name function as the client function. 4. search_dir_entries will scan the entire entries and will call our action_name function for each entry. In action_name, the required name will be checked against the name of the current entry, and FOUND will be @@ -205,7 +205,7 @@ void type_dir___cd (char *command_line) 7. We check the inode's type to see if it is a directory. If it is, we dispatch a dir command to "enter the directory", and recursively call ourself (The type is dir again) by dispatching a cd command, with the rest of the path as an argument. - + 8. If the inode's type is a symbolic link (only fast symbolic link were meanwhile implemented. I guess this is typically the case.), we note the path it is pointing at, the saved inode is recalled, we dispatch dir to get back to the original directory, and we call ourself again with the link path/rest of the path argument. @@ -221,9 +221,9 @@ void type_dir___cd (char *command_line) struct ext2_dir_entry_2 *dir_entry_ptr; dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset); - + ptr=parse_word (command_line,dir_name); - + if (*ptr==0) { /* cd alone will enter the highlighted directory */ strncpy (full_dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len); full_dir_name [dir_entry_ptr->name_len]=0; @@ -232,11 +232,11 @@ void type_dir___cd (char *command_line) ptr=parse_word (ptr,full_dir_name); ptr=strchr (full_dir_name,'/'); - + if (ptr==full_dir_name) { /* Pathname is from root - Let the general cd do the job */ sprintf (temp,"cd %s",full_dir_name);type_ext2___cd (temp);return; } - + if (ptr==NULL) { strcpy (dir_name,full_dir_name); full_dir_name [0]=0; @@ -251,7 +251,7 @@ void type_dir___cd (char *command_line) /* full_dir_name contains the rest */ strcpy (name_search,dir_name); /* name_search is used to hold the required entry name */ - + if (dir_entry_ptr->name_len != strlen (dir_name) || strncmp (dir_name,dir_entry_ptr->name,dir_entry_ptr->name_len)!=0) info=search_dir_entries (&action_name,&status); /* Search for the entry. Answer in info. */ @@ -262,15 +262,15 @@ void type_dir___cd (char *command_line) if (status==FOUND) { /* If found */ file_info=info; /* Switch to it, by setting the global file_info */ dispatch ("remember internal_variable"); /* Move the inode into the objects memory */ - + dispatch ("followinode"); /* Go to the inode pointed by this directory entry */ - + if (S_ISLNK (type_data.u.t_ext2_inode.i_mode)) {/* Symbolic link ? */ if (type_data.u.t_ext2_inode.i_size > 60) { /* I'm lazy, I guess :-) */ wprintw (command_win,"Error - Sorry, Only fast symbolic link following is currently supported\n"); refresh_command_win (); - return; + return; } /* Get the pointed name and append the previous path */ @@ -280,10 +280,10 @@ void type_dir___cd (char *command_line) dispatch ("recall internal_variable"); /* Return to the original inode */ dispatch ("dir"); /* and to the directory */ - + sprintf (temp,"cd %s",temp2); /* And continue from there by dispatching a cd command */ dispatch (temp); /* (which can call ourself or the general cd) */ - + return; } @@ -295,16 +295,16 @@ void type_dir___cd (char *command_line) sprintf (temp,"cd %s",full_dir_name); dispatch (temp); } - + return; } - + else { /* If we can't continue from here, we'll just stop */ wprintw (command_win,"Can\'t continue - Stopping at last inode\n");refresh_command_win (); return; } } - + wprintw (command_win,"Error - Directory entry %s not found.\n",dir_name); /* Hmm, an invalid path somewhere */ refresh_command_win (); } @@ -325,7 +325,7 @@ Returns FOUND if found, or CONTINUE if not found. if (dir_entry_ptr->name_len != strlen (name_search)) return (CONTINUE); - + if (strncmp (dir_entry_ptr->name,name_search,dir_entry_ptr->name_len)==0) return (FOUND); @@ -345,7 +345,7 @@ search_dir_entries is used along with action_entry_num, in the same fashion as t int status; struct struct_file_info info; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - Argument_not_specified\n");wrefresh (command_win); @@ -353,7 +353,7 @@ search_dir_entries is used along with action_entry_num, in the same fashion as t } ptr=parse_word (ptr,buffer); entry_num_search=atol (buffer); - + if (entry_num_search < 0 || entry_num_search >= file_info.dir_entries_count) { wprintw (command_win,"Error - Entry number out of range\n");wrefresh (command_win); return; @@ -431,7 +431,7 @@ We use search_dir_entries to run on all the entries. Each time, action_show will { int status; - + wmove (show_pad,0,0); show_pad_info.max_line=-1; @@ -452,7 +452,7 @@ Show the current search entry (info) in one line. If the entry happens to be the { unsigned char temp [80]; struct ext2_dir_entry_2 *dir_entry_ptr; - + dir_entry_ptr=(struct ext2_dir_entry_2 *) (info->buffer+info->dir_entry_offset); if (info->dir_entry_num == file_info.dir_entry_num) /* Highlight the current entry */ @@ -486,7 +486,7 @@ This function moves to the next directory entry. It just uses the current inform char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); offset*=atol (buffer); @@ -503,7 +503,7 @@ void type_dir___prev (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); offset*=atol (buffer); @@ -522,12 +522,12 @@ Various statistics about the directory. { long inode_num; - + wmove (show_win,0,0); wprintw (show_win,"Directory listing. Block %ld. ",file_info.global_block_num); wprintw (show_win,"Directory entry %ld of %ld.\n",file_info.dir_entry_num,file_info.dir_entries_count-1); wprintw (show_win,"Directory Offset %ld of %ld. ",file_info.file_offset,file_info.file_length-1); - + inode_num=inode_offset_to_inode_num (file_info.inode_offset); wprintw (show_win,"File inode %ld. Indirection level %ld.\n",inode_num,file_info.level); @@ -548,14 +548,14 @@ inode of the current directory. long entry_num; char *ptr,buffer [80]; struct struct_descriptor *descriptor_ptr; - + ptr=parse_word (command_line,buffer); - + if (*ptr==0) { wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win); - return; + return; } - + ptr=parse_word (ptr,buffer); entry_num=remember_lifo.entries_count++; @@ -563,7 +563,7 @@ inode of the current directory. entry_num=0; remember_lifo.entries_count--; } - + descriptor_ptr=first_type; while (descriptor_ptr!=NULL && !found) { if (strcmp (descriptor_ptr->name,"ext2_inode")==0) @@ -576,7 +576,7 @@ inode of the current directory. remember_lifo.offset [entry_num]=device_offset; remember_lifo.type [entry_num]=descriptor_ptr; strcpy (remember_lifo.name [entry_num],buffer); - + wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer); wrefresh (command_win); } @@ -594,9 +594,9 @@ because it is of variable length. int found=0; unsigned char *ptr,buffer [80],variable [80],value [80],temp [80]; struct ext2_dir_entry_2 *dir_entry_ptr; - + dir_entry_ptr=(struct ext2_dir_entry_2 *) (file_info.buffer+file_info.dir_entry_offset); - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - Missing arguments\n");refresh_command_win (); @@ -641,7 +641,7 @@ because it is of variable length. wprintw (command_win,"Variable %s set to %s\n",variable,value);refresh_command_win (); } - + if (found) { wattrset (show_pad,A_REVERSE); strncpy (temp,dir_entry_ptr->name,dir_entry_ptr->name_len); @@ -654,7 +654,7 @@ because it is of variable length. refresh_show_pad (); show_dir_status (); } - + else { wprintw (command_win,"Error - Variable %s not found\n",variable); refresh_command_win (); diff --git a/ext2ed/disk.c b/ext2ed/disk.c index d29c7194..5e1cd7e2 100644 --- a/ext2ed/disk.c +++ b/ext2ed/disk.c @@ -55,7 +55,7 @@ This function is used when we need to read something from the filesystem. return (0); } -#endif +#endif if ( (fseek (device_handle,offset,SEEK_SET))==-1) { /* Seek to the required offset */ wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",offset,device_name); @@ -67,7 +67,7 @@ This function is used when we need to read something from the filesystem. wprintw (command_win,"Error - Failed to read from offset %ld in device %s\n",offset,device_name); refresh_command_win ();return (0); }; - + return (1); } @@ -83,7 +83,7 @@ If logging is enabled, we log the change before writing it to the device. */ { char temp [80]; - + if (!write_access) { wprintw (command_win,"Error - Write access not aviable (use enablewrite)\n"); return (0); @@ -95,7 +95,7 @@ If logging is enabled, we log the change before writing it to the device. internal_error ("AllowChanges=0 yet enablewrite succeeded","disk","low_write"); return (0); } - + if (device_handle==NULL) { internal_error ("No device opened yet read requested","disk","low_write"); return (0); @@ -107,7 +107,7 @@ If logging is enabled, we log the change before writing it to the device. return (0); } -#endif +#endif if (LogChanges) if (!log_changes (buffer,length,offset)) @@ -124,7 +124,7 @@ If logging is enabled, we log the change before writing it to the device. refresh_command_win ();return (0); }; - wprintw (command_win,"Data written");refresh_command_win (); + wprintw (command_win,"Data written");refresh_command_win (); return (1); } @@ -139,29 +139,29 @@ The hex bytes are converted to text, so that they will be readable with a standa { unsigned char *original; - + int i; time_t current_time; FILE *fp; - + if ((fp=fopen (LogFile,"a+"))==NULL) { wprintw (command_win,"Error - Unable to open log file %s\n",LogFile); refresh_command_win ();return (0); }; current_time=time (NULL); - + fprintf (fp,"\n----- EXT2ED log begin -----\n\n"); fprintf (fp,"Time: %s\nDevice: %s\n",ctime ((time_t *) ¤t_time),device_name); fprintf (fp,"Offset: %lu\nLength: %lu\n",offset,length); - + original=(unsigned char *) malloc (length*sizeof (unsigned char)); if (original==NULL) { wprintw (command_win,"Fatal error - Can\'t allocate %lu bytes!"); refresh_command_win ();fclose (fp);return (0); } - + if (!low_read (original,length,offset)) { fclose (fp);return (0); } @@ -172,17 +172,17 @@ The hex bytes are converted to text, so that they will be readable with a standa if (i%16==0 && i!=0) fprintf (fp,"\n"); fprintf (fp,"%02x ",original [i]); } - - fprintf (fp,"\n\nNew data:\n\n"); - + + fprintf (fp,"\n\nNew data:\n\n"); + for (i=0;i<length;i++) { if (i%16==0 && i!=0) fprintf (fp,"\n"); fprintf (fp,"%02x ",buffer [i]); } - + fprintf (fp,"\n----- EXT2ED log end -----\n"); - fclose (fp); + fclose (fp); return (1); } @@ -197,17 +197,17 @@ Just read from the current position into type data. { if (device_handle==NULL) { printf ("Error - No device opened\n"); - return (0); + return (0); } if (device_offset==-1) { printf ("Error - No offset set\n"); return (0); } - + if (low_read (type_data.u.buffer,EXT2_MAX_BLOCK_SIZE,device_offset)==0) return (0); - + if (current_type!=NULL) if (strcmp (current_type->name,"ext2_dir_entry")==0) current_type->length=type_data.u.t_ext2_dir_entry.rec_len; @@ -221,7 +221,7 @@ int write_type_data (void) if (device_handle==NULL) { wprintw (command_win,"Error - No device opened\n"); refresh_command_win (); - return (0); + return (0); } if (device_offset==-1) { @@ -229,10 +229,10 @@ int write_type_data (void) refresh_command_win (); return (0); } - + if (low_write (type_data.u.buffer,file_system_info.block_size,device_offset)==0) return (0); - + return (1); } diff --git a/ext2ed/ext2_com.c b/ext2ed/ext2_com.c index b4d2a661..2f20a28d 100644 --- a/ext2ed/ext2_com.c +++ b/ext2ed/ext2_com.c @@ -33,7 +33,7 @@ initialization phase (but is constant - 1024). { char buffer [80]; - + super_info.copy_num=0; sprintf (buffer,"setoffset %ld",file_system_info.super_block_offset);dispatch (buffer); sprintf (buffer,"settype ext2_super_block");dispatch (buffer); @@ -51,13 +51,13 @@ We implement it through dispatching to our primitive functions. { char temp [80],buffer [80],*ptr; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return; } ptr=parse_word (ptr,buffer); - + if (buffer [0] != '/') { wprintw (command_win,"Error - Use a full pathname (begin with '/')\n");refresh_command_win ();return; } @@ -83,7 +83,7 @@ Then, we use the group's entry command to pass to another group. { long group_num=0; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); diff --git a/ext2ed/ext2ed.h b/ext2ed/ext2ed.h index deae516b..2ee483e8 100644 --- a/ext2ed/ext2ed.h +++ b/ext2ed/ext2ed.h @@ -45,14 +45,14 @@ Copyright (C) 1995 Gadi Oxman #define MAX_COMMANDS_NUM 30 /* Maximum number of commands of one type */ #define REMEMBER_COUNT 30 /* Object memory size */ -/* +/* The user screen consists of four parts: 1. Title window (title_win). 2. Show (status) window (show_win). 3. Main show pad (show_pad). 4. Command window (command_win). - + */ /* @@ -133,7 +133,7 @@ struct struct_file_system_info { /* Important information about the filesystem struct struct_file_info { /* Used to handle files and directories */ struct ext2_inode *inode_ptr; - + long inode_offset; long global_block_num,global_block_offset; long block_num,blocks_count; @@ -144,7 +144,7 @@ struct struct_file_info { /* Used to handle files and directories */ int display; /* The following is used if the file is a directory */ - + long dir_entry_num,dir_entries_count; long dir_entry_offset; }; diff --git a/ext2ed/file_com.c b/ext2ed/file_com.c index 898df657..9772f66d 100644 --- a/ext2ed/file_com.c +++ b/ext2ed/file_com.c @@ -24,9 +24,9 @@ int init_file_info (void) { struct ext2_inode *ptr; - + ptr=&type_data.u.t_ext2_inode; - + file_info.inode_ptr=ptr; file_info.inode_offset=device_offset; @@ -38,11 +38,11 @@ int init_file_info (void) file_info.file_length=ptr->i_size; file_info.level=0; file_info.offset_in_block=0; - + file_info.display=HEX; low_read (file_info.buffer,file_system_info.block_size,file_info.global_block_offset); - + return (1); } @@ -69,7 +69,7 @@ void type_file___nextblock (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); block_offset*=atol (buffer); @@ -79,7 +79,7 @@ void type_file___nextblock (char *command_line) wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win); return; } - + file_info.block_num+=block_offset; file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info); file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size; @@ -97,17 +97,17 @@ void type_file___next (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); offset*=atol (buffer); } - + if (file_info.offset_in_block+offset < file_system_info.block_size) { file_info.offset_in_block+=offset; sprintf (buffer,"show");dispatch (buffer); } - + else { wprintw (command_win,"Error - Offset out of block\n");refresh_command_win (); } @@ -120,7 +120,7 @@ void type_file___offset (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); offset=atol (buffer); @@ -129,7 +129,7 @@ void type_file___offset (char *command_line) wprintw (command_win,"Error - Argument not specified\n");refresh_command_win (); return; } - + if (offset < file_system_info.block_size) { file_info.offset_in_block=offset; sprintf (buffer,"show");dispatch (buffer); @@ -147,17 +147,17 @@ void type_file___prev (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); offset*=atol (buffer); } - + if (file_info.offset_in_block-offset >= 0) { file_info.offset_in_block-=offset; sprintf (buffer,"show");dispatch (buffer); } - + else { wprintw (command_win,"Error - Offset out of block\n");refresh_command_win (); } @@ -170,7 +170,7 @@ void type_file___prevblock (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); block_offset*=atol (buffer); @@ -180,7 +180,7 @@ void type_file___prevblock (char *command_line) wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win); return; } - + file_info.block_num-=block_offset; file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info); file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size; @@ -198,12 +198,12 @@ void type_file___block (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr==0) { wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win); return; } - + ptr=parse_word (ptr,buffer); block_offset=atol (buffer); @@ -226,25 +226,25 @@ void type_file___display (char *command_line) { char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); - if (*ptr==0) + if (*ptr==0) strcpy (buffer,"hex"); else ptr=parse_word (ptr,buffer); - + if (strcasecmp (buffer,"hex")==0) { wprintw (command_win,"Display set to hex\n");wrefresh (command_win); file_info.display=HEX; sprintf (buffer,"show");dispatch (buffer); } - + else if (strcasecmp (buffer,"text")==0) { wprintw (command_win,"Display set to text\n");wrefresh (command_win); file_info.display=TEXT; sprintf (buffer,"show");dispatch (buffer); } - + else { wprintw (command_win,"Error - Invalid arguments\n");wrefresh (command_win); } @@ -255,22 +255,22 @@ void file_show_hex (void) { long offset=0,l,i; unsigned char *ch_ptr; - + /* device_offset and type_data points to the inode */ show_pad_info.line=0; - + wmove (show_pad,0,0); ch_ptr=file_info.buffer; for (l=0;l<file_system_info.block_size/16;l++) { if (file_info.file_offset+offset>file_info.file_length-1) break; wprintw (show_pad,"%08ld : ",offset); for (i=0;i<16;i++) { - + if (file_info.file_offset+offset+i>file_info.file_length-1) { wprintw (show_pad," "); } - + else { if (file_info.offset_in_block==offset+i) wattrset (show_pad,A_REVERSE); @@ -297,20 +297,20 @@ void file_show_hex (void) wattrset (show_pad,A_NORMAL); show_pad_info.line=l-l % show_pad_info.display_lines; } - + wprintw (show_pad," "); - + } wprintw (show_pad,"\n"); offset+=i; ch_ptr+=i; } - + show_pad_info.max_line=l-1; - + refresh_show_pad (); - + show_status (); } @@ -319,7 +319,7 @@ void file_show_text (void) { long offset=0,last_offset,l=0,cols=0; unsigned char *ch_ptr; - + /* device_offset and type_data points to the inode */ show_pad_info.line=0; @@ -330,14 +330,14 @@ void file_show_text (void) if (file_info.file_offset+last_offset > file_info.file_length-1) last_offset=file_info.file_length-1-file_info.file_offset; - + while ( (offset <= last_offset) && l<SHOW_PAD_LINES) { if (cols==SHOW_PAD_COLS-1) { wprintw (show_pad,"\n"); l++;cols=0; } - + if (file_info.offset_in_block==offset) wattrset (show_pad,A_REVERSE); @@ -354,7 +354,7 @@ void file_show_text (void) else if (*ch_ptr == 0x9) wprintw (show_pad," "); - + else wprintw (show_pad,"."); } @@ -363,29 +363,29 @@ void file_show_text (void) wattrset (show_pad,A_NORMAL); show_pad_info.line=l-l % show_pad_info.display_lines; } - + offset++;cols++;ch_ptr++; } - + wprintw (show_pad,"\n"); show_pad_info.max_line=l; - + refresh_show_pad (); - - show_status (); + + show_status (); } void show_status (void) { long inode_num; - + werase (show_win);wmove (show_win,0,0); wprintw (show_win,"File contents. Block %ld. ",file_info.global_block_num); wprintw (show_win,"File block %ld of %ld. ",file_info.block_num,file_info.blocks_count-1); wprintw (show_win,"File Offset %ld of %ld.",file_info.file_offset,file_info.file_length-1); - + wmove (show_win,1,0); inode_num=inode_offset_to_inode_num (file_info.inode_offset); wprintw (show_win,"File inode %ld. Indirection level %ld.",inode_num,file_info.level); @@ -400,14 +400,14 @@ void type_file___remember (char *command_line) long entry_num; char *ptr,buffer [80]; struct struct_descriptor *descriptor_ptr; - + ptr=parse_word (command_line,buffer); - + if (*ptr==0) { wprintw (command_win,"Error - Argument not specified\n");wrefresh (command_win); - return; + return; } - + ptr=parse_word (ptr,buffer); entry_num=remember_lifo.entries_count++; @@ -415,7 +415,7 @@ void type_file___remember (char *command_line) entry_num=0; remember_lifo.entries_count--; } - + descriptor_ptr=first_type; while (descriptor_ptr!=NULL && !found) { if (strcmp (descriptor_ptr->name,"ext2_inode")==0) @@ -428,7 +428,7 @@ void type_file___remember (char *command_line) remember_lifo.offset [entry_num]=device_offset; remember_lifo.type [entry_num]=descriptor_ptr; strcpy (remember_lifo.name [entry_num],buffer); - + wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",descriptor_ptr->name,device_offset,buffer); wrefresh (command_win); } @@ -439,7 +439,7 @@ void type_file___set (char *command_line) unsigned char tmp; char *ptr,buffer [80],*ch_ptr; int mode=HEX; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return; @@ -492,7 +492,7 @@ void type_file___set (char *command_line) } } } - + strcpy (buffer,"show");dispatch (buffer); } @@ -507,7 +507,7 @@ long file_block_to_global_block (long file_block,struct struct_file_info *file_i { long last_direct,last_indirect,last_dindirect; - + last_direct=EXT2_NDIR_BLOCKS-1; last_indirect=last_direct+file_system_info.block_size/4; last_dindirect=last_indirect+(file_system_info.block_size/4)*(file_system_info.block_size/4); @@ -516,7 +516,7 @@ long file_block_to_global_block (long file_block,struct struct_file_info *file_i file_info_ptr->level=0; return (file_info_ptr->inode_ptr->i_block [file_block]); } - + if (file_block <= last_indirect) { file_info_ptr->level=1; file_block=file_block-last_direct-1; @@ -538,16 +538,16 @@ long return_indirect (long table_block,long block_num) { long block_table [EXT2_MAX_BLOCK_SIZE/4]; - + low_read ((char *) block_table,file_system_info.block_size,table_block*file_system_info.block_size); - return (block_table [block_num]); + return (block_table [block_num]); } long return_dindirect (long table_block,long block_num) { long f_indirect; - + f_indirect=block_num/(file_system_info.block_size/4); f_indirect=return_indirect (table_block,f_indirect); return (return_indirect (f_indirect,block_num%(file_system_info.block_size/4))); @@ -557,7 +557,7 @@ long return_tindirect (long table_block,long block_num) { long s_indirect; - + s_indirect=block_num/((file_system_info.block_size/4)*(file_system_info.block_size/4)); s_indirect=return_indirect (table_block,s_indirect); return (return_dindirect (s_indirect,block_num%((file_system_info.block_size/4)*(file_system_info.block_size/4)))); diff --git a/ext2ed/general_com.c b/ext2ed/general_com.c index 679f1775..03dc2615 100644 --- a/ext2ed/general_com.c +++ b/ext2ed/general_com.c @@ -33,16 +33,16 @@ void help (char *command_line) if (*ptr!=0) { ptr=parse_word (ptr,argument); - if (*argument!=0) { + if (*argument!=0) { detailed_help (argument); return; } } if (current_type!=NULL) { - + wprintw (show_pad,"Type %s specific commands:\n",current_type->name);max_line++; - + if (current_type->type_commands.last_command==-1) { wprintw (show_pad,"\nnone\n");max_line+=2; } @@ -53,11 +53,11 @@ void help (char *command_line) } wprintw (show_pad,"%-13s",current_type->type_commands.names [i]); if (i%5!=4) - wprintw (show_pad,"; "); + wprintw (show_pad,"; "); } - + wprintw (show_pad,"\n\n");max_line+=2; - } + } if (ext2_commands.last_command != -1) { wprintw (show_pad,"ext2 filesystem general commands: \n");max_line++; @@ -67,25 +67,25 @@ void help (char *command_line) } wprintw (show_pad,"%-13s",ext2_commands.names [i]); if (i%5!=4) - wprintw (show_pad,"; "); + wprintw (show_pad,"; "); } wprintw (show_pad,"\n\n");max_line+=2; } wprintw (show_pad,"General commands: \n"); - + for (i=0;i<=general_commands.last_command;i++) { if (i%5==0) { wprintw (show_pad,"\n");max_line++; } wprintw (show_pad,"%-13s",general_commands.names [i]); if (i%5!=4) - wprintw (show_pad,"; "); + wprintw (show_pad,"; "); } - + wprintw (show_pad,"\n\n");max_line+=2; - + wprintw (show_pad,"EXT2ED ver %s (%s)\n",E2FSPROGS_VERSION, E2FSPROGS_DATE); wprintw (show_pad,"Copyright (C) 1995 Gadi Oxman\n"); wprintw (show_pad,"Reviewed 2001 Christian Bac\n"); @@ -97,12 +97,12 @@ void help (char *command_line) wprintw (show_pad,"with the guide of Avner Lottem and Dr. Ilana David.\n"); max_line+=10; - + show_pad_info.line=0;show_pad_info.max_line=max_line; werase (show_win);wmove (show_win,0,0); wprintw (show_win,"EXT2ED help"); - + refresh_show_win (); refresh_show_pad (); } @@ -111,7 +111,7 @@ void detailed_help (char *text) { int i; - + if (current_type != NULL) for (i=0;i<=current_type->type_commands.last_command;i++) { if (strcmp (current_type->type_commands.names [i],text)==0) { @@ -149,20 +149,20 @@ void set_device (char *command_line) { char *ptr,new_device [80]; - + ptr=parse_word (command_line,new_device); if (*ptr==0) { wprintw (command_win,"Error - Device name not specified\n"); refresh_command_win ();return; } - parse_word (ptr,new_device); + parse_word (ptr,new_device); check_mounted (new_device); if (mounted && !AllowMountedRead) { wprintw (command_win,"Error - Filesystem is mounted, aborting\n"); wprintw (command_win,"You may wish to use the AllowMountedRead on configuration option\n"); refresh_command_win ();return; } - + if (mounted && AllowMountedRead) { wprintw (command_win,"Warning - Filesystem is mounted. Displayed data may be unreliable.\n"); refresh_command_win (); @@ -170,7 +170,7 @@ void set_device (char *command_line) if (device_handle!=NULL) fclose (device_handle); - + if ( (device_handle=fopen (new_device,"rb"))==NULL) { wprintw (command_win,"Error - Can not open device %s\n",new_device);refresh_command_win (); return; @@ -204,14 +204,14 @@ void set_offset (char *command_line) long mult=1; long new_offset; char *ptr,new_offset_buffer [80]; - + if (device_handle==NULL) { wprintw (command_win,"Error - No device opened\n");refresh_command_win (); return; } - + ptr=parse_word (command_line,new_offset_buffer); - + if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n");refresh_command_win (); return; @@ -246,7 +246,7 @@ void set_offset (char *command_line) } new_offset=device_offset+atol (new_offset_buffer+1)*mult; } - + else if (new_offset_buffer [0]=='-') { if (device_offset==-1) { wprintw (command_win,"Error - Select a fixed offset first\n");refresh_command_win (); @@ -255,10 +255,10 @@ void set_offset (char *command_line) new_offset=device_offset-atol (new_offset_buffer+1)*mult; if (new_offset<0) new_offset=0; } - - else + + else new_offset=atol (new_offset_buffer)*mult; - + if ( (fseek (device_handle,new_offset,SEEK_SET))==-1) { wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",new_offset,device_name); refresh_command_win (); @@ -362,7 +362,7 @@ void set (char *command_line) unsigned long *long_ptr,offset=0; int i,len, found=0; char *ptr,buffer [80],variable [80],value [80]; - + if (device_handle==NULL) { wprintw (command_win,"Error - No device opened\n");refresh_command_win (); return; @@ -389,7 +389,7 @@ void set (char *command_line) if (current_type==NULL) { wprintw (command_win,"Sorry, not yet supported\n");refresh_command_win ();return; } - + for (i=0;i<current_type->fields_num && !found;i++) { if (strcmp (current_type->field_names [i],variable)==0) { found=1; @@ -429,7 +429,7 @@ void hex_set (char *command_line) unsigned char tmp; char *ptr,buffer [80],*ch_ptr; int mode=HEX; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return; @@ -482,7 +482,7 @@ void hex_set (char *command_line) } } } - + strcpy (buffer,"show");dispatch (buffer); } @@ -500,14 +500,14 @@ void set_type (char *command_line) ptr=parse_word (command_line,buffer); parse_word (ptr,buffer); - + if (strcmp (buffer,"none")==0 || strcmp (buffer,"hex")==0) { wprintw (command_win,"Data will be shown as hex dump\n");refresh_command_win (); current_type=NULL; sprintf (tmp_buffer,"show");dispatch (tmp_buffer); return; } - + descriptor_ptr=first_type; while (descriptor_ptr!=NULL && !found) { if (strcmp (descriptor_ptr->name,buffer)==0) @@ -523,7 +523,7 @@ void set_type (char *command_line) else { wprintw (command_win,"Error - %s is not a valid type\n",buffer);refresh_command_win (); } -} +} void show_int(short len, void *ptr) { @@ -584,7 +584,7 @@ void show_char(short len, void *ptr) int i,j; wprintw(show_pad, "\""); - + for (i=0; i < len; i++) { ch = *cp++; if (ch == 0) { @@ -604,17 +604,17 @@ void show_char(short len, void *ptr) } wprintw(show_pad, "%c", ch); } - + wprintw(show_pad, "\"\n"); } - + void show (char *command_line) { unsigned int i,l,len,temp_int; - unsigned long offset=0,temp_long; + unsigned long offset=0,temp_long; unsigned char temp_char,*ch_ptr; void *ptr; @@ -622,7 +622,7 @@ void show (char *command_line) return; show_pad_info.line=0; - + if (current_type==NULL) { wmove (show_pad,0,0); ch_ptr=type_data.u.buffer; @@ -631,7 +631,7 @@ void show (char *command_line) for (i=0;i<16;i++) { if (type_data.offset_in_block==offset+i) wattrset (show_pad,A_REVERSE); - + if (ch_ptr [i]>=' ' && ch_ptr [i]<='z') wprintw (show_pad,"%c",ch_ptr [i]); else @@ -643,7 +643,7 @@ void show (char *command_line) for (i=0;i<16;i++) { if (type_data.offset_in_block==offset+i) wattrset (show_pad,A_REVERSE); - + wprintw (show_pad,"%02x",ch_ptr [i]); if (type_data.offset_in_block==offset+i) { @@ -696,12 +696,12 @@ void next (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); offset*=atol (buffer); } - + if (current_type!=NULL) { sprintf (buffer,"setoffset type +%ld",offset); dispatch (buffer); @@ -712,7 +712,7 @@ void next (char *command_line) type_data.offset_in_block+=offset; sprintf (buffer,"show");dispatch (buffer); } - + else { wprintw (command_win,"Error - Offset out of block\n");refresh_command_win (); } @@ -725,12 +725,12 @@ void prev (char *command_line) char *ptr,buffer [80]; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); offset*=atol (buffer); } - + if (current_type!=NULL) { sprintf (buffer,"setoffset type -%ld",offset); dispatch (buffer); @@ -741,13 +741,13 @@ void prev (char *command_line) type_data.offset_in_block-=offset; sprintf (buffer,"show");dispatch (buffer); } - + else { wprintw (command_win,"Error - Offset out of block\n");refresh_command_win (); } } -void pgdn (char *commnad_line) +void pgdn (char *commnad_line) { show_pad_info.line+=show_pad_info.display_lines; @@ -773,19 +773,19 @@ void remember (char *command_line) { long entry_num; char *ptr,buffer [80]; - + if (device_handle==NULL) { wprintw (command_win,"Error - No device opened\n");refresh_command_win (); return; } ptr=parse_word (command_line,buffer); - + if (*ptr==0) { wprintw (command_win,"Error - Argument not specified\n");refresh_command_win (); - return; + return; } - + ptr=parse_word (ptr,buffer); entry_num=remember_lifo.entries_count++; @@ -793,16 +793,16 @@ void remember (char *command_line) entry_num=0; remember_lifo.entries_count--; } - + remember_lifo.offset [entry_num]=device_offset; remember_lifo.type [entry_num]=current_type; strcpy (remember_lifo.name [entry_num],buffer); - + if (current_type!=NULL) wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",current_type->name,device_offset,buffer); else wprintw (command_win,"Offset %ld remembered as %s\n",device_offset,buffer); - + refresh_command_win (); } @@ -821,17 +821,17 @@ void recall (char *command_line) if (*ptr==0) { wprintw (command_win,"Error - Argument not specified\n");refresh_command_win (); - return; + return; } ptr=parse_word (ptr,buffer); - + for (entry_num=remember_lifo.entries_count-1;entry_num>=0;entry_num--) { if (strcmp (remember_lifo.name [entry_num],buffer)==0) - break; + break; } - + if (entry_num==-1) { wprintw (command_win,"Error - Can not recall %s\n",buffer);refresh_command_win (); return; @@ -839,13 +839,13 @@ void recall (char *command_line) sprintf (buffer,"setoffset %ld",remember_lifo.offset [entry_num]);dispatch (buffer); if (remember_lifo.type [entry_num] != NULL) { - sprintf (buffer,"settype %s",remember_lifo.type [entry_num]->name);dispatch (buffer); + sprintf (buffer,"settype %s",remember_lifo.type [entry_num]->name);dispatch (buffer); } else { - sprintf (buffer,"settype none");dispatch (buffer); + sprintf (buffer,"settype none");dispatch (buffer); } - + wprintw (command_win,"Object %s in Offset %ld recalled\n",current_type->name,device_offset); refresh_command_win (); } @@ -864,12 +864,12 @@ void enable_write (char *command_line) wprintw (command_win,"Sorry, write access is not allowed\n"); return; } - + if (mounted) { wprintw (command_win,"Error - Filesystem is mounted\n"); - return; + return; } - + if ( (fp=fopen (device_name,"r+b"))==NULL) { wprintw (command_win,"Error - Can not open device %s for reading and writing\n",device_name);refresh_command_win (); return; @@ -893,7 +893,7 @@ void disable_write (char *command_line) wprintw (command_win,"Error - Can not open device %s\n",device_name);refresh_command_win (); return; } - + fclose (device_handle); device_handle=fp;write_access=0; wprintw (command_win,"Write access disabled\n");refresh_command_win (); diff --git a/ext2ed/group_com.c b/ext2ed/group_com.c index ee6aabc1..25325533 100644 --- a/ext2ed/group_com.c +++ b/ext2ed/group_com.c @@ -19,11 +19,11 @@ Copyright (C) 1995 Gadi Oxman #include "ext2ed.h" void type_ext2_group_desc___next (char *command_line) - + { long entry_offset=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); @@ -39,7 +39,7 @@ void type_ext2_group_desc___prev (char *command_line) { long entry_offset=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); @@ -55,7 +55,7 @@ void type_ext2_group_desc___entry (char *command_line) { long group_num; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return; @@ -63,11 +63,11 @@ void type_ext2_group_desc___entry (char *command_line) ptr=parse_word (ptr,buffer); group_num=atol (buffer); - + if (group_num < 0 || group_num >= file_system_info.groups_count) { wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return; } - + device_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc); sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer); @@ -81,7 +81,7 @@ void type_ext2_group_desc___gocopy (char *command_line) { unsigned long copy_num,offset; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return; @@ -89,12 +89,12 @@ void type_ext2_group_desc___gocopy (char *command_line) ptr=parse_word (ptr,buffer); copy_num=atol (buffer); - + offset=file_system_info.first_group_desc_offset+copy_num*file_system_info.super_block.s_blocks_per_group*file_system_info.block_size; - + if (offset > file_system_info.file_system_size) { wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return; - } + } group_info.copy_num=copy_num; device_offset=offset+group_info.group_num*sizeof (struct ext2_group_desc); @@ -108,12 +108,12 @@ void type_ext2_group_desc___show (char *command_line) { long group_num,temp; - + temp=(device_offset-file_system_info.first_group_desc_offset) % (file_system_info.super_block.s_blocks_per_group*file_system_info.block_size); group_num=temp/sizeof (struct ext2_group_desc); show (command_line); - + wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0); wprintw (show_win,"Group %ld of %ld ",group_num,file_system_info.groups_count-1); wprintw (show_win,"in copy %ld ",group_info.copy_num); @@ -136,7 +136,7 @@ void type_ext2_group_desc___inode (char *command_line) { long inode_offset; char buffer [80]; - + inode_offset=type_data.u.t_ext2_group_desc.bg_inode_table; sprintf (buffer,"setoffset block %ld",inode_offset);dispatch (buffer); sprintf (buffer,"settype ext2_inode");dispatch (buffer); @@ -147,10 +147,10 @@ void type_ext2_group_desc___blockbitmap (char *command_line) { long block_bitmap_offset; char buffer [80]; - + block_bitmap_info.entry_num=0; block_bitmap_info.group_num=group_info.group_num; - + block_bitmap_offset=type_data.u.t_ext2_group_desc.bg_block_bitmap; sprintf (buffer,"setoffset block %ld",block_bitmap_offset);dispatch (buffer); sprintf (buffer,"settype block_bitmap");dispatch (buffer); @@ -161,10 +161,10 @@ void type_ext2_group_desc___inodebitmap (char *command_line) { long inode_bitmap_offset; char buffer [80]; - + inode_bitmap_info.entry_num=0; inode_bitmap_info.group_num=group_info.group_num; - + inode_bitmap_offset=type_data.u.t_ext2_group_desc.bg_inode_bitmap; sprintf (buffer,"setoffset block %ld",inode_bitmap_offset);dispatch (buffer); sprintf (buffer,"settype inode_bitmap");dispatch (buffer); @@ -174,7 +174,7 @@ void type_ext2_group_desc___setactivecopy (char *command_line) { struct ext2_group_desc gd; - + gd=type_data.u.t_ext2_group_desc; dispatch ("gocopy 0"); type_data.u.t_ext2_group_desc=gd; diff --git a/ext2ed/init.c b/ext2ed/init.c index 7ab2e28c..41c2a398 100644 --- a/ext2ed/init.c +++ b/ext2ed/init.c @@ -48,12 +48,12 @@ int init (void) { printf ("Initializing ...\n"); - + if (!process_configuration_file ()) { fprintf (stderr,"Error - Unable to complete configuration. Quitting.\n"); - return (0); + return (0); }; - + general_commands.last_command=-1; /* No commands whatsoever meanwhile */ ext2_commands.last_command=-1; add_general_commands (); /* Add the general commands, aviable always */ @@ -62,12 +62,12 @@ int init (void) current_type=NULL; /* No filesystem specific types yet */ remember_lifo.entries_count=0; /* Object memory is empty */ - + init_windows (); /* Initialize the NCURSES interface */ init_readline (); /* Initialize the READLINE interface */ init_signals (); /* Initialize the signal handlers */ write_access=0; /* Write access disabled */ - + strcpy (last_command_line,"help"); /* Show the help screen to the user */ dispatch ("help"); return (1); /* Success */ @@ -109,26 +109,26 @@ int set_struct_descriptors (char *file_name) char current_line [500],current_word [50],*ch; char variable_name [50],variable_type [20]; struct struct_descriptor *current_descriptor; - + if ( (fp=fopen (file_name,"rt"))==NULL) { wprintw (command_win,"Error - Failed to open descriptors file %s\n",file_name); refresh_command_win (); return (0); }; - + while (!feof (fp)) { fgets (current_line,500,fp); - if (feof (fp)) break; + if (feof (fp)) break; ch=parse_word (current_line,current_word); if (strcmp (current_word,"struct")==0) { ch=parse_word (ch,current_word); current_descriptor=add_new_descriptor (current_word); - + while (strchr (current_line,'{')==NULL) { fgets (current_line,500,fp); if (feof (fp)) break; }; if (feof (fp)) break; - + fgets (current_line,500,fp); while (strchr (current_line,'}')==NULL) { @@ -147,9 +147,9 @@ int set_struct_descriptors (char *file_name) add_new_variable (current_descriptor,variable_type,variable_name); fgets (current_line,500,fp); }; - }; + }; }; - + fclose (fp); return (1); } @@ -158,7 +158,7 @@ void free_struct_descriptors (void) { struct struct_descriptor *ptr,*next; - + ptr=first_type; while (ptr!=NULL) { next=ptr->next; @@ -173,12 +173,12 @@ void free_user_commands (struct struct_commands *ptr) { int i; - + for (i=0;i<=ptr->last_command;i++) { free (ptr->names [i]); free (ptr->descriptions [i]); } - + ptr->last_command=-1; } @@ -186,7 +186,7 @@ struct struct_descriptor *add_new_descriptor (char *name) { struct struct_descriptor *ptr; - + ptr = malloc (sizeof (struct struct_descriptor)); if (ptr == NULL) { printf ("Error - Can not allocate memory - Quitting\n"); @@ -232,7 +232,7 @@ void add_new_variable (struct struct_descriptor *ptr,char *v_type,char *v_name) short len=1; char field_type=FIELD_TYPE_INT; struct type_table *p; - + strcpy (ptr->field_names [ptr->fields_num],v_name); ptr->field_positions [ptr->fields_num]=ptr->length; @@ -257,7 +257,7 @@ void add_new_variable (struct struct_descriptor *ptr,char *v_type,char *v_name) ptr->field_types [ptr->fields_num] = field_type; ptr->length+=len; - ptr->fields_num++; + ptr->fields_num++; } void fill_type_commands (struct struct_descriptor *ptr) @@ -294,7 +294,7 @@ Set specific type user commands. add_user_command (&ptr->type_commands,"file","Display file data of the current inode",type_ext2_inode___file); add_user_command (&ptr->type_commands,"dir","Display directory data of the current inode",type_ext2_inode___dir); } - + if (strcmp ((ptr->name),"dir")==0) { add_user_command (&ptr->type_commands,"show","Shows current directory data",type_dir___show); add_user_command (&ptr->type_commands,"inode","Returns to the inode of the current directory",type_dir___inode); @@ -307,7 +307,7 @@ Set specific type user commands. add_user_command (&ptr->type_commands,"writedata","Writes the current entry to the disk",type_dir___writedata); add_user_command (&ptr->type_commands,"set","Changes a variable in the current directory entry",type_dir___set); } - + if (strcmp ((ptr->name),"ext2_super_block")==0) { add_user_command (&ptr->type_commands,"show","Displays the super block data",type_ext2_super_block___show); add_user_command (&ptr->type_commands,"gocopy","Move to another backup copy of the superblock",type_ext2_super_block___gocopy); @@ -343,30 +343,30 @@ Set specific type user commands. add_user_command (&ptr->type_commands,"allocate","Allocates the current inode",type_ext2_inode_bitmap___allocate); add_user_command (&ptr->type_commands,"deallocate","Deallocates the current inode",type_ext2_inode_bitmap___deallocate); } - + } void add_user_command (struct struct_commands *ptr,char *name,char *description,PF callback) { int num; - + num=ptr->last_command; if (num+1==MAX_COMMANDS_NUM) { printf ("Internal Error - Can't add command %s\n",name); return; } - + ptr->last_command=++num; ptr->names [num]=(char *) malloc (strlen (name)+1); strcpy (ptr->names [num],name); - + if (*description!=0) { ptr->descriptions [num]=(char *) malloc (strlen (description)+1); strcpy (ptr->descriptions [num],description); } - + ptr->callback [num]=callback; } @@ -382,7 +382,7 @@ int set_file_system_info (void) { int ext2_detected=0; struct ext2_super_block *sb; - + file_system_info.super_block_offset=1024; file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize; @@ -390,7 +390,7 @@ int set_file_system_info (void) sb=&file_system_info.super_block; - if (sb->s_magic == EXT2_SUPER_MAGIC) + if (sb->s_magic == EXT2_SUPER_MAGIC) ext2_detected=1; if (ext2_detected) @@ -403,7 +403,7 @@ int set_file_system_info (void) if (ForceExt2 && !ext2_detected) wprintw (command_win,"Forcing extended 2 filesystem\n"); - + if (ForceDefault || !ext2_detected) wprintw (command_win,"Forcing default parameters\n"); @@ -414,17 +414,17 @@ int set_file_system_info (void) if (!set_struct_descriptors (Ext2Descriptors)) return (0); } - + if (!ForceDefault && ext2_detected) { - + file_system_info.block_size=EXT2_MIN_BLOCK_SIZE << sb->s_log_block_size; if (file_system_info.block_size == EXT2_MIN_BLOCK_SIZE) file_system_info.first_group_desc_offset=2*EXT2_MIN_BLOCK_SIZE; else file_system_info.first_group_desc_offset=file_system_info.block_size; - file_system_info.groups_count = div_ceil(sb->s_blocks_count, + file_system_info.groups_count = div_ceil(sb->s_blocks_count, sb->s_blocks_per_group); - + file_system_info.inodes_per_block=file_system_info.block_size/sizeof (struct ext2_inode); file_system_info.blocks_per_group=sb->s_inodes_per_group/file_system_info.inodes_per_block; file_system_info.no_blocks_in_group=sb->s_blocks_per_group; @@ -433,10 +433,10 @@ int set_file_system_info (void) else { file_system_info.file_system_size=DefaultTotalBlocks*DefaultBlockSize; - file_system_info.block_size=DefaultBlockSize; + file_system_info.block_size=DefaultBlockSize; file_system_info.no_blocks_in_group=DefaultBlocksInGroup; } - + if (file_system_info.file_system_size > 2147483647) { wprintw (command_win,"Sorry, filesystems bigger than 2 GB are currently not supported\n"); return (0); @@ -458,17 +458,17 @@ void init_signals (void) signal (SIGWINCH, signal_SIGWINCH_handler); /* Catch SIGWINCH */ signal (SIGTERM, signal_SIGTERM_handler); signal (SIGSEGV, signal_SIGSEGV_handler); - + } void signal_SIGWINCH_handler (int sig_num) { redraw_request=1; /* We will handle it in main.c */ - - /* Reset signal handler */ - signal (SIGWINCH, signal_SIGWINCH_handler); - + + /* Reset signal handler */ + signal (SIGWINCH, signal_SIGWINCH_handler); + } void signal_SIGTERM_handler (int sig_num) @@ -496,12 +496,12 @@ int process_configuration_file (void) strcpy (buffer, ETC_DIR); strcat (buffer,"/ext2ed.conf"); - + if ((fp=fopen (buffer,"rt"))==NULL) { fprintf (stderr,"Error - Unable to open configuration file %s\n",buffer); return (0); } - + while (get_next_option (fp,option,value)) { if (strcasecmp (option,"Ext2Descriptors")==0) { strcpy (Ext2Descriptors,value); @@ -581,7 +581,7 @@ int process_configuration_file (void) fclose (fp);return (0); } } - + else { fprintf (stderr,"Error - Unknown option: %s\n",option); fclose (fp);return (0); @@ -598,13 +598,13 @@ int get_next_option (FILE *fp,char *option,char *value) { char *ptr; char buffer [600]; - + if (feof (fp)) return (0); do{ if (feof (fp)) return (0); fgets (buffer,500,fp); } while (buffer [0]=='#' || buffer [0]=='\n'); - + ptr=parse_word (buffer,option); ptr=parse_word (ptr,value); return (1); @@ -618,15 +618,15 @@ void check_mounted (char *name) char current_line [500],current_word [200]; mounted=0; - + if ( (fp=fopen ("/etc/mtab","rt"))==NULL) { wprintw (command_win,"Error - Failed to open /etc/mtab. Assuming filesystem is mounted.\n"); refresh_command_win ();mounted=1;return; }; - + while (!feof (fp)) { fgets (current_line,500,fp); - if (feof (fp)) break; + if (feof (fp)) break; ptr=parse_word (current_line,current_word); if (strcasecmp (current_word,name)==0) { mounted=1;fclose (fp);return; @@ -634,6 +634,6 @@ void check_mounted (char *name) }; fclose (fp); - - return; + + return; } diff --git a/ext2ed/inode_com.c b/ext2ed/inode_com.c index 0f14d118..843286c5 100644 --- a/ext2ed/inode_com.c +++ b/ext2ed/inode_com.c @@ -51,7 +51,7 @@ void type_ext2_inode___prev (char *command_line) if (entry_num-mult+1>0) { device_offset-=sizeof (struct ext2_inode)*mult; entry_num-=mult; - + sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer); strcpy (buffer,"show");dispatch (buffer); } @@ -59,7 +59,7 @@ void type_ext2_inode___prev (char *command_line) else { wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win (); } - + if (entry_num==0) { wprintw (command_win,"Reached first inode in current group descriptor\n"); refresh_command_win (); @@ -77,7 +77,7 @@ void type_ext2_inode___next (char *command_line) struct ext2_group_desc desc; ptr=parse_word (command_line,buffer); - + if (*ptr!=0) { ptr=parse_word (ptr,buffer); mult=atol (buffer); @@ -99,7 +99,7 @@ void type_ext2_inode___next (char *command_line) if (entry_num+mult-1<last_entry) { device_offset+=sizeof (struct ext2_inode)*mult; entry_num+=mult; - + sprintf (buffer,"setoffset %ld",device_offset);dispatch (buffer); strcpy (buffer,"show");dispatch (buffer); } @@ -107,7 +107,7 @@ void type_ext2_inode___next (char *command_line) else { wprintw (command_win,"Error - Entry out of limits\n");refresh_command_win (); } - + if (entry_num==last_entry) { wprintw (command_win,"Reached last inode in current group descriptor\n"); refresh_command_win (); @@ -119,10 +119,10 @@ void type_ext2_inode___show (char *command_line) { struct ext2_inode *inode_ptr; - + unsigned short temp; int i; - + long group_num,group_offset,entry_num,block_num,first_entry,last_entry,inode_num; struct ext2_group_desc desc; @@ -150,7 +150,7 @@ void type_ext2_inode___show (char *command_line) wprintw (show_pad,"r"); else wprintw (show_pad,"-"); - + if (temp & 2) wprintw (show_pad,"w"); else @@ -168,7 +168,7 @@ void type_ext2_inode___show (char *command_line) wmove (show_pad,10,40); temp=inode_ptr->i_flags; - + if (temp & EXT2_SECRM_FL) wprintw (show_pad,"s"); else @@ -204,14 +204,14 @@ void type_ext2_inode___show (char *command_line) wprintw (show_pad,"d"); else wprintw (show_pad,"-"); - + refresh_show_pad (); wmove (show_win,1,0); wprintw (show_win,"Inode %ld of %ld. Entry %ld of %ld in group descriptor %ld.\n" ,inode_num,file_system_info.super_block.s_inodes_count,entry_num,last_entry,group_num); - + wprintw (show_win,"Inode type: "); if (inode_num < EXT2_GOOD_OLD_FIRST_INO) { @@ -241,7 +241,7 @@ void type_ext2_inode___show (char *command_line) } if (type_data.u.t_ext2_inode.i_mode==0) wprintw (show_win,"Free. "); - + if (S_ISREG (type_data.u.t_ext2_inode.i_mode)) wprintw (show_win,"File. "); @@ -255,7 +255,7 @@ void type_ext2_inode___show (char *command_line) if (inode_ptr->i_size <= 60) wprintw (show_pad,"-> %s",(char *) &type_data.u.t_ext2_inode.i_block [0]); else - wprintw (show_pad,"Slow symbolic link\n"); + wprintw (show_pad,"Slow symbolic link\n"); refresh_show_pad (); } @@ -266,7 +266,7 @@ void type_ext2_inode___show (char *command_line) wprintw (show_win,"Block device. "); wprintw (show_win,"\n");refresh_show_win (); - + if (entry_num==last_entry) { wprintw (command_win,"Reached last inode in current group descriptor\n"); refresh_command_win (); @@ -305,7 +305,7 @@ void type_ext2_inode___entry (char *command_line) sprintf (buffer,"next %ld",wanted_entry-entry_num); dispatch (buffer); } - + else if (wanted_entry < entry_num) { sprintf (buffer,"prev %ld",entry_num-wanted_entry); dispatch (buffer); @@ -316,12 +316,12 @@ void type_ext2_inode___group (char *command_line) { char buffer [80]; - + long group_num,group_offset; - + group_num=inode_offset_to_group_num (device_offset); group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc); - + sprintf (buffer,"setoffset %ld",group_offset);dispatch (buffer); sprintf (buffer,"settype ext2_group_desc");dispatch (buffer); } @@ -330,17 +330,17 @@ void type_ext2_inode___file (char *command_line) { char buffer [80]; - + if (!S_ISREG (type_data.u.t_ext2_inode.i_mode)) { wprintw (command_win,"Error - Inode type is not file\n");refresh_command_win (); - return; + return; } - + if (!init_file_info ()) { wprintw (command_win,"Error - Unable to show file\n");refresh_command_win (); - return; + return; } - + sprintf (buffer,"settype file");dispatch (buffer); } @@ -348,21 +348,21 @@ void type_ext2_inode___dir (char *command_line) { char buffer [80]; - + if (!S_ISDIR (type_data.u.t_ext2_inode.i_mode)) { wprintw (command_win,"Error - Inode type is not directory\n");refresh_command_win (); - return; + return; } -/* It is very important to init first_file_info first, as search_dir_entries relies on it */ +/* It is very important to init first_file_info first, as search_dir_entries relies on it */ if (!init_dir_info (&first_file_info)) { wprintw (command_win,"Error - Unable to show directory\n");refresh_command_win (); - return; + return; } - + file_info=first_file_info; - + sprintf (buffer,"settype dir");dispatch (buffer); } @@ -371,9 +371,9 @@ long inode_offset_to_group_num (long inode_offset) { int found=0; struct ext2_group_desc desc; - + long block_num,group_offset,group_num; - + block_num=inode_offset/file_system_info.block_size; group_offset=file_system_info.first_group_desc_offset; @@ -387,14 +387,14 @@ long inode_offset_to_group_num (long inode_offset) group_offset+=sizeof (struct ext2_group_desc); group_num=(group_offset-file_system_info.first_group_desc_offset)/sizeof (struct ext2_group_desc); } - + if (!found) return (-1); return (group_num); } - + long int inode_offset_to_inode_num (long inode_offset) @@ -413,7 +413,7 @@ long int inode_offset_to_inode_num (long inode_offset) first_entry=0;last_entry=file_system_info.super_block.s_inodes_per_group-1; inode_num=group_num*file_system_info.super_block.s_inodes_per_group+1; inode_num+=entry_num; - + return (inode_num); } @@ -424,7 +424,7 @@ long int inode_num_to_inode_offset (long inode_num) struct ext2_group_desc desc; inode_num--; - + group_num=inode_num/file_system_info.super_block.s_inodes_per_group; inode_entry=inode_num%file_system_info.super_block.s_inodes_per_group; group_offset=file_system_info.first_group_desc_offset+group_num*sizeof (struct ext2_group_desc); diff --git a/ext2ed/inodebitmap_com.c b/ext2ed/inodebitmap_com.c index f1fddd45..e6022344 100644 --- a/ext2ed/inodebitmap_com.c +++ b/ext2ed/inodebitmap_com.c @@ -28,7 +28,7 @@ void type_ext2_inode_bitmap___entry (char *command_line) { unsigned long entry_num; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return; @@ -36,11 +36,11 @@ void type_ext2_inode_bitmap___entry (char *command_line) ptr=parse_word (ptr,buffer); entry_num=atol (buffer); - + if (entry_num >= file_system_info.super_block.s_inodes_per_group) { wprintw (command_win,"Error - Entry number out of bounds\n");refresh_command_win ();return; } - + inode_bitmap_info.entry_num=entry_num; strcpy (buffer,"show");dispatch (buffer); } @@ -50,7 +50,7 @@ void type_ext2_inode_bitmap___next (char *command_line) { long entry_offset=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); @@ -66,7 +66,7 @@ void type_ext2_inode_bitmap___prev (char *command_line) { long entry_offset=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); @@ -82,24 +82,24 @@ void type_ext2_inode_bitmap___allocate (char *command_line) { long entry_num,num=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); num=atol (buffer); } - + entry_num=inode_bitmap_info.entry_num; if (num > file_system_info.super_block.s_inodes_per_group-entry_num) { - wprintw (command_win,"Error - There aren't that much inodes in the group\n"); - refresh_command_win ();return; + wprintw (command_win,"Error - There aren't that much inodes in the group\n"); + refresh_command_win ();return; } - + while (num) { allocate_inode (entry_num); num--;entry_num++; } - + dispatch ("show"); } @@ -108,24 +108,24 @@ void type_ext2_inode_bitmap___deallocate (char *command_line) { long entry_num,num=1; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr!=0) { ptr=parse_word (ptr,buffer); num=atol (buffer); } - + entry_num=inode_bitmap_info.entry_num; if (num > file_system_info.super_block.s_inodes_per_group-entry_num) { - wprintw (command_win,"Error - There aren't that much inodes in the group\n"); - refresh_command_win ();return; + wprintw (command_win,"Error - There aren't that much inodes in the group\n"); + refresh_command_win ();return; } - + while (num) { deallocate_inode (entry_num); num--;entry_num++; } - + dispatch ("show"); } @@ -135,7 +135,7 @@ void allocate_inode (long entry_num) { unsigned char bit_mask=1; int byte_offset,j; - + byte_offset=entry_num/8; for (j=0;j<entry_num%8;j++) bit_mask*=2; @@ -147,12 +147,12 @@ void deallocate_inode (long entry_num) { unsigned char bit_mask=1; int byte_offset,j; - + byte_offset=entry_num/8; for (j=0;j<entry_num%8;j++) bit_mask*=2; bit_mask^=0xff; - + type_data.u.buffer [byte_offset] &= bit_mask; } @@ -165,7 +165,7 @@ void type_ext2_inode_bitmap___show (char *command_line) ptr=type_data.u.buffer; show_pad_info.line=0;show_pad_info.max_line=-1; - + wmove (show_pad,0,0); for (i=0,entry_num=0;i<file_system_info.super_block.s_inodes_per_group/8;i++,ptr++) { for (j=1;j<=128;j*=2) { @@ -190,13 +190,13 @@ void type_ext2_inode_bitmap___show (char *command_line) show_pad_info.max_line++; } } - + if (i%8!=7) { wprintw (show_pad,"\n"); show_pad_info.max_line++; } - refresh_show_pad (); + refresh_show_pad (); show_info (); wmove (show_win,1,0);wprintw (show_win,"Inode bitmap of block group %ld\n",inode_bitmap_info.group_num); diff --git a/ext2ed/main.c b/ext2ed/main.c index e2394546..50a3f07f 100644 --- a/ext2ed/main.c +++ b/ext2ed/main.c @@ -71,7 +71,7 @@ char device_name [80]; /* The location of the filesystem */ FILE *device_handle=NULL; /* This is passed to the fopen / fread ... commands */ long device_offset; /* The current position in the filesystem */ /* Note that we have a 2 GB limitation */ - + int mounted=0; /* This is set when we find that the filesystem is mounted */ struct struct_commands general_commands,ext2_commands; /* Used to define the general and ext2 commands */ @@ -98,7 +98,7 @@ int main (int argc, char **argv) int write_priv = 0; int c; char *buf; - + if (!init ()) return (1); while ((c = getopt (argc, argv, "w")) != EOF) { @@ -119,7 +119,7 @@ int main (int argc, char **argv) set_device(buf); free(buf); if (write_priv) { - wprintw (command_win,"\n"); + wprintw (command_win,"\n"); enable_write("enable_write"); } } @@ -148,7 +148,7 @@ int command_read_key() key = 0; kill(getpid(), SIGTSTP); break; - + case KEY_NPAGE: pgdn(""); refresh_command_win (); @@ -161,7 +161,7 @@ int command_read_key() case ERR: key = 0; break; - + case KEY_BACKSPACE: key = '\b'; } @@ -203,10 +203,10 @@ void parser (void) cbreak(); keypad(command_win, 1); wtimeout(command_win, 100); - + rl_getc_function = rl_getc_replacement; #endif - + while (!quit) { /* Terminal screen size has changed */ if (redraw_request) { @@ -228,7 +228,7 @@ void parser (void) * time. */ mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0); - + /* echo (); */ ptr=readline ("ext2ed > "); /* noecho (); */ @@ -239,15 +239,15 @@ void parser (void) * XXX WHY??? */ strcpy (command_line,ptr); - free (ptr); + free (ptr); if (*command_line != 0) add_history (command_line); /* If only enter was pressed, recall the last command */ - if (*command_line==0) + if (*command_line==0) strcpy (command_line,last_command_line); - + /* Emulate readline's actions for ncurses */ mvcur (-1,-1,LINES-COMMAND_WIN_LINES,0); werase (command_win); @@ -261,7 +261,7 @@ void parser (void) /* And call dispatch to do the actual job */ quit=dispatch (command_line); - } + } } #else void read_line(char * foo) { @@ -321,13 +321,13 @@ void parser (void) if (*command_line==0) strcpy (command_line,last_command_line); - mvcur (-1,-1,LINES-COMMAND_WIN_LINES + 1,0); + mvcur (-1,-1,LINES-COMMAND_WIN_LINES + 1,0); strcpy (last_command_line,command_line); /* Save this command in our tiny cache */ - + /* And call dispatch to do the actual job */ quit=dispatch (command_line); - } + } } #endif @@ -335,35 +335,35 @@ void parser (void) /* * This is a very important function. Its task is to recieve a command * name and link it to a C function. There are three types of commands: - * + * * 1. General commands - Always available and accessed through - * general_commands. + * general_commands. * 2. Ext2 specific commands - Available when editing an ext2 - * filesystem, accessed through ext2_commands. + * filesystem, accessed through ext2_commands. * 3. Type specific commands - Those are changing according to the * current type. The global variable current_type points to the * current object definition (of type struct_descriptor). In it, the - * struct_commands entry contains the type specific commands links. - * + * struct_commands entry contains the type specific commands links. + * * Overriding is an important feature - Much like in C++ : The same * command name can dispatch to different functions. The overriding * priority is 3,2,1; That is - A type specific command will always * override a general command. This is used through the program to - * allow fine tuned operation. - * + * allow fine tuned operation. + * * When an handling function is found, it is called along with the * command line that was passed to us. The handling function is then - * free to interpert the arguments in its own style. + * free to interpert the arguments in its own style. */ int dispatch (char *command_line) { int i,found=0; - + char command [80]; parse_word (command_line,command); - - if (strcasecmp (command,"quit")==0) return (1); + + if (strcasecmp (command,"quit")==0) return (1); /* 1. Search for type specific commands FIRST - Allows overriding of a general command */ @@ -388,9 +388,9 @@ int dispatch (char *command_line) } } - + /* 3. If not found, search the general commands */ - + if (!found) for (i=0;i<=general_commands.last_command && !found;i++) { if (strcasecmp (command,general_commands.names [i])==0) { @@ -400,18 +400,18 @@ int dispatch (char *command_line) } /* 4. If not found, issue an error message and return */ - + if (!found) { wprintw (command_win,"Error: Unknown command\n"); refresh_command_win (); } - + return (0); } /* - * + * * This function copies the next word in source to the variable dest, * ignoring whitespaces. It returns a pointer to the next word in * source. It is used to split the command line into command and arguments. @@ -419,12 +419,12 @@ int dispatch (char *command_line) char *parse_word (char *source,char *dest) { char ch,*source_ptr,*target_ptr; - + if (*source==0) { *dest=0; return (source); }; - + source_ptr=source;target_ptr=dest; do { ch=*source_ptr++; @@ -432,7 +432,7 @@ char *parse_word (char *source,char *dest) while (ch>' ' && ch<='z') { *target_ptr++=ch; - ch=*source_ptr++; + ch=*source_ptr++; } *target_ptr=0; @@ -448,23 +448,23 @@ char *parse_word (char *source,char *dest) /* * text is the partial command entered by the user; We assume that it * is a part of a command - I didn't write code for smarter completion. - * + * * The state variable is an index which tells us how many possible - * completions we already returned to readline. - * + * completions we already returned to readline. + * * We return only one possible completion or (char *) NULL if there * are no more completions. This function will be called by readline - * over and over until we tell it to stop. - * + * over and over until we tell it to stop. + * * While scanning for possible completions, we use the same priority - * definition which was used in dispatch. + * definition which was used in dispatch. */ #if HAVE_READLINE char *complete_command (char *text,int state) { int state_index=-1; int i,len; - + len=strlen (text); /* Is the command type specific ? */ @@ -480,7 +480,7 @@ char *complete_command (char *text,int state) } /* No, pehaps ext2 specific command then ? */ - + for (i=0;i<=ext2_commands.last_command;i++) { if (strncmp (ext2_commands.names [i],text,len)==0) { state_index++; @@ -489,9 +489,9 @@ char *complete_command (char *text,int state) } } - + /* Check for a general command */ - + for (i=0;i<=general_commands.last_command;i++) { if (strncmp (general_commands.names [i],text,len)==0) { state_index++; @@ -501,27 +501,27 @@ char *complete_command (char *text,int state) } /* quit is handled differently */ - + if (strncmp ("quit",text,len)==0) { state_index++; if (state==state_index) - return (dupstr ("quit")); + return (dupstr ("quit")); } /* No more completions */ - + return ((char *) NULL); } #endif -/* +/* * Nothing special - Just allocates enough space and copy the string. */ char *dupstr (char *src) { char *ptr; - + ptr=(char *) malloc (strlen (src)+1); strcpy (ptr,src); return (ptr); @@ -531,13 +531,13 @@ char *dupstr (char *src) /* * This function reports an internal error. It is almost not used. One * place in which I do check for internal errors is disk.c. - * + * * We just report the error, and try to continue ... */ void internal_error (char *description,char *source_name,char *function_name) { wprintw (command_win,"Internal error - Found by source: %s.c , function: %s\n",source_name,function_name); - wprintw (command_win,"\t%s\n",description); + wprintw (command_win,"\t%s\n",description); wprintw (command_win,"Press enter to (hopefully) continue\n"); refresh_command_win ();getch ();werase (command_win); } diff --git a/ext2ed/super_com.c b/ext2ed/super_com.c index ec483513..3d30070b 100644 --- a/ext2ed/super_com.c +++ b/ext2ed/super_com.c @@ -26,14 +26,14 @@ void type_ext2_super_block___show (char *command_line) { struct ext2_super_block *super; super=&type_data.u.t_ext2_super_block; - + show (command_line); if (super->s_blocks_count != 0) { wmove (show_pad,2,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_r_blocks_count/ (float) super->s_blocks_count); wmove (show_pad,3,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_blocks_count/ (float) super->s_blocks_count); } - + if (super->s_inodes_count != 0) { wmove (show_pad,4,40);wprintw (show_pad,"%2.2f%%",100*(float) super->s_free_inodes_count/ (float) super->s_inodes_count); } @@ -60,7 +60,7 @@ void type_ext2_super_block___show (char *command_line) wprintw (show_pad,"Unknown"); break; } - + wmove (show_pad,16,40); if (type_data.u.t_ext2_super_block.s_state & 0x1) wprintw (show_pad,"clean "); @@ -71,9 +71,9 @@ void type_ext2_super_block___show (char *command_line) wprintw (show_pad,"with errors "); else wprintw (show_pad,"with no errors"); - + wmove (show_pad,17,40); - + switch (type_data.u.t_ext2_super_block.s_errors) { case EXT2_ERRORS_CONTINUE: wprintw (show_pad,"Continue"); @@ -90,7 +90,7 @@ void type_ext2_super_block___show (char *command_line) } wmove (show_pad,21,40); - + switch (type_data.u.t_ext2_super_block.s_creator_os) { case EXT2_OS_LINUX: @@ -105,7 +105,7 @@ void type_ext2_super_block___show (char *command_line) wprintw (show_pad,"Unknown"); break; } - + refresh_show_pad (); wmove (show_win,1,0);wprintw (show_win,"\n");wmove (show_win,2,0); @@ -121,7 +121,7 @@ void type_ext2_super_block___gocopy (char *command_line) { unsigned long copy_num,offset; char *ptr,buffer [80]; - + ptr=parse_word (command_line,buffer); if (*ptr==0) { wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();return; @@ -129,12 +129,12 @@ void type_ext2_super_block___gocopy (char *command_line) ptr=parse_word (ptr,buffer); copy_num=atol (buffer); - + offset=file_system_info.super_block_offset+copy_num*file_system_info.no_blocks_in_group*file_system_info.block_size; - + if (offset > file_system_info.file_system_size) { wprintw (command_win,"Error - Copy number out of bounds\n");refresh_command_win ();return; - } + } super_info.copy_num=copy_num; device_offset=offset; @@ -147,7 +147,7 @@ void type_ext2_super_block___setactivecopy (char *command_line) { struct ext2_super_block sb; - + sb=type_data.u.t_ext2_super_block; dispatch ("gocopy 0"); type_data.u.t_ext2_super_block=sb; diff --git a/ext2ed/win.c b/ext2ed/win.c index 758bc6ad..113a28f3 100644 --- a/ext2ed/win.c +++ b/ext2ed/win.c @@ -30,7 +30,7 @@ Copyright (C) 1995 Gadi Oxman struct struct_pad_info show_pad_info; WINDOW *title_win,*show_win,*command_win,*mt_win1,*mt_win2,*show_pad; -/* to remember configuration after initscr +/* to remember configuration after initscr * and modify it */ struct termios termioInit, termioCurrent; @@ -56,7 +56,7 @@ void setup_show_win(void) show_pad_info.display_cols=COLS; show_pad_info.max_line=show_pad_info.display_lines-1;show_pad_info.max_col=show_pad_info.display_cols-1; show_pad_info.disable_output=0; -} +} void init_windows (void) { @@ -65,7 +65,7 @@ void init_windows (void) termioCurrent = termioInit; termioCurrent.c_lflag |= ECHO; /* set echo on */ tcsetattr(0,TCSANOW,&termioCurrent); - + if (LINES<TITLE_WIN_LINES+SHOW_WIN_LINES+COMMAND_WIN_LINES+3) { printf ("Sorry, your terminal screen is too small\n"); printf ("Error - Can not initialize windows\n"); @@ -105,7 +105,7 @@ void refresh_title_win (void) void refresh_show_win (void) { int current_page,total_pages; - + current_page=show_pad_info.line/show_pad_info.display_lines+1; if (show_pad_info.line%show_pad_info.display_lines) current_page++; @@ -123,10 +123,10 @@ void refresh_show_pad (void) { int left,top,right,bottom,i; - + if (show_pad_info.disable_output) return; - + if (show_pad_info.max_line < show_pad_info.display_lines-1) { for (i=show_pad_info.max_line+1;i<show_pad_info.display_lines;i++) { wmove (show_pad,i,0);wprintw (show_pad,"\n"); @@ -157,19 +157,19 @@ void close_windows (void) { // echo (); tcsetattr(0,TCSANOW,&termioInit); - + delwin (title_win); delwin (command_win); delwin (show_win); delwin (show_pad); - + endwin (); } void show_info (void) { int block_num,block_offset; - + block_num=device_offset/file_system_info.block_size; block_offset=device_offset%file_system_info.block_size; diff --git a/include/nonunix/grp.h b/include/nonunix/grp.h index 4130cb79..ef019bd5 100644 --- a/include/nonunix/grp.h +++ b/include/nonunix/grp.h @@ -7,10 +7,10 @@ __inline struct group * getgrnam(char* g){return 0;} struct group { - char *gr_name; + char *gr_name; char *gr_passwd; - __gid_t gr_gid; - char **gr_mem; + __gid_t gr_gid; + char **gr_mem; }; #define getgrgid(i) NULL diff --git a/include/nonunix/pwd.h b/include/nonunix/pwd.h index 67e05eab..a724ea21 100644 --- a/include/nonunix/pwd.h +++ b/include/nonunix/pwd.h @@ -9,13 +9,13 @@ __inline struct passwd* getpwnam (char* g){return 0;} struct passwd { - char *pw_name; - char *pw_passwd; - __uid_t pw_uid; - __gid_t pw_gid; - char *pw_gecos; - char *pw_dir; - char *pw_shell; + char *pw_name; + char *pw_passwd; + __uid_t pw_uid; + __gid_t pw_gid; + char *pw_gecos; + char *pw_dir; + char *pw_shell; }; #define getpwuid(i) NULL diff --git a/intl/l10nflist.c b/intl/l10nflist.c index eb995aaf..40b0249b 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -164,7 +164,7 @@ pop (int x) return x; } - + struct loaded_l10nfile * _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, const char *dirlist, size_t dirlist_len, @@ -359,7 +359,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, return retval; } - + /* Normalize codeset name. There is no standard for the codeset names. Normalization allows the user to use any of the common names. The return value is dynamically allocated and has to be diff --git a/intl/plural.c b/intl/plural.c index 72494f9e..535305b7 100644 --- a/intl/plural.c +++ b/intl/plural.c @@ -223,8 +223,8 @@ static const short yyrline[] = /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ static const char *const yytname[] = { - "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", - "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", + "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", + "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", "start", "exp", 0 }; #endif @@ -556,7 +556,7 @@ int yydebug; #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif - + #ifdef YYERROR_VERBOSE # ifndef yystrlen @@ -608,7 +608,7 @@ yystpcpy (yydest, yysrc) # endif # endif #endif - + #line 315 "/usr/local/share/bison/bison.simple" @@ -1081,7 +1081,7 @@ case 12: #line 705 "/usr/local/share/bison/bison.simple" - + yyvsp -= yylen; yyssp -= yylen; #if YYLSP_NEEDED diff --git a/lib/blkid/blkid.h b/lib/blkid/blkid.h index f38a2350..81f3098c 100644 --- a/lib/blkid/blkid.h +++ b/lib/blkid/blkid.h @@ -90,7 +90,7 @@ extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev); extern int blkid_tag_next(blkid_tag_iterate iterate, const char **type, const char **value); extern void blkid_tag_iterate_end(blkid_tag_iterate iterate); -extern int blkid_dev_has_tag(blkid_dev dev, const char *type, +extern int blkid_dev_has_tag(blkid_dev dev, const char *type, const char *value); extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache, const char *type, diff --git a/lib/blkid/cache.c b/lib/blkid/cache.c index efd4656e..7c95726d 100644 --- a/lib/blkid/cache.c +++ b/lib/blkid/cache.c @@ -100,14 +100,14 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename) if (filename && !strlen(filename)) filename = 0; - if (!filename) + if (!filename) filename = safe_getenv("BLKID_FILE"); if (!filename) filename = BLKID_CACHE_FILE; cache->bic_filename = blkid_strdup(filename); - + blkid_read_cache(cache); - + *ret_cache = cache; return 0; } @@ -120,7 +120,7 @@ void blkid_put_cache(blkid_cache cache) (void) blkid_flush_cache(cache); DBG(DEBUG_CACHE, printf("freeing cache struct\n")); - + /* DBG(DEBUG_CACHE, blkid_debug_dump_cache(cache)); */ while (!list_empty(&cache->bic_devs)) { @@ -137,7 +137,7 @@ void blkid_put_cache(blkid_cache cache) while (!list_empty(&tag->bit_names)) { blkid_tag bad = list_entry(tag->bit_names.next, - struct blkid_struct_tag, + struct blkid_struct_tag, bit_names); DBG(DEBUG_CACHE, printf("warning: unfreed tag %s=%s\n", @@ -148,7 +148,7 @@ void blkid_put_cache(blkid_cache cache) } if (cache->bic_filename) free(cache->bic_filename); - + free(cache); } @@ -165,12 +165,12 @@ void blkid_gc_cache(blkid_cache cache) if (!p) break; if (stat(dev->bid_name, &st) < 0) { - DBG(DEBUG_CACHE, + DBG(DEBUG_CACHE, printf("freeing %s\n", dev->bid_name)); blkid_free_dev(dev); cache->bic_flags |= BLKID_BIC_FL_CHANGED; } else { - DBG(DEBUG_CACHE, + DBG(DEBUG_CACHE, printf("Device %s exists\n", dev->bid_name)); } } diff --git a/lib/blkid/dev.c b/lib/blkid/dev.c index 5252a8eb..fb8d8527 100644 --- a/lib/blkid/dev.c +++ b/lib/blkid/dev.c @@ -77,7 +77,7 @@ void blkid_debug_dump_dev(blkid_dev dev) list_for_each(p, &dev->bid_tags) { blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); if (tag) - printf(" tag: %s=\"%s\"\n", tag->bit_name, + printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val); else printf(" tag: NULL\n"); @@ -102,7 +102,7 @@ void blkid_debug_dump_dev(blkid_dev dev) * This series of functions iterate over all devices in a blkid cache */ #define DEV_ITERATE_MAGIC 0x01a5284c - + struct blkid_struct_dev_iterate { int magic; blkid_cache cache; @@ -131,7 +131,7 @@ extern int blkid_dev_set_search(blkid_dev_iterate iter, { char *new_type, *new_value; - if (!iter || iter->magic != DEV_ITERATE_MAGIC || !search_type || + if (!iter || iter->magic != DEV_ITERATE_MAGIC || !search_type || !search_value) return -1; new_type = malloc(strlen(search_type)+1); @@ -168,8 +168,8 @@ extern int blkid_dev_next(blkid_dev_iterate iter, while (iter->p != &iter->cache->bic_devs) { dev = list_entry(iter->p, struct blkid_struct_dev, bid_devs); iter->p = iter->p->next; - if (iter->search_type && - !blkid_dev_has_tag(dev, iter->search_type, + if (iter->search_type && + !blkid_dev_has_tag(dev, iter->search_type, iter->search_value)) continue; *ret_dev = dev; @@ -220,7 +220,7 @@ int main(int argc, char **argv) case 'm': blkid_debug_mask = strtoul (optarg, &tmp, 0); if (*tmp) { - fprintf(stderr, "Invalid debug mask: %s\n", + fprintf(stderr, "Invalid debug mask: %s\n", optarg); exit(1); } diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c index 2b3855b2..f0e127cf 100644 --- a/lib/blkid/devname.c +++ b/lib/blkid/devname.c @@ -58,7 +58,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags) if (strcmp(tmp->bid_name, devname)) continue; - DBG(DEBUG_DEVNAME, + DBG(DEBUG_DEVNAME, printf("found devname %s in cache\n", tmp->bid_name)); dev = tmp; break; @@ -79,7 +79,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags) dev = blkid_verify(cache, dev); if (!dev || !(dev->bid_flags & BLKID_BID_FL_VERIFIED)) return dev; - /* + /* * If the device is verified, then search the blkid * cache for any entries that match on the type, uuid, * and label, and verify them; if a cache entry can @@ -192,7 +192,7 @@ static void probe_one(blkid_cache cache, const char *ptname, dev->bid_devno == devno) goto set_pri; - if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) && + if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) && st.st_rdev == devno) { devname = blkid_strdup(device); break; @@ -309,7 +309,7 @@ static void lvm_probe_all(blkid_cache cache, int only_if_new) DBG(DEBUG_DEVNAME, printf("LVM dev %s: devno 0x%04X\n", lvm_device, (unsigned int) dev)); - probe_one(cache, lvm_device, dev, BLKID_PRI_LVM, + probe_one(cache, lvm_device, dev, BLKID_PRI_LVM, only_if_new); free(lvm_device); } @@ -417,7 +417,7 @@ static int probe_all(blkid_cache cache, int only_if_new) ptname, (unsigned int) devs[which])); if (sz > 1) - probe_one(cache, ptname, devs[which], 0, + probe_one(cache, ptname, devs[which], 0, only_if_new); lens[which] = 0; /* mark as checked */ } diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c index e9c174f4..0a16d9be 100644 --- a/lib/blkid/devno.c +++ b/lib/blkid/devno.c @@ -122,7 +122,7 @@ void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list, path, *devname)); break; } - if (list && S_ISDIR(st.st_mode) && !lstat(path, &st) && + if (list && S_ISDIR(st.st_mode) && !lstat(path, &st) && S_ISDIR(st.st_mode)) add_to_dirlist(path, list); } @@ -175,13 +175,13 @@ char *blkid_devno_to_devname(dev_t devno) if (!devname) { DBG(DEBUG_DEVNO, - printf("blkid: couldn't find devno 0x%04lx\n", + printf("blkid: couldn't find devno 0x%04lx\n", (unsigned long) devno)); } else { DBG(DEBUG_DEVNO, printf("found devno 0x%04llx as %s\n", (long long)devno, devname)); } - + return devname; } diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c index 876d682c..10ba7ecf 100644 --- a/lib/blkid/getsize.c +++ b/lib/blkid/getsize.c @@ -199,7 +199,7 @@ int main(int argc, char **argv) perror(argv[0]); bytes = blkid_get_dev_size(fd); - printf("Device %s has %Ld 1k blocks.\n", argv[1], + printf("Device %s has %Ld 1k blocks.\n", argv[1], (unsigned long long) bytes >> 10); return 0; diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 04eb29a7..10ac8036 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -47,7 +47,7 @@ static int figure_label_len(const unsigned char *label, int len) return 0; } -static unsigned char *get_buffer(struct blkid_probe *pr, +static unsigned char *get_buffer(struct blkid_probe *pr, blkid_loff_t off, size_t len) { ssize_t ret_read; @@ -96,7 +96,7 @@ static int check_mdraid(int fd, unsigned char *ret_uuid) struct mdp_superblock_s *md; blkid_loff_t offset; char buf[4096]; - + if (fd < 0) return -BLKID_ERR_PARAM; @@ -139,7 +139,7 @@ static void get_ext2_info(blkid_dev dev, struct blkid_magic *id, struct ext2_super_block *es = (struct ext2_super_block *) buf; const char *label = 0; - DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n", + DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n", blkid_le32(es->s_feature_compat), blkid_le32(es->s_feature_incompat), blkid_le32(es->s_feature_ro_compat))); @@ -307,7 +307,7 @@ static int probe_ext4(struct blkid_probe *probe, struct blkid_magic *id, es = (struct ext2_super_block *)buf; /* Distinguish from jbd */ - if (blkid_le32(es->s_feature_incompat) & + if (blkid_le32(es->s_feature_incompat) & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) return -BLKID_ERR_PARAM; @@ -419,13 +419,13 @@ static unsigned char *search_fat_label(struct vfat_dir_entry *dir, int count) for (i = 0; i < count; i++) { if (dir[i].name[0] == 0x00) break; - + if ((dir[i].name[0] == FAT_ENTRY_FREE) || (dir[i].cluster_high != 0 || dir[i].cluster_low != 0) || ((dir[i].attr & FAT_ATTR_MASK) == FAT_ATTR_LONG_NAME)) continue; - if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) == + if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) == FAT_ATTR_VOLUME_ID) { return dir[i].name; } @@ -436,7 +436,7 @@ static unsigned char *search_fat_label(struct vfat_dir_entry *dir, int count) /* FAT label extraction from the root directory taken from Kay * Sievers's volume_id library */ static int probe_fat(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct vfat_super_block *vs = (struct vfat_super_block *) buf; @@ -484,11 +484,11 @@ static int probe_fat(struct blkid_probe *probe, if (ms->ms_fat_length) { /* the label may be an attribute in the root directory */ root_start = (reserved + fat_size) * sector_size; - root_dir_entries = vs->vs_dir_entries[0] + + root_dir_entries = vs->vs_dir_entries[0] + (vs->vs_dir_entries[1] << 8); buf_size = root_dir_entries * sizeof(struct vfat_dir_entry); - dir = (struct vfat_dir_entry *) get_buffer(probe, root_start, + dir = (struct vfat_dir_entry *) get_buffer(probe, root_start, buf_size); if (dir) vol_label = search_fat_label(dir, root_dir_entries); @@ -497,7 +497,7 @@ static int probe_fat(struct blkid_probe *probe, vol_label = ms->ms_label; vol_serno = ms->ms_serno; - blkid_set_tag(probe->dev, "SEC_TYPE", "msdos", + blkid_set_tag(probe->dev, "SEC_TYPE", "msdos", sizeof("msdos")); } else { /* Search the FAT32 root dir for the label attribute */ @@ -511,10 +511,10 @@ static int probe_fat(struct blkid_probe *probe, int count; next_sect_off = (next - 2) * vs->vs_cluster_size; - next_off = (start_data_sect + next_sect_off) * + next_off = (start_data_sect + next_sect_off) * sector_size; - dir = (struct vfat_dir_entry *) + dir = (struct vfat_dir_entry *) get_buffer(probe, next_off, buf_size); if (dir == NULL) break; @@ -526,7 +526,7 @@ static int probe_fat(struct blkid_probe *probe, break; /* get FAT entry */ - fat_entry_off = (reserved * sector_size) + + fat_entry_off = (reserved * sector_size) + (next * sizeof(__u32)); buf = get_buffer(probe, fat_entry_off, buf_size); if (buf == NULL) @@ -563,7 +563,7 @@ static int probe_fat(struct blkid_probe *probe, * [7-Jul-2005, Karel Zak <kzak@redhat.com>] */ static int probe_fat_nomagic(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct msdos_super_block *ms; @@ -574,7 +574,7 @@ static int probe_fat_nomagic(struct blkid_probe *probe, if (ms->ms_heads == 0) return 1; - /* cluster size check*/ + /* cluster size check*/ if (ms->ms_cluster_size == 0 || (ms->ms_cluster_size & (ms->ms_cluster_size-1))) return 1; @@ -604,7 +604,7 @@ static int probe_fat_nomagic(struct blkid_probe *probe, } static int probe_ntfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct ntfs_super_block *ns; @@ -631,7 +631,7 @@ static int probe_ntfs(struct blkid_probe *probe, if (ns->cluster_per_mft_record < 0) mft_record_size = 1 << (0-ns->cluster_per_mft_record); else - mft_record_size = ns->cluster_per_mft_record * + mft_record_size = ns->cluster_per_mft_record * sectors_per_cluster * bytes_per_sector; nr_clusters = blkid_le64(ns->number_of_sectors) / sectors_per_cluster; @@ -639,7 +639,7 @@ static int probe_ntfs(struct blkid_probe *probe, (blkid_le64(ns->mft_mirror_cluster_location) > nr_clusters)) return 1; - off = blkid_le64(ns->mft_mirror_cluster_location) * + off = blkid_le64(ns->mft_mirror_cluster_location) * bytes_per_sector * sectors_per_cluster; buf_mft = get_buffer(probe, off, mft_record_size); @@ -649,7 +649,7 @@ static int probe_ntfs(struct blkid_probe *probe, if (memcmp(buf_mft, "FILE", 4)) return 1; - off = blkid_le64(ns->mft_cluster_location) * bytes_per_sector * + off = blkid_le64(ns->mft_cluster_location) * bytes_per_sector * sectors_per_cluster; buf_mft = get_buffer(probe, off, mft_record_size); @@ -672,7 +672,7 @@ static int probe_ntfs(struct blkid_probe *probe, attr_off = blkid_le16(mft->attrs_offset); label_str[0] = 0; - + while (1) { attr = (struct file_attribute *) (buf_mft + attr_off); attr_len = blkid_le16(attr->len); @@ -712,7 +712,7 @@ static int probe_ntfs(struct blkid_probe *probe, static int probe_xfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct xfs_super_block *xs; @@ -756,7 +756,7 @@ static int probe_reiserfs(struct blkid_probe *probe, } static int probe_reiserfs4(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct reiser4_super_block *rs4 = (struct reiser4_super_block *) buf; @@ -765,14 +765,14 @@ static int probe_reiserfs4(struct blkid_probe *probe, if (strlen((char *) rs4->rs4_label)) label = rs4->rs4_label; set_uuid(probe->dev, rs4->rs4_uuid, 0); - blkid_set_tag(probe->dev, "LABEL", (const char *) label, + blkid_set_tag(probe->dev, "LABEL", (const char *) label, sizeof(rs4->rs4_label)); return 0; } static int probe_jfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct jfs_super_block *js; @@ -825,7 +825,7 @@ static int probe_luks(struct blkid_probe *probe, } static int probe_romfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct romfs_super_block *ros; @@ -840,7 +840,7 @@ static int probe_romfs(struct blkid_probe *probe, } static int probe_cramfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct cramfs_super_block *csb; @@ -888,7 +888,7 @@ static int probe_swap1(struct blkid_probe *probe, /* arbitrary sanity check.. is there any garbage down there? */ if (sws->sws_pad[32] == 0 && sws->sws_pad[33] == 0) { if (sws->sws_volume[0]) - blkid_set_tag(probe->dev, "LABEL", sws->sws_volume, + blkid_set_tag(probe->dev, "LABEL", sws->sws_volume, sizeof(sws->sws_volume)); if (sws->sws_uuid[0]) set_uuid(probe->dev, sws->sws_uuid, 0); @@ -897,7 +897,7 @@ static int probe_swap1(struct blkid_probe *probe, } static int probe_iso9660(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct iso_volume_descriptor *iso; @@ -906,7 +906,7 @@ static int probe_iso9660(struct blkid_probe *probe, iso = (struct iso_volume_descriptor *) buf; label = iso->volume_id; - blkid_set_tag(probe->dev, "LABEL", (const char *) label, + blkid_set_tag(probe->dev, "LABEL", (const char *) label, figure_label_len(label, 32)); return 0; } @@ -917,7 +917,7 @@ static const char "NSR03", "TEA01", 0 }; static int probe_udf(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf __BLKID_ATTR((unused))) { int j, bs; @@ -927,7 +927,7 @@ static int probe_udf(struct blkid_probe *probe, /* determine the block size by scanning in 2K increments (block sizes larger than 2K will be null padded) */ for (bs = 1; bs < 16; bs++) { - isosb = (struct iso_volume_descriptor *) + isosb = (struct iso_volume_descriptor *) get_buffer(probe, bs*2048+32768, sizeof(isosb)); if (!isosb) return 1; @@ -938,8 +938,8 @@ static int probe_udf(struct blkid_probe *probe, /* Scan up to another 64 blocks looking for additional VSD's */ for (j = 1; j < 64; j++) { if (j > 1) { - isosb = (struct iso_volume_descriptor *) - get_buffer(probe, j*bs*2048+32768, + isosb = (struct iso_volume_descriptor *) + get_buffer(probe, j*bs*2048+32768, sizeof(isosb)); if (!isosb) return 1; @@ -960,7 +960,7 @@ static int probe_udf(struct blkid_probe *probe, } static int probe_ocfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct ocfs_volume_header ovh; @@ -975,7 +975,7 @@ static int probe_ocfs(struct blkid_probe *probe, blkid_set_tag(probe->dev,"SEC_TYPE","ocfs1",sizeof("ocfs1")); else if (major >= 9) blkid_set_tag(probe->dev,"SEC_TYPE","ntocfs",sizeof("ntocfs")); - + blkid_set_tag(probe->dev, "LABEL", ovl.label, ocfslabellen(ovl)); blkid_set_tag(probe->dev, "MOUNT", ovh.mount, ocfsmountlen(ovh)); set_uuid(probe->dev, ovl.vol_id, 0); @@ -983,7 +983,7 @@ static int probe_ocfs(struct blkid_probe *probe, } static int probe_ocfs2(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct ocfs2_super_block *osb; @@ -996,7 +996,7 @@ static int probe_ocfs2(struct blkid_probe *probe, } static int probe_oracleasm(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct oracle_asm_disk_label *dl; @@ -1018,9 +1018,9 @@ static int probe_gfs(struct blkid_probe *probe, if (blkid_be32(sbd->sb_fs_format) == GFS_FORMAT_FS && blkid_be32(sbd->sb_multihost_format) == GFS_FORMAT_MULTI) - { + { blkid_set_tag(probe->dev, "UUID", 0, 0); - + if (strlen(sbd->sb_locktable)) label = sbd->sb_locktable; blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable)); @@ -1040,9 +1040,9 @@ static int probe_gfs2(struct blkid_probe *probe, if (blkid_be32(sbd->sb_fs_format) == GFS2_FORMAT_FS && blkid_be32(sbd->sb_multihost_format) == GFS2_FORMAT_MULTI) - { + { blkid_set_tag(probe->dev, "UUID", 0, 0); - + if (strlen(sbd->sb_locktable)) label = sbd->sb_locktable; blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable)); @@ -1051,7 +1051,7 @@ static int probe_gfs2(struct blkid_probe *probe, return 1; } -static void unicode_16be_to_utf8(unsigned char *str, int out_len, +static void unicode_16be_to_utf8(unsigned char *str, int out_len, const unsigned char *buf, int in_len) { int i, j; @@ -1138,7 +1138,7 @@ static int probe_hfsplus(struct blkid_probe *probe, (memcmp(sbd->embed_sig, "HX", 2) != 0)) /* This must be an HFS volume, so fail */ return 1; - + alloc_block_size = blkid_be32(sbd->al_blk_size); alloc_first_block = blkid_be16(sbd->al_bl_st); embed_first_block = blkid_be16(sbd->embed_startblock); @@ -1431,7 +1431,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) if ((now >= dev->bid_time) && (st.st_mtime <= dev->bid_time) && - ((diff < BLKID_PROBE_MIN) || + ((diff < BLKID_PROBE_MIN) || (dev->bid_flags & BLKID_BID_FL_VERIFIED && diff < BLKID_PROBE_INTERVAL))) return dev; @@ -1444,7 +1444,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) if ((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) { DBG(DEBUG_PROBE, printf("blkid_verify: error %s (%d) while " - "opening %s\n", strerror(errno), errno, + "opening %s\n", strerror(errno), errno, dev->bid_name)); goto open_err; } @@ -1454,12 +1454,12 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) probe.sbbuf = 0; probe.buf = 0; probe.buf_max = 0; - + /* * Iterate over the type array. If we already know the type, * then try that first. If it doesn't work, then blow away * the type information, and try again. - * + * */ try_again: type = 0; @@ -1530,7 +1530,7 @@ found_type: free(probe.sbbuf); if (probe.buf) free(probe.buf); - if (probe.fd >= 0) + if (probe.fd >= 0) close(probe.fd); return dev; @@ -1574,7 +1574,7 @@ int main(int argc, char **argv) printf("LABEL='%s'\n", dev->bid_label); if (dev->bid_uuid) printf("UUID='%s'\n", dev->bid_uuid); - + blkid_free_dev(dev); return (0); } diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h index 993156d1..bee5a518 100644 --- a/lib/blkid/probe.h +++ b/lib/blkid/probe.h @@ -30,7 +30,7 @@ struct blkid_probe { size_t buf_max; }; -typedef int (*blkid_probe_t)(struct blkid_probe *probe, +typedef int (*blkid_probe_t)(struct blkid_probe *probe, struct blkid_magic *id, unsigned char *buf); struct blkid_magic { @@ -347,7 +347,7 @@ struct ocfs_volume_header { struct ocfs_volume_label { unsigned char disk_lock[48]; - char label[64]; + char label[64]; unsigned char label_len[2]; unsigned char vol_id[16]; unsigned char vol_id_len[2]; @@ -432,15 +432,15 @@ struct gfs2_sb { __u32 sb_fs_format; __u32 sb_multihost_format; __u32 __pad0; /* Was superblock flags in gfs1 */ - + __u32 sb_bsize; __u32 sb_bsize_shift; __u32 __pad1; /* Was journal segment size in gfs1 */ - + struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */ struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */ struct gfs2_inum sb_root_dir; - + char sb_lockproto[GFS_LOCKNAME_LEN]; char sb_locktable[GFS_LOCKNAME_LEN]; /* In gfs1, quota and license dinodes followed */ @@ -686,7 +686,7 @@ _INLINE_ __u64 blkid_swab64(__u64 val) return (blkid_swab32(val >> 32) | (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32)); } -#endif +#endif diff --git a/lib/blkid/read.c b/lib/blkid/read.c index b913b631..ca2798f0 100644 --- a/lib/blkid/read.c +++ b/lib/blkid/read.c @@ -315,7 +315,7 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp) return ret; /* Some tags are stored directly in the device struct */ - if (!strcmp(name, "DEVNO")) + if (!strcmp(name, "DEVNO")) dev->bid_devno = STRTOULL(value, 0, 0); else if (!strcmp(name, "PRI")) dev->bid_pri = strtol(value, 0, 0); @@ -401,7 +401,7 @@ void blkid_read_cache(blkid_cache cache) cache->bic_filename)); goto errout; } - + DBG(DEBUG_CACHE, printf("reading cache file %s\n", cache->bic_filename)); @@ -463,7 +463,7 @@ static void debug_dump_dev(blkid_dev dev) list_for_each(p, &dev->bid_tags) { blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); if (tag) - printf(" tag: %s=\"%s\"\n", tag->bit_name, + printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val); else printf(" tag: NULL\n"); diff --git a/lib/blkid/resolve.c b/lib/blkid/resolve.c index b4a93081..678f34e7 100644 --- a/lib/blkid/resolve.c +++ b/lib/blkid/resolve.c @@ -68,7 +68,7 @@ char *blkid_get_devname(blkid_cache cache, const char *token, if (!token) return NULL; - + if (!cache) { if (blkid_get_cache(&c, NULL) < 0) return NULL; @@ -126,7 +126,7 @@ int main(int argc, char **argv) fprintf(stderr, "Couldn't get blkid cache\n"); exit(1); } - + if (argv[2]) { value = blkid_get_tag_value(cache, argv[1], argv[2]); printf("%s has tag %s=%s\n", argv[2], argv[1], diff --git a/lib/blkid/save.c b/lib/blkid/save.c index 60aa6ce7..656bb0bb 100644 --- a/lib/blkid/save.c +++ b/lib/blkid/save.c @@ -181,7 +181,7 @@ int main(int argc, char **argv) exit(1); } cache->bic_filename = blkid_strdup(argv[1]); - + if ((ret = blkid_flush_cache(cache)) < 0) { fprintf(stderr, "error (%d) saving cache\n", ret); exit(1); diff --git a/lib/blkid/tag.c b/lib/blkid/tag.c index 8a8ac990..b305ab48 100644 --- a/lib/blkid/tag.c +++ b/lib/blkid/tag.c @@ -83,7 +83,7 @@ blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type) return NULL; } -extern int blkid_dev_has_tag(blkid_dev dev, const char *type, +extern int blkid_dev_has_tag(blkid_dev dev, const char *type, const char *value) { blkid_tag tag; @@ -125,7 +125,7 @@ static blkid_tag blkid_find_head_cache(blkid_cache cache, const char *type) /* * Set a tag on an existing device. - * + * * If value is NULL, then delete the tagsfrom the device. */ int blkid_set_tag(blkid_dev dev, const char *name, @@ -141,7 +141,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, if (!(val = blkid_strndup(value, vlength)) && value) return -BLKID_ERR_MEM; - /* + /* * Certain common tags are linked directly to the device struct * We need to know what they are before we do anything else because * the function name parameter might get freed later on. @@ -174,7 +174,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, t->bit_dev = dev; list_add_tail(&t->bit_tags, &dev->bid_tags); - + if (dev->bid_cache) { head = blkid_find_head_cache(dev->bid_cache, t->bit_name); @@ -194,11 +194,11 @@ int blkid_set_tag(blkid_dev dev, const char *name, list_add_tail(&t->bit_names, &head->bit_names); } } - + /* Link common tags directly to the device struct */ if (dev_var) *dev_var = val; - + if (dev->bid_cache) dev->bid_cache->bic_flags |= BLKID_BIC_FL_CHANGED; return 0; @@ -274,7 +274,7 @@ errout: * This series of functions iterate over all tags in a device */ #define TAG_ITERATE_MAGIC 0x01a5284c - + struct blkid_struct_tag_iterate { int magic; blkid_dev dev; @@ -301,7 +301,7 @@ extern int blkid_tag_next(blkid_tag_iterate iter, const char **type, const char **value) { blkid_tag tag; - + *type = 0; *value = 0; if (!iter || iter->magic != TAG_ITERATE_MAGIC || @@ -342,9 +342,9 @@ extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache, return NULL; blkid_read_cache(cache); - + DBG(DEBUG_TAG, printf("looking for %s=%s in cache\n", type, value)); - + try_again: pri = -1; dev = 0; @@ -352,7 +352,7 @@ try_again: if (head) { list_for_each(p, &head->bit_names) { - blkid_tag tmp = list_entry(p, struct blkid_struct_tag, + blkid_tag tmp = list_entry(p, struct blkid_struct_tag, bit_names); if (!strcmp(tmp->bit_val, value) && @@ -395,7 +395,7 @@ extern int optind; void usage(char *prog) { fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device " - "[type value]\n", + "[type value]\n", prog); fprintf(stderr, "\tList all tags for a device and exit\n"); exit(1); @@ -423,7 +423,7 @@ int main(int argc, char **argv) case 'm': blkid_debug_mask = strtoul (optarg, &tmp, 0); if (*tmp) { - fprintf(stderr, "Invalid debug mask: %s\n", + fprintf(stderr, "Invalid debug mask: %s\n", optarg); exit(1); } @@ -448,14 +448,14 @@ int main(int argc, char **argv) dev = blkid_get_dev(cache, devname, flags); if (!dev) { - fprintf(stderr, "%s: Can not find device in blkid cache\n", + fprintf(stderr, "%s: Can not find device in blkid cache\n", devname); exit(1); } if (search_type) { found = blkid_dev_has_tag(dev, search_type, search_value); printf("Device %s: (%s, %s) %s\n", blkid_dev_devname(dev), - search_type, search_value ? search_value : "NULL", + search_type, search_value ? search_value : "NULL", found ? "FOUND" : "NOT FOUND"); return(!found); } diff --git a/lib/blkid/tst_types.c b/lib/blkid/tst_types.c index 8e3055d9..3003c8b5 100644 --- a/lib/blkid/tst_types.c +++ b/lib/blkid/tst_types.c @@ -2,7 +2,7 @@ * This testing program makes sure the blkid_types header file * * Copyright (C) 2006 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h index ad607f68..98c97db4 100644 --- a/lib/e2p/e2p.h +++ b/lib/e2p/e2p.h @@ -40,7 +40,7 @@ const char *e2p_feature2string(int compat, unsigned int mask); int e2p_string2feature(char *string, int *compat, unsigned int *mask); int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array); int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, - __u32 *clear_ok_array, int *type_err, + __u32 *clear_ok_array, int *type_err, unsigned int *mask_err); int e2p_is_null_uuid(void *uu); diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c index e3a72047..1da3c7de 100644 --- a/lib/e2p/feature.c +++ b/lib/e2p/feature.c @@ -1,11 +1,11 @@ /* * feature.c --- convert between features and strings - * + * * Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License - * + * */ #include <stdio.h> @@ -251,11 +251,11 @@ static char *skip_over_word(char *cp) /* * Edit a feature set array as requested by the user. The ok_array, * if set, allows the application to limit what features the user is - * allowed to set or clear using this function. If clear_ok_array is set, + * allowed to set or clear using this function. If clear_ok_array is set, * then use it tell whether or not it is OK to clear a filesystem feature. */ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, - __u32 *clear_ok_array, int *type_err, + __u32 *clear_ok_array, int *type_err, unsigned int *mask_err) { char *cp, *buf, *next; @@ -280,7 +280,7 @@ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, neg = 0; cp = skip_over_blanks(cp); next = skip_over_word(cp); - + if (*next == 0) next = 0; else @@ -307,11 +307,11 @@ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, break; } if (neg) { - if (clear_ok_array && + if (clear_ok_array && !(clear_ok_array[compat_type] & mask)) { rc = 1; if (type_err) - *type_err = (compat_type | + *type_err = (compat_type | E2P_FEATURE_NEGATE_FLAG); if (mask_err) *mask_err = mask; diff --git a/lib/e2p/fsetflags.c b/lib/e2p/fsetflags.c index 3a053240..62189c9b 100644 --- a/lib/e2p/fsetflags.c +++ b/lib/e2p/fsetflags.c @@ -32,8 +32,8 @@ #include "e2p.h" -/* - * Deal with lame glibc's that define this function without actually +/* + * Deal with lame glibc's that define this function without actually * implementing it. Can you say "attractive nuisance", boys and girls? * I knew you could! */ diff --git a/lib/e2p/getflags.c b/lib/e2p/getflags.c index acf7a122..7b35246d 100644 --- a/lib/e2p/getflags.c +++ b/lib/e2p/getflags.c @@ -51,7 +51,7 @@ int getflags (int fd, unsigned long * flags) #else #if HAVE_EXT2_IOCTLS int r, f; - + if (!fstat(fd, &buf) && !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) goto notsupp; diff --git a/lib/e2p/getversion.c b/lib/e2p/getversion.c index 38b7d0fb..47c588fd 100644 --- a/lib/e2p/getversion.c +++ b/lib/e2p/getversion.c @@ -25,7 +25,7 @@ int getversion (int fd, unsigned long * version) { #if HAVE_EXT2_IOCTLS int r, ver; - + r = ioctl (fd, EXT2_IOC_GETVERSION, &ver); *version = ver; return 0; diff --git a/lib/e2p/hashstr.c b/lib/e2p/hashstr.c index b257eb26..ece4d058 100644 --- a/lib/e2p/hashstr.c +++ b/lib/e2p/hashstr.c @@ -1,11 +1,11 @@ /* * feature.c --- convert between features and strings - * + * * Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License - * + * */ #include <stdio.h> diff --git a/lib/e2p/iod.c b/lib/e2p/iod.c index 84c97094..2c675b9d 100644 --- a/lib/e2p/iod.c +++ b/lib/e2p/iod.c @@ -29,7 +29,7 @@ int iterate_on_dir (const char * dir_name, struct dirent *de, *dep; int max_len = -1, len, ret = 0; -#if HAVE_PATHCONF && defined(_PC_NAME_MAX) +#if HAVE_PATHCONF && defined(_PC_NAME_MAX) max_len = pathconf(dir_name, _PC_NAME_MAX); #endif if (max_len == -1) { diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c index c211dce7..6d2ce70a 100644 --- a/lib/e2p/ls.c +++ b/lib/e2p/ls.c @@ -6,7 +6,7 @@ * Universite Pierre et Marie Curie (Paris VI) * * Copyright (C) 1995, 1996, 1997 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License */ @@ -227,7 +227,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f) fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb)); fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb)); if (sb->s_reserved_gdt_blocks) - fprintf(f, "Reserved GDT blocks: %u\n", + fprintf(f, "Reserved GDT blocks: %u\n", sb->s_reserved_gdt_blocks); fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group); fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group); @@ -275,10 +275,10 @@ void list_super2(struct ext2_super_block * sb, FILE *f) fprintf(f, "First inode: %d\n", sb->s_first_ino); fprintf(f, "Inode size: %d\n", sb->s_inode_size); if (sb->s_min_extra_isize) - fprintf(f, "Required extra isize: %d\n", + fprintf(f, "Required extra isize: %d\n", sb->s_min_extra_isize); if (sb->s_want_extra_isize) - fprintf(f, "Desired extra isize: %d\n", + fprintf(f, "Desired extra isize: %d\n", sb->s_want_extra_isize); } if (!e2p_is_null_uuid(sb->s_journal_uuid)) diff --git a/lib/e2p/mntopts.c b/lib/e2p/mntopts.c index 4e50e9f9..51e349dc 100644 --- a/lib/e2p/mntopts.c +++ b/lib/e2p/mntopts.c @@ -1,11 +1,11 @@ /* * mountopts.c --- convert between default mount options and strings - * + * * Copyright (C) 2002 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License - * + * */ #include <stdio.h> diff --git a/lib/e2p/ostype.c b/lib/e2p/ostype.c index 3cd6257c..c477535a 100644 --- a/lib/e2p/ostype.c +++ b/lib/e2p/ostype.c @@ -12,10 +12,10 @@ #include <stdlib.h> static const char *os_tab[] = - { "Linux", - "Hurd", - "Masix", - "FreeBSD", + { "Linux", + "Hurd", + "Masix", + "FreeBSD", "Lites", 0 }; diff --git a/lib/e2p/parse_num.c b/lib/e2p/parse_num.c index 7e9ee71a..7f817d60 100644 --- a/lib/e2p/parse_num.c +++ b/lib/e2p/parse_num.c @@ -1,8 +1,8 @@ /* - * parse_num.c - Parse the number of blocks + * parse_num.c - Parse the number of blocks * * Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License */ @@ -18,25 +18,25 @@ unsigned long parse_num_blocks(const char *arg, int log_block_size) num = strtoull(arg, &p, 0); - if (p[0] && p[1]) + if (p[0] && p[1]) return 0; switch (*p) { /* Using fall-through logic */ - case 'T': case 't': + case 'T': case 't': num <<= 10; - case 'G': case 'g': + case 'G': case 'g': num <<= 10; - case 'M': case 'm': + case 'M': case 'm': num <<= 10; - case 'K': case 'k': - num >>= log_block_size; + case 'K': case 'k': + num >>= log_block_size; break; - case 's': + case 's': num >>= (1+log_block_size); break; case '\0': break; - default: + default: return 0; } return num; diff --git a/lib/e2p/percent.c b/lib/e2p/percent.c index b8c936df..94d71e5c 100644 --- a/lib/e2p/percent.c +++ b/lib/e2p/percent.c @@ -2,7 +2,7 @@ * percent.c - Take percentage of a number * * Copyright (C) 2006 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License */ @@ -23,7 +23,7 @@ unsigned int e2p_percent(int percent, unsigned int base) return 0; if (100 % percent == 0) return base / (100 / percent); - if (mask & base) + if (mask & base) return (base / 100) * percent; return base * percent / 100; } @@ -49,7 +49,7 @@ main(int argc, char **argv) fprintf(stderr, "Bad percent: %s\n", argv[1]); exit(1); } - + base = strtoul(argv[2], &p, 0); if (p[0] && p[1]) { fprintf(stderr, "Bad base: %s\n", argv[2]); diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c index 05a961a9..078b82c7 100644 --- a/lib/e2p/pf.c +++ b/lib/e2p/pf.c @@ -41,7 +41,7 @@ static struct flags_name flags_array[] = { { EXT2_ECOMPR_FL, "E", "Compression_Error" }, #endif { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" }, - { EXT2_INDEX_FL, "I", "Indexed_direcctory" }, + { EXT2_INDEX_FL, "I", "Indexed_direcctory" }, { EXT2_NOTAIL_FL, "t", "No_Tailmerging" }, { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" }, { EXT4_EXTENTS_FL, "e", "Extents" }, diff --git a/lib/e2p/setflags.c b/lib/e2p/setflags.c index 47c52a7a..908f0f19 100644 --- a/lib/e2p/setflags.c +++ b/lib/e2p/setflags.c @@ -25,8 +25,8 @@ #include "e2p.h" -/* - * Deal with lame glibc's that define this function without actually +/* + * Deal with lame glibc's that define this function without actually * implementing it. Can you say "attractive nuisance", boys and girls? * I knew you could! */ diff --git a/lib/e2p/uuid.c b/lib/e2p/uuid.c index 60d42bae..0bf8f829 100644 --- a/lib/e2p/uuid.c +++ b/lib/e2p/uuid.c @@ -42,7 +42,7 @@ static void e2p_unpack_uuid(void *in, struct uuid *uu) tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_mid = tmp; - + tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_hi_and_version = tmp; diff --git a/lib/et/com_err.c b/lib/et/com_err.c index 77938b04..d83d6a92 100644 --- a/lib/et/com_err.c +++ b/lib/et/com_err.c @@ -1,6 +1,6 @@ /* * Copyright 1987, 1988 by MIT Student Information Processing Board. - * + * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose is hereby granted, provided that * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in diff --git a/lib/et/com_err.h b/lib/et/com_err.h index a49c5a5a..1c6ce94c 100644 --- a/lib/et/com_err.h +++ b/lib/et/com_err.h @@ -36,10 +36,10 @@ extern void com_err_va (const char *whoami, errcode_t code, const char *fmt, extern char const *error_message (long); extern void (*com_err_hook) (const char *, long, const char *, va_list); -extern void (*set_com_err_hook (void (*) (const char *, long, +extern void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list))) (const char *, long, const char *, va_list); -extern void (*reset_com_err_hook (void)) (const char *, long, +extern void (*reset_com_err_hook (void)) (const char *, long, const char *, va_list); extern int init_error_table(const char * const *msgs, long base, int count); @@ -49,8 +49,8 @@ extern void add_to_error_table(struct et_list *new_table); /* Provided for Heimdall compatibility */ extern const char *com_right(struct et_list *list, long code); -extern void initialize_error_table_r(struct et_list **list, - const char **messages, +extern void initialize_error_table_r(struct et_list **list, + const char **messages, int num_errors, long base); extern void free_error_table(struct et_list *et); diff --git a/lib/et/com_right.c b/lib/et/com_right.c index 5ac6e7f0..173fd1a3 100644 --- a/lib/et/com_right.c +++ b/lib/et/com_right.c @@ -1,41 +1,41 @@ /* * com_right.c -- provide Heimdall / Kerberos4kth com_err interfaces - * for backwards compatbility - * + * for backwards compatbility + * * Copyright (c) 2003 by Theodore Ts'o * * Taken from lib/com_err/error.c from Kerberos4kth distribution. - * + * * Copyright (c) 1997, 1998, 2001 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #include <stdio.h> @@ -68,8 +68,8 @@ struct foobar { * afoul of dependencies. */ void -initialize_error_table_r(struct et_list **list, - const char **messages, +initialize_error_table_r(struct et_list **list, + const char **messages, int num_errors, long base) { @@ -91,7 +91,7 @@ initialize_error_table_r(struct et_list **list, et->next = NULL; *end = et; } - + void free_error_table(struct et_list *et) diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c index ebe2bf6e..230bec9c 100644 --- a/lib/ext2fs/alloc.c +++ b/lib/ext2fs/alloc.c @@ -7,7 +7,7 @@ * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -100,7 +100,7 @@ static check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map, * * Should have a special policy for directories. */ -errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, +errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode EXT2FS_ATTR((unused)), ext2fs_inode_bitmap map, ext2_ino_t *ret) { @@ -109,13 +109,13 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t start_inode; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); - + if (!map) map = fs->inode_map; if (!map) return EXT2_ET_NO_INODE_BITMAP; - - if (dir > 0) + + if (dir > 0) dir_group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super); start_inode = (dir_group * EXT2_INODES_PER_GROUP(fs->super)) + 1; @@ -134,7 +134,7 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, if (i > fs->super->s_inodes_count) i = EXT2_FIRST_INODE(fs->super); } while (i != start_inode); - + if (ext2fs_test_inode_bitmap(map, i)) return EXT2_ET_INODE_ALLOC_FAIL; *ret = i; @@ -221,7 +221,7 @@ errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, retval = io_channel_write_blk(fs->io, block, 1, block_buf); if (retval) goto fail; - + ext2fs_block_alloc_stats(fs, block, +1); *ret = block; @@ -260,7 +260,7 @@ errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish, return EXT2_ET_BLOCK_ALLOC_FAIL; } -void ext2fs_set_alloc_block_callback(ext2_filsys fs, +void ext2fs_set_alloc_block_callback(ext2_filsys fs, errcode_t (*func)(ext2_filsys fs, blk64_t goal, blk64_t *ret), diff --git a/lib/ext2fs/alloc_sb.c b/lib/ext2fs/alloc_sb.c index cdcb8666..b0aeb964 100644 --- a/lib/ext2fs/alloc_sb.c +++ b/lib/ext2fs/alloc_sb.c @@ -1,5 +1,5 @@ /* - * alloc_sb.c --- Allocate the superblock and block group descriptors for a + * alloc_sb.c --- Allocate the superblock and block group descriptors for a * newly initialized filesystem. Used by mke2fs when initializing a filesystem * * Copyright (C) 1994, 1995, 1996, 2003 Theodore Ts'o. @@ -40,20 +40,20 @@ * * See also the comment for ext2fs_super_and_bgd_loc() */ -int ext2fs_reserve_super_and_bgd(ext2_filsys fs, +int ext2fs_reserve_super_and_bgd(ext2_filsys fs, dgrp_t group, ext2fs_block_bitmap bmap) { blk_t super_blk, old_desc_blk, new_desc_blk; int j, old_desc_blocks, num_blocks; - num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk, + num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk, &old_desc_blk, &new_desc_blk, 0); if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else - old_desc_blocks = + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; if (super_blk || (group == 0)) diff --git a/lib/ext2fs/alloc_stats.c b/lib/ext2fs/alloc_stats.c index a8514cc2..97661dc7 100644 --- a/lib/ext2fs/alloc_stats.c +++ b/lib/ext2fs/alloc_stats.c @@ -7,7 +7,7 @@ * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -73,7 +73,7 @@ void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse) (fs->block_alloc_stats)(fs, (blk64_t) blk, inuse); } -void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, +void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, void (*func)(ext2_filsys fs, blk64_t blk, int inuse), diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c index 7726eefd..4d2535e4 100644 --- a/lib/ext2fs/alloc_tables.c +++ b/lib/ext2fs/alloc_tables.c @@ -101,7 +101,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, if (last_grp > fs->group_desc_count) last_grp = fs->group_desc_count; } - + /* * Allocate the block and inode bitmaps, if necessary */ @@ -130,7 +130,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, if (!fs->group_desc[group].bg_block_bitmap) { retval = ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, bmap, &new_blk); - if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) + if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) retval = ext2fs_get_free_blocks(fs, group_blk, last_blk, 1, bmap, &new_blk); if (retval) @@ -158,7 +158,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, if (!fs->group_desc[group].bg_inode_bitmap) { retval = ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, bmap, &new_blk); - if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) + if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) retval = ext2fs_get_free_blocks(fs, group_blk, last_blk, 1, bmap, &new_blk); if (retval) diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c index da7889d2..6eadb126 100644 --- a/lib/ext2fs/badblocks.c +++ b/lib/ext2fs/badblocks.c @@ -1,6 +1,6 @@ /* * badblocks.c --- routines to manipulate the bad block structure - * + * * Copyright (C) 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -34,7 +34,7 @@ static errcode_t make_u32_list(int size, int num, __u32 *list, { ext2_u32_list bb; errcode_t retval; - + retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list), &bb); if (retval) return retval; @@ -54,7 +54,7 @@ static errcode_t make_u32_list(int size, int num, __u32 *list, *ret = bb; return 0; } - + /* * This procedure creates an empty u32 list. @@ -79,7 +79,7 @@ errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size) errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest) { errcode_t retval; - + retval = make_u32_list(src->size, src->num, src->list, dest); if (retval) return retval; @@ -271,11 +271,11 @@ int ext2fs_u32_list_iterate(ext2_u32_iterate iter, __u32 *blk) if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) return 0; - + if (iter->ptr < bb->num) { *blk = bb->list[iter->ptr++]; return 1; - } + } *blk = 0; return 0; } diff --git a/lib/ext2fs/bb_compat.c b/lib/ext2fs/bb_compat.c index 40f73436..5a158b34 100644 --- a/lib/ext2fs/bb_compat.c +++ b/lib/ext2fs/bb_compat.c @@ -1,6 +1,6 @@ /* * bb_compat.c --- compatibility badblocks routines - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c index dbda79f1..cbeeb98f 100644 --- a/lib/ext2fs/bb_inode.c +++ b/lib/ext2fs/bb_inode.c @@ -1,12 +1,12 @@ /* * bb_inode.c --- routines to update the bad block inode. - * + * * WARNING: This routine modifies a lot of state in the filesystem; if * this routine returns an error, the bad block inode may be in an * inconsistent state. - * + * * Copyright (C) 1994, 1995 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -49,7 +49,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, blk_t ref_block, int ref_offset, void *priv_data); - + /* * Given a bad blocks bitmap, update the bad blocks inode to reflect * the map. @@ -59,12 +59,12 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) errcode_t retval; struct set_badblock_record rec; struct ext2_inode inode; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!fs->block_map) return EXT2_ET_NO_BLOCK_BITMAP; - + rec.bad_block_count = 0; rec.ind_blocks_size = rec.ind_blocks_ptr = 0; rec.max_ind_blocks = 10; @@ -78,9 +78,9 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) goto cleanup; memset(rec.block_buf, 0, fs->blocksize); rec.err = 0; - + /* - * First clear the old bad blocks (while saving the indirect blocks) + * First clear the old bad blocks (while saving the indirect blocks) */ retval = ext2fs_block_iterate2(fs, EXT2_BAD_INO, BLOCK_FLAG_DEPTH_TRAVERSE, 0, @@ -91,7 +91,7 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) retval = rec.err; goto cleanup; } - + /* * Now set the bad blocks! * @@ -108,22 +108,22 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) BLOCK_FLAG_APPEND, 0, set_bad_block_proc, &rec); ext2fs_badblocks_list_iterate_end(rec.bb_iter); - if (retval) + if (retval) goto cleanup; if (rec.err) { retval = rec.err; goto cleanup; } } - + /* * Update the bad block inode's mod time and block count - * field. + * field. */ retval = ext2fs_read_inode(fs, EXT2_BAD_INO, &inode); if (retval) goto cleanup; - + inode.i_atime = inode.i_mtime = fs->now ? fs->now : time(0); if (!inode.i_ctime) inode.i_ctime = fs->now ? fs->now : time(0); @@ -133,7 +133,7 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) retval = ext2fs_write_inode(fs, EXT2_BAD_INO, &inode); if (retval) goto cleanup; - + cleanup: ext2fs_free_mem(&rec.ind_blocks); ext2fs_free_mem(&rec.block_buf); @@ -176,7 +176,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, if (rec->ind_blocks_size >= rec->max_ind_blocks) { old_size = rec->max_ind_blocks * sizeof(blk_t); rec->max_ind_blocks += 10; - retval = ext2fs_resize_mem(old_size, + retval = ext2fs_resize_mem(old_size, rec->max_ind_blocks * sizeof(blk_t), &rec->ind_blocks); if (retval) { @@ -192,12 +192,12 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, * Mark the block as unused, and update accounting information */ ext2fs_block_alloc_stats(fs, *block_nr, -1); - + *block_nr = 0; return BLOCK_CHANGED; } - + /* * Helper function for update_bb_inode() * @@ -250,12 +250,12 @@ static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr, return BLOCK_ABORT; } } - + /* * Update block counts */ ext2fs_block_alloc_stats(fs, blk, +1); - + *block_nr = blk; return BLOCK_CHANGED; } diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c index b033fa36..ea08b3e2 100644 --- a/lib/ext2fs/bitmaps.c +++ b/lib/ext2fs/bitmaps.c @@ -46,7 +46,7 @@ errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src, void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map) { ext2fs_set_generic_bitmap_padding(map); -} +} errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, const char *descr, @@ -79,9 +79,9 @@ errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, start = fs->super->s_first_data_block; end = fs->super->s_blocks_count-1; - real_end = (EXT2_BLOCKS_PER_GROUP(fs->super) + real_end = (EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count)-1 + start; - + return (ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_BLOCK_BITMAP, fs, start, end, real_end, descr, 0, ret)); @@ -168,7 +168,7 @@ errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap, blk_t start, unsigned int num, void *in) { - return (ext2fs_set_generic_bitmap_range(bmap, + return (ext2fs_set_generic_bitmap_range(bmap, EXT2_ET_MAGIC_BLOCK_BITMAP, start, num, in)); } diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c index 9c348474..485e997b 100644 --- a/lib/ext2fs/bitops.c +++ b/lib/ext2fs/bitops.c @@ -1,7 +1,7 @@ /* * bitops.c --- Bitmap frobbing code. See bitops.h for the inlined * routines. - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h index 391b8cdb..82ca138f 100644 --- a/lib/ext2fs/bitops.h +++ b/lib/ext2fs/bitops.h @@ -1,14 +1,14 @@ /* * bitops.h --- Bitmap frobbing code. The byte swapping routines are * also included here. - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * i386 bitops operations taken from <asm/bitops.h>, Copyright 1992, * Linus Torvalds. */ @@ -118,7 +118,7 @@ extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap); /* * The inline routines themselves... - * + * * If NO_INLINE_FUNCS is defined, then we won't try to do inline * functions at all; they will be included as normal functions in * inline.c @@ -185,7 +185,7 @@ _INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr) */ struct __dummy_h { unsigned long a[100]; }; #define EXT2FS_ADDR (*(struct __dummy_h *) addr) -#define EXT2FS_CONST_ADDR (*(const struct __dummy_h *) addr) +#define EXT2FS_CONST_ADDR (*(const struct __dummy_h *) addr) _INLINE_ int ext2fs_set_bit(unsigned int nr, void * addr) { @@ -230,7 +230,7 @@ _INLINE_ int ext2fs_find_first_bit_set(void * addr, unsigned size) return 0; /* This looks at memory. Mark it volatile to tell gcc not to move it around */ __asm__ __volatile__( - "cld\n\t" + "cld\n\t" "xorl %%eax,%%eax\n\t" "xorl %%edx,%%edx\n\t" "repe; scasl\n\t" @@ -250,7 +250,7 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset) { unsigned long * p = ((unsigned long *) addr) + (offset >> 5); int set = 0, bit = offset & 31, res; - + if (bit) { /* * Look for zero in first byte @@ -376,7 +376,7 @@ _INLINE_ int ext2fs_find_first_bit_set(void * addr, unsigned size) d0 = ffs(*cp); if (d0 == 0) return size; - + return res + d0 - 1; } @@ -384,10 +384,10 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset) { unsigned char * p; int set = 0, bit = offset & 7, res = 0, d0; - + res = offset >> 3; p = ((unsigned char *) addr) + res; - + if (bit) { set = ffs(*p & ~((1 << bit) - 1)); if (set) @@ -405,7 +405,7 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset) return (res + d0 - 1); } -#endif +#endif _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) @@ -417,35 +417,35 @@ _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, _INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) { - return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); } _INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); } _INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } _INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } _INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } @@ -464,7 +464,7 @@ _INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap, _INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); } @@ -483,7 +483,7 @@ _INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, _INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c index 71fec23a..b19c450d 100644 --- a/lib/ext2fs/block.c +++ b/lib/ext2fs/block.c @@ -1,6 +1,6 @@ /* * block.c --- iterate over all blocks in an inode - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -80,7 +80,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - ctx->errcode = ext2fs_read_ind_block(ctx->fs, *ind_block, + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *ind_block, ctx->ind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; @@ -92,7 +92,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, if (ctx->flags & BLOCK_FLAG_APPEND) { for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) { flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount, - *ind_block, offset, + *ind_block, offset, ctx->priv_data); changed |= flags; if (flags & BLOCK_ABORT) { @@ -106,7 +106,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, if (*block_nr == 0) continue; flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount, - *ind_block, offset, + *ind_block, offset, ctx->priv_data); changed |= flags; if (flags & BLOCK_ABORT) { @@ -132,7 +132,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, check_for_ro_violation_return(ctx, ret); return ret; } - + static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, int ref_offset, struct block_context *ctx) { @@ -157,7 +157,7 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - ctx->errcode = ext2fs_read_ind_block(ctx->fs, *dind_block, + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *dind_block, ctx->dind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; @@ -211,7 +211,7 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, check_for_ro_violation_return(ctx, ret); return ret; } - + static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, int ref_offset, struct block_context *ctx) { @@ -236,7 +236,7 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - ctx->errcode = ext2fs_read_ind_block(ctx->fs, *tind_block, + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *tind_block, ctx->tind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; @@ -290,7 +290,7 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, check_for_ro_violation_return(ctx, ret); return ret; } - + errcode_t ext2fs_block_iterate2(ext2_filsys fs, ext2_ino_t ino, int flags, @@ -357,7 +357,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs, check_for_ro_violation_goto(&ctx, ret, abort_exit); } } - + if (inode.i_flags & EXT4_EXTENTS_FL) { ext2_extent_handle_t handle; struct ext2fs_extent extent; @@ -385,7 +385,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs, check_for_ro_violation_goto(&ctx, ret, extent_errout); if (r & BLOCK_CHANGED) { - ctx.errcode = + ctx.errcode = ext2fs_extent_set_bmap(handle, (blk64_t) blockcnt++, (blk64_t) blk, 0); @@ -529,7 +529,7 @@ errcode_t ext2fs_block_iterate(ext2_filsys fs, void *priv_data) { struct xlate xl; - + xl.real_private = priv_data; xl.func = func; diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c index be7ccbc9..4edf425e 100644 --- a/lib/ext2fs/bmap.c +++ b/lib/ext2fs/bmap.c @@ -26,14 +26,14 @@ #endif extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode *inode, + struct ext2_inode *inode, char *block_buf, int bmap_flags, blk_t block, blk_t *phys_blk); #define inode_bmap(inode, nr) ((inode)->i_block[(nr)]) -static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, - blk_t ind, char *block_buf, +static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, + blk_t ind, char *block_buf, int *blocks_alloc, blk_t nr, blk_t *ret_blk) { @@ -90,17 +90,17 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, } static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags, - blk_t dind, char *block_buf, + blk_t dind, char *block_buf, int *blocks_alloc, blk_t nr, blk_t *ret_blk) { blk_t b; errcode_t retval; blk_t addr_per_block; - + addr_per_block = (blk_t) fs->blocksize >> 2; - retval = block_ind_bmap(fs, flags & ~BMAP_SET, dind, block_buf, + retval = block_ind_bmap(fs, flags & ~BMAP_SET, dind, block_buf, blocks_alloc, nr / addr_per_block, &b); if (retval) return retval; @@ -110,17 +110,17 @@ static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags, } static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags, - blk_t tind, char *block_buf, + blk_t tind, char *block_buf, int *blocks_alloc, blk_t nr, blk_t *ret_blk) { blk_t b; errcode_t retval; blk_t addr_per_block; - + addr_per_block = (blk_t) fs->blocksize >> 2; - retval = block_dind_bmap(fs, flags & ~BMAP_SET, tind, block_buf, + retval = block_dind_bmap(fs, flags & ~BMAP_SET, tind, block_buf, blocks_alloc, nr / addr_per_block, &b); if (retval) return retval; @@ -224,7 +224,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, *phys_blk = inode_bmap(inode, block); b = block ? inode_bmap(inode, block-1) : 0; - + if ((*phys_blk == 0) && (bmap_flags & BMAP_ALLOC)) { retval = ext2fs_alloc_block(fs, b, block_buf, &b); if (retval) @@ -235,7 +235,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, } goto done; } - + /* Indirect block */ block -= EXT2_NDIR_BLOCKS; blk32 = *phys_blk; @@ -255,13 +255,13 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, inode_bmap(inode, EXT2_IND_BLOCK) = b; blocks_alloc++; } - retval = block_ind_bmap(fs, bmap_flags, b, block_buf, + retval = block_ind_bmap(fs, bmap_flags, b, block_buf, &blocks_alloc, block, &blk32); if (retval == 0) *phys_blk = blk32; goto done; } - + /* Doubly indirect block */ block -= addr_per_block; if (block < addr_per_block * addr_per_block) { @@ -280,7 +280,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, inode_bmap(inode, EXT2_DIND_BLOCK) = b; blocks_alloc++; } - retval = block_dind_bmap(fs, bmap_flags, b, block_buf, + retval = block_dind_bmap(fs, bmap_flags, b, block_buf, &blocks_alloc, block, &blk32); if (retval == 0) *phys_blk = blk32; @@ -304,7 +304,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, inode_bmap(inode, EXT2_TIND_BLOCK) = b; blocks_alloc++; } - retval = block_tind_bmap(fs, bmap_flags, b, block_buf, + retval = block_tind_bmap(fs, bmap_flags, b, block_buf, &blocks_alloc, block, &blk32); if (retval == 0) *phys_blk = blk32; diff --git a/lib/ext2fs/bmove.c b/lib/ext2fs/bmove.c index 7d4b21af..019db91c 100644 --- a/lib/ext2fs/bmove.c +++ b/lib/ext2fs/bmove.c @@ -44,7 +44,7 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, pb = (struct process_block_struct *) priv_data; block = orig = *block_nr; ret = 0; - + /* * Let's see if this is one which we need to relocate */ @@ -98,7 +98,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, struct process_block_struct pb; ext2_inode_scan scan; char *block_buf; - + retval = ext2fs_open_inode_scan(fs, 0, &scan); if (retval) return retval; @@ -107,7 +107,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, pb.error = 0; pb.alloc_map = alloc_map ? alloc_map : fs->block_map; pb.flags = flags; - + retval = ext2fs_get_array(4, fs->blocksize, &block_buf); if (retval) return retval; @@ -131,12 +131,12 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, retval = ext2fs_get_next_inode(scan, &ino, &inode); if (retval) return retval; - + while (ino) { if ((inode.i_links_count == 0) || !ext2fs_inode_has_valid_blocks(&inode)) goto next; - + pb.ino = ino; pb.inode = &inode; diff --git a/lib/ext2fs/brel.h b/lib/ext2fs/brel.h index be97243c..a7f97765 100644 --- a/lib/ext2fs/brel.h +++ b/lib/ext2fs/brel.h @@ -1,6 +1,6 @@ /* * brel.h - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -47,7 +47,7 @@ struct ext2_block_relocation_table { * Initialize for iterating over the block relocation entries. */ errcode_t (*start_iter)(ext2_brel brel); - + /* * The iterator function for the inode relocation entries. * Returns an inode number of 0 when out of entries. diff --git a/lib/ext2fs/brel_ma.c b/lib/ext2fs/brel_ma.c index 3753e9fa..1c4f218d 100644 --- a/lib/ext2fs/brel_ma.c +++ b/lib/ext2fs/brel_ma.c @@ -1,6 +1,6 @@ /* * brel_ma.c - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * TODO: rewrite to not use a direct array!!! (Fortunately this @@ -61,18 +61,18 @@ errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block, if (retval) goto errout; memset(brel, 0, sizeof(struct ext2_block_relocation_table)); - + retval = ext2fs_get_mem(strlen(name)+1, &brel->name); if (retval) goto errout; strcpy(brel->name, name); - + retval = ext2fs_get_mem(sizeof(struct brel_ma), &ma); if (retval) goto errout; memset(ma, 0, sizeof(struct brel_ma)); brel->priv_data = ma; - + size = (size_t) (sizeof(struct ext2_block_relocate_entry) * (max_block+1)); retval = ext2fs_get_array(max_block+1, @@ -92,7 +92,7 @@ errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block, brel->move = bma_move; brel->delete = bma_delete; brel->free = bma_free; - + *new_brel = brel; return 0; diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c index c84589bf..299cb010 100644 --- a/lib/ext2fs/check_desc.c +++ b/lib/ext2fs/check_desc.c @@ -1,6 +1,6 @@ /* * check_desc.c --- Check the group descriptors of an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -53,7 +53,7 @@ errcode_t ext2fs_check_desc(ext2_filsys fs) EXT4_FEATURE_INCOMPAT_FLEX_BG)) { first_block = ext2fs_group_first_block(fs, i); last_block = ext2fs_group_last_block(fs, i); - if (i == (fs->group_desc_count - 1)) + if (i == (fs->group_desc_count - 1)) last_block = fs->super->s_blocks_count-1; } @@ -88,7 +88,7 @@ errcode_t ext2fs_check_desc(ext2_filsys fs) retval = EXT2_ET_GDESC_BAD_INODE_TABLE; goto errout; } - for (j = 0, b = blk; j < fs->inode_blocks_per_group; + for (j = 0, b = blk; j < fs->inode_blocks_per_group; j++, b++) { if (ext2fs_test_block_bitmap(bmap, b)) { retval = EXT2_ET_GDESC_BAD_INODE_TABLE; diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 206faa6c..baf8ce13 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -1,6 +1,6 @@ /* * closefs.c --- close an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -58,7 +58,7 @@ int ext2fs_bg_has_super(ext2_filsys fs, int group_block) * * See also the comment for ext2fs_reserve_super_and_bgd() */ -int ext2fs_super_and_bgd_loc(ext2_filsys fs, +int ext2fs_super_and_bgd_loc(ext2_filsys fs, dgrp_t group, blk_t *ret_super_blk, blk_t *ret_old_desc_blk, @@ -75,7 +75,7 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs, if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else - old_desc_blocks = + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; if (group == fs->group_desc_count-1) { @@ -112,7 +112,7 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs, numblocks--; } } - + numblocks -= 2 + fs->inode_blocks_per_group; if (ret_super_blk) @@ -200,7 +200,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group, struct ext2_super_block *super_shadow) { dgrp_t sgrp = group; - + if (sgrp > ((1 << 16) - 1)) sgrp = (1 << 16) - 1; #ifdef WORDS_BIGENDIAN @@ -209,7 +209,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group, fs->super->s_block_group_nr = sgrp; #endif - return io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE, + return io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE, super_shadow); } @@ -228,7 +228,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) #endif char *group_ptr; int old_desc_blocks; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); fs_state = fs->super->s_state; @@ -241,13 +241,13 @@ errcode_t ext2fs_flush(ext2_filsys fs) retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow); if (retval) goto errout; - retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, + retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, &group_shadow); if (retval) goto errout; memset(group_shadow, 0, (size_t) fs->blocksize * fs->desc_blocks); - + /* swap the group descriptors */ for (j=0, s=fs->group_desc, t=group_shadow; j < fs->group_desc_count; j++, t++, s++) { @@ -258,7 +258,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) super_shadow = fs->super; group_shadow = fs->group_desc; #endif - + /* * Set the state of the FS to be non-valid. (The state has * already been backed up earlier, and will be restored after @@ -293,7 +293,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) blk_t super_blk, old_desc_blk, new_desc_blk; int meta_bg; - ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk, + ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk, &new_desc_blk, &meta_bg); if (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) &&i && super_blk) { @@ -304,7 +304,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) } if (fs->flags & EXT2_FLAG_SUPER_ONLY) continue; - if ((old_desc_blk) && + if ((old_desc_blk) && (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) || (i == 0))) { retval = io_channel_write_blk(fs->io, old_desc_blk, old_desc_blocks, group_ptr); @@ -370,7 +370,7 @@ errout: errcode_t ext2fs_close(ext2_filsys fs) { errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (fs->flags & EXT2_FLAG_DIRTY) { diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c index 257d7133..459c3c08 100644 --- a/lib/ext2fs/csum.c +++ b/lib/ext2fs/csum.c @@ -63,7 +63,7 @@ int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group) { if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && - (fs->group_desc[group].bg_checksum != + (fs->group_desc[group].bg_checksum != ext2fs_group_desc_csum(fs, group))) return 0; diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c index 188e36e3..4a80367c 100644 --- a/lib/ext2fs/dblist.c +++ b/lib/ext2fs/dblist.c @@ -1,13 +1,13 @@ /* * dblist.c -- directory block list functions - * + * * Copyright 1997 by Theodore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -33,7 +33,7 @@ errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs) ext2_ino_t num_dirs, max_dirs; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); - + num_dirs = 0; max_dirs = fs->super->s_inodes_per_group; for (i = 0; i < fs->group_desc_count; i++) { @@ -89,7 +89,7 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size, ext2_ino_t count, &dblist->list); if (retval) goto cleanup; - + if (list) memcpy(dblist->list, list, len); else @@ -159,7 +159,7 @@ errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, struct ext2_db_entry *new_entry; errcode_t retval; unsigned long old_size; - + EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); if (dblist->count >= dblist->size) { @@ -190,7 +190,7 @@ errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, int blockcnt) { dgrp_t i; - + EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); for (i=0; i < dblist->count; i++) { @@ -226,7 +226,7 @@ errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, { ext2_ino_t i; int ret; - + EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); if (!dblist->sorted) @@ -248,7 +248,7 @@ static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b) if (db_a->blk != db_b->blk) return (int) (db_a->blk - db_b->blk); - + if (db_a->ino != db_b->ino) return (int) (db_a->ino - db_b->ino); @@ -260,7 +260,7 @@ int ext2fs_dblist_count(ext2_dblist dblist) return (int) dblist->count; } -errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, +errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, struct ext2_db_entry **entry) { EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); @@ -274,7 +274,7 @@ errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, } errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist) -{ +{ EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); if (dblist->count == 0) diff --git a/lib/ext2fs/dblist_dir.c b/lib/ext2fs/dblist_dir.c index 28a04c74..6f370cd3 100644 --- a/lib/ext2fs/dblist_dir.c +++ b/lib/ext2fs/dblist_dir.c @@ -2,12 +2,12 @@ * dblist_dir.c --- iterate by directory entry * * Copyright 1997 by Theodore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -54,7 +54,7 @@ errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist, ctx.errcode = 0; retval = ext2fs_dblist_iterate(dblist, db_dir_proc, &ctx); - + if (!block_buf) ext2fs_free_mem(&ctx.buf); if (retval) @@ -71,7 +71,7 @@ static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info, ctx = (struct dir_context *) priv_data; ctx->dir = db_info->ino; ctx->errcode = 0; - + ret = ext2fs_process_dir_block(fs, &db_info->blk, db_info->blockcnt, 0, 0, priv_data); if ((ret & BLOCK_ABORT) && !ctx->errcode) diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c index 6bb536b0..1f8cf8ff 100644 --- a/lib/ext2fs/dir_iterate.c +++ b/lib/ext2fs/dir_iterate.c @@ -1,6 +1,6 @@ /* * dir_iterate.c --- ext2fs directory iteration operations - * + * * Copyright (C) 1993, 1994, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -34,7 +34,7 @@ static int ext2fs_validate_entry(ext2_filsys fs, char *buf, int offset, { struct ext2_dir_entry *dirent; int rec_len; - + while (offset < final_offset) { dirent = (struct ext2_dir_entry *)(buf + offset); rec_len = (dirent->rec_len || fs->blocksize < 65536) ? @@ -63,13 +63,13 @@ errcode_t ext2fs_dir_iterate2(ext2_filsys fs, { struct dir_context ctx; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_check_directory(fs, dir); if (retval) return retval; - + ctx.dir = dir; ctx.flags = flags; if (block_buf) @@ -110,7 +110,7 @@ static int xlate_func(ext2_ino_t dir EXT2FS_ATTR((unused)), return (*xl->func)(dirent, offset, blocksize, buf, xl->real_private); } -extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, +extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, ext2_ino_t dir, int flags, char *block_buf, @@ -122,7 +122,7 @@ extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, void *priv_data) { struct xlate xl; - + xl.real_private = priv_data; xl.func = func; @@ -155,7 +155,7 @@ int ext2fs_process_dir_block(ext2_filsys fs, return 0; entry = blockcnt ? DIRENT_OTHER_FILE : DIRENT_DOT_FILE; - + ctx->errcode = ext2fs_read_dir_block(fs, *blocknr, ctx->buf); if (ctx->errcode) return BLOCK_ABORT; @@ -183,7 +183,7 @@ int ext2fs_process_dir_block(ext2_filsys fs, ctx->priv_data); if (entry < DIRENT_OTHER_FILE) entry++; - + if (ret & DIRENT_CHANGED) { rec_len = (dirent->rec_len || fs->blocksize < 65536) ? dirent->rec_len : 65536; @@ -193,10 +193,10 @@ int ext2fs_process_dir_block(ext2_filsys fs, do_abort++; break; } -next: +next: if (next_real_entry == offset) next_real_entry += rec_len; - + if (ctx->flags & DIRENT_FLAG_INCLUDE_REMOVED) { size = ((dirent->name_len & 0xFF) + 11) & ~3; diff --git a/lib/ext2fs/dirblock.c b/lib/ext2fs/dirblock.c index c61e001c..501c6560 100644 --- a/lib/ext2fs/dirblock.c +++ b/lib/ext2fs/dirblock.c @@ -1,6 +1,6 @@ /* * dirblock.c --- directory block routines. - * + * * Copyright (C) 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -26,7 +26,7 @@ errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block, char *p, *end; struct ext2_dir_entry *dirent; unsigned int name_len, rec_len; - + retval = io_channel_read_blk(fs->io, block, 1, buf); if (retval) diff --git a/lib/ext2fs/dirhash.c b/lib/ext2fs/dirhash.c index 9fd20160..c42ccd95 100644 --- a/lib/ext2fs/dirhash.c +++ b/lib/ext2fs/dirhash.c @@ -2,7 +2,7 @@ * dirhash.c -- Calculate the hash of a directory entry * * Copyright (c) 2001 Daniel Phillips - * + * * Copyright (c) 2002 Theodore Ts'o. * * %Begin-Header% @@ -25,7 +25,7 @@ * (see Applied Cryptography, 2nd edition, p448). * * Jeremy Fitzhardinge <jeremy@zip.com.au> 1998 - * + * * This code is made available under the terms of the GPL */ #define DELTA 0x9E3779B9 @@ -37,10 +37,10 @@ static void TEA_transform(__u32 buf[4], __u32 const in[]) __u32 a = in[0], b = in[1], c = in[2], d = in[3]; int n = 16; - do { - sum += DELTA; - b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); - b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); + do { + sum += DELTA; + b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); + b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); } while(--n); buf[0] += b0; @@ -130,7 +130,7 @@ static ext2_dirhash_t dx_hack_hash (const char *name, int len, else c = (int) *scp++; hash = hash1 + (hash0 ^ (c * 7152373)); - + if (hash & 0x80000000) hash -= 0x7fffffff; hash1 = hash0; hash0 = hash; @@ -177,11 +177,11 @@ static void str2hashbuf(const char *msg, int len, __u32 *buf, int num, * Returns the hash of a filename. If len is 0 and name is NULL, then * this function can be used to test whether or not a hash version is * supported. - * + * * The seed is an 4 longword (32 bits) "secret" which can be used to * uniquify a hash. If the seed is all zero's, then some default seed * may be used. - * + * * A particular hash version specifies whether or not the seed is * represented, and whether or not the returned hash is 32 bits or 64 * bits. 32 bit hashes will return 0 for the minor hash. @@ -213,7 +213,7 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len, if (i < 4) memcpy(buf, seed, sizeof(buf)); } - + switch (version) { case EXT2_HASH_LEGACY_UNSIGNED: unsigned_flag++; diff --git a/lib/ext2fs/dosio.c b/lib/ext2fs/dosio.c index d695b18e..d93cc6a3 100644 --- a/lib/ext2fs/dosio.c +++ b/lib/ext2fs/dosio.c @@ -2,7 +2,7 @@ * dosio.c -- Disk I/O module for the ext2fs/DOS library. * * Copyright (c) 1997 by Theodore Ts'o. - * + * * Copyright (c) 1997 Mark Habersack * This file may be distributed under the terms of the GNU Public License. * @@ -179,7 +179,7 @@ static errcode_t dos_open(const char *dev, int flags, io_channel *channel) PARTITION *part; PTABLE_ENTRY *pent; PARTITION **newparts; - + if(!dev) { _dio_error = ERR_BADDEV; diff --git a/lib/ext2fs/dupfs.c b/lib/ext2fs/dupfs.c index 1cf314ce..2f9bedcd 100644 --- a/lib/ext2fs/dupfs.c +++ b/lib/ext2fs/dupfs.c @@ -1,6 +1,6 @@ /* * dupfs.c --- duplicate a ext2 filesystem handle - * + * * Copyright (C) 1997, 1998, 2001, 2003, 2005 by Theodore Ts'o. * * %Begin-Header% @@ -25,7 +25,7 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) errcode_t retval; EXT2_CHECK_MAGIC(src, EXT2_ET_MAGIC_EXT2FS_FILSYS); - + retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); if (retval) return retval; @@ -91,6 +91,6 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) errout: ext2fs_free(fs); return retval; - + } diff --git a/lib/ext2fs/e2image.h b/lib/ext2fs/e2image.h index e12b7d69..c05d43e2 100644 --- a/lib/ext2fs/e2image.h +++ b/lib/ext2fs/e2image.h @@ -1,10 +1,10 @@ /* * e2image.h --- header file describing the ext2 image format - * + * * Copyright (C) 2000 Theodore Ts'o. * * Note: this uses the POSIX IO interfaces, unlike most of the other - * functions in this library. So sue me. + * functions in this library. So sue me. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public @@ -24,7 +24,7 @@ struct ext2_image_hdr { char fs_uuid[16]; /* UUID of filesystem */ __u32 fs_blocksize; /* Block size of the filesystem */ __u32 fs_reserved[8]; - + __u32 image_device; /* Device number of image file */ __u32 image_inode; /* Inode number of image file */ __u32 image_time; /* Time of image creation */ @@ -37,15 +37,15 @@ struct ext2_image_hdr { __u32 offset_reserved[8]; }; - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c index c124d3e1..934eaf12 100644 --- a/lib/ext2fs/expanddir.c +++ b/lib/ext2fs/expanddir.c @@ -1,6 +1,6 @@ /* * expand.c --- expand an ext2fs directory - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999 Theodore Ts'o. * * %Begin-Header% @@ -36,7 +36,7 @@ static int expand_dir_proc(ext2_filsys fs, static blk_t last_blk = 0; char *block; errcode_t retval; - + if (*blocknr) { last_blk = *blocknr; return 0; @@ -62,7 +62,7 @@ static int expand_dir_proc(ext2_filsys fs, } memset(block, 0, fs->blocksize); retval = io_channel_write_blk(fs->io, new_blk, 1, block); - } + } if (retval) { es->err = retval; return BLOCK_ABORT; @@ -83,7 +83,7 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir) errcode_t retval; struct expand_dir_struct es; struct ext2_inode inode; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!(fs->flags & EXT2_FLAG_RW)) @@ -95,11 +95,11 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir) retval = ext2fs_check_directory(fs, dir); if (retval) return retval; - + es.done = 0; es.err = 0; es.newblocks = 0; - + retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND, 0, expand_dir_proc, &es); @@ -114,7 +114,7 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir) retval = ext2fs_read_inode(fs, dir, &inode); if (retval) return retval; - + inode.i_size += fs->blocksize; ext2fs_iblk_add_blocks(fs, &inode, es.newblocks); diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 554c708b..d7d7bdb1 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -666,7 +666,7 @@ struct ext2_super_block { #define EXT2_DEFM_XATTR_USER 0x0004 #define EXT2_DEFM_ACL 0x0008 #define EXT2_DEFM_UID16 0x0010 -#define EXT3_DEFM_JMODE 0x0060 +#define EXT3_DEFM_JMODE 0x0060 #define EXT3_DEFM_JMODE_DATA 0x0020 #define EXT3_DEFM_JMODE_ORDERED 0x0040 #define EXT3_DEFM_JMODE_WBACK 0x0060 diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h index dce21386..2a579e6b 100644 --- a/lib/ext2fs/ext2_io.h +++ b/lib/ext2fs/ext2_io.h @@ -1,6 +1,6 @@ /* * io.h --- the I/O manager abstraction - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -76,7 +76,7 @@ struct struct_io_manager { errcode_t (*flush)(io_channel channel); errcode_t (*write_byte)(io_channel channel, unsigned long offset, int count, const void *data); - errcode_t (*set_option)(io_channel channel, const char *option, + errcode_t (*set_option)(io_channel channel, const char *option, const char *arg); errcode_t (*get_stats)(io_channel channel, io_stats *io_stats); errcode_t (*read_blk64)(io_channel channel, unsigned long long block, @@ -98,11 +98,11 @@ struct struct_io_manager { #define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d)) #define io_channel_flush(c) ((c)->manager->flush((c))) #define io_channel_bumpcount(c) ((c)->refcount++) - + /* io_manager.c */ -extern errcode_t io_channel_set_options(io_channel channel, +extern errcode_t io_channel_set_options(io_channel channel, const char *options); -extern errcode_t io_channel_write_byte(io_channel channel, +extern errcode_t io_channel_write_byte(io_channel channel, unsigned long offset, int count, const void *data); extern errcode_t io_channel_read_blk64(io_channel channel, @@ -130,4 +130,4 @@ extern void (*test_io_cb_set_blksize) (int blksize, errcode_t err); #endif /* _EXT2FS_EXT2_IO_H */ - + diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 04a95a26..e02a55f6 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1,6 +1,6 @@ /* * ext2fs.h --- ext2fs - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -259,7 +259,7 @@ struct struct_ext2_filsys { * This is used by ext2fs_expand_dir() to be able to add a new block * to an inode. It can also be used for programs that want to be able * to deal with files that contain "holes". - * + * * BLOCK_FLAG_DEPTH_TRAVERSE indicates that the iterator function for * the indirect, doubly indirect, etc. blocks should be called after * all of the blocks containined in the indirect blocks are processed. @@ -269,7 +269,7 @@ struct struct_ext2_filsys { * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be * called for data blocks only. * - * BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not + * BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not * modify returned block number. * * BLOCK_FLAG_NO_LARGE is for internal use only. It informs @@ -295,7 +295,7 @@ struct struct_ext2_filsys { /* * Flags for ext2fs_move_blocks */ -#define EXT2_BMOVE_GET_DBLIST 0x0001 +#define EXT2_BMOVE_GET_DBLIST 0x0001 #define EXT2_BMOVE_DEBUG 0x0002 #endif @@ -560,7 +560,7 @@ extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t *ret); extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, char *block_buf, blk_t *ret); -extern void ext2fs_set_alloc_block_callback(ext2_filsys fs, +extern void ext2fs_set_alloc_block_callback(ext2_filsys fs, errcode_t (*func)(ext2_filsys fs, blk64_t goal, blk64_t *ret), @@ -569,10 +569,10 @@ extern void ext2fs_set_alloc_block_callback(ext2_filsys fs, blk64_t *ret)); /* alloc_sb.c */ -extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs, +extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs, dgrp_t group, ext2fs_block_bitmap bmap); -extern void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, +extern void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, void (*func)(ext2_filsys fs, blk64_t blk, int inuse), @@ -706,10 +706,10 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs, /* bmap.c */ extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode *inode, + struct ext2_inode *inode, char *block_buf, int bmap_flags, blk_t block, blk_t *phys_blk); -extern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, +extern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, char *block_buf, int bmap_flags, blk64_t block, int *ret_flags, blk64_t *phys_blk); @@ -729,7 +729,7 @@ extern errcode_t ext2fs_check_desc(ext2_filsys fs); extern errcode_t ext2fs_close(ext2_filsys fs); extern errcode_t ext2fs_flush(ext2_filsys fs); extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block); -extern int ext2fs_super_and_bgd_loc(ext2_filsys fs, +extern int ext2fs_super_and_bgd_loc(ext2_filsys fs, dgrp_t group, blk_t *ret_super_blk, blk_t *ret_old_desc_blk, @@ -760,7 +760,7 @@ extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, extern errcode_t ext2fs_copy_dblist(ext2_dblist src, ext2_dblist *dest); extern int ext2fs_dblist_count(ext2_dblist dblist); -extern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, +extern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, struct ext2_db_entry **entry); extern errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist); @@ -796,7 +796,7 @@ extern errcode_t ext2fs_dirhash(int version, const char *name, int len, /* dir_iterate.c */ -extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, +extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, ext2_ino_t dir, int flags, char *block_buf, @@ -806,7 +806,7 @@ extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, char *buf, void *priv_data), void *priv_data); -extern errcode_t ext2fs_dir_iterate2(ext2_filsys fs, +extern errcode_t ext2fs_dir_iterate2(ext2_filsys fs, ext2_ino_t dir, int flags, char *block_buf, @@ -890,8 +890,8 @@ extern void ext2fs_u32_list_free(ext2_u32_list bb); /* gen_bitmap.c */ extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap); -extern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, - __u32 start, __u32 end, +extern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, + __u32 start, __u32 end, __u32 real_end, const char *descr, char *init_map, ext2fs_generic_bitmap *ret); @@ -904,9 +904,9 @@ extern errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, ext2fs_generic_bitmap *dest); extern void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap); extern errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap, - errcode_t magic, + errcode_t magic, errcode_t neq, - ext2_ino_t end, + ext2_ino_t end, ext2_ino_t *oend); extern void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map); extern errcode_t ext2fs_resize_generic_bitmap(errcode_t magic, @@ -960,10 +960,10 @@ extern errcode_t ext2fs_initialize(const char *name, int flags, extern void ext2fs_free_icount(ext2_icount_t icount); extern errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir, int flags, ext2_icount_t *ret); -extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, +extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, unsigned int size, ext2_icount_t hint, ext2_icount_t *ret); -extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, +extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, unsigned int size, ext2_icount_t *ret); extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, @@ -979,9 +979,9 @@ errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *); /* inode.c */ extern errcode_t ext2fs_flush_icache(ext2_filsys fs); -extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, +extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, - struct ext2_inode *inode, + struct ext2_inode *inode, int bufsize); extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, ext2_inode_scan *ret_scan); @@ -1000,12 +1000,12 @@ extern void ext2fs_set_inode_callback extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags, int clear_flags); extern errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode * inode, + struct ext2_inode * inode, int bufsize); extern errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode); extern errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode * inode, + struct ext2_inode * inode, int bufsize); extern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode); @@ -1016,12 +1016,12 @@ extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino); /* inode_io.c */ extern io_manager inode_io_manager; -extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino, +extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino, char **name); extern errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, char **name); - + /* ismounted.c */ extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags); extern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, @@ -1064,11 +1064,11 @@ extern int ext2fs_default_journal_size(__u64 blocks); extern errcode_t ext2fs_open(const char *name, int flags, int superblock, unsigned int block_size, io_manager manager, ext2_filsys *ret_fs); -extern errcode_t ext2fs_open2(const char *name, const char *io_options, - int flags, int superblock, +extern errcode_t ext2fs_open2(const char *name, const char *io_options, + int flags, int superblock, unsigned int block_size, io_manager manager, ext2_filsys *ret_fs); -extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, +extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i); errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io); errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io); @@ -1089,14 +1089,14 @@ extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs, ext2_badblocks_list *bb_list); /* read_bb_file.c */ -extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, +extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void *priv_data, void (*invalid)(ext2_filsys fs, blk_t blk, char *badstr, void *priv_data)); -extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, +extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void (*invalid)(ext2_filsys fs, blk_t blk)); @@ -1105,7 +1105,7 @@ extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, extern errcode_t ext2fs_create_resize_inode(ext2_filsys fs); /* swapfs.c */ -extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, +extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, int has_header); extern void ext2fs_swap_ext_attr_header(struct ext2_ext_attr_header *to_header, struct ext2_ext_attr_header *from_hdr); @@ -1210,7 +1210,7 @@ _INLINE_ errcode_t ext2fs_free_mem(void *ptr) memcpy(ptr, &p, sizeof(p)); return 0; } - + /* * Resize memory */ diff --git a/lib/ext2fs/ext2fsP.h b/lib/ext2fs/ext2fsP.h index eea32d63..c666faaf 100644 --- a/lib/ext2fs/ext2fsP.h +++ b/lib/ext2fs/ext2fsP.h @@ -1,6 +1,6 @@ /* * ext2fsP.h --- private header file for ext2 library - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 3d208ec7..9f5e10fb 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -1,6 +1,6 @@ /* * ext_attr.c --- extended attribute blocks - * + * * Copyright (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> * * Copyright (C) 2002 Theodore Ts'o. diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c index a2cf679f..929e5cdc 100644 --- a/lib/ext2fs/extent.c +++ b/lib/ext2fs/extent.c @@ -147,7 +147,7 @@ errcode_t ext2fs_extent_header_verify(void *ptr, int size) eh_max = (size - sizeof(*eh)) / entry_size; /* Allow two extent-sized items at the end of the block, for * ext4_extent_tail with checksum in the future. */ - if ((ext2fs_le16_to_cpu(eh->eh_max) > eh_max) || + if ((ext2fs_le16_to_cpu(eh->eh_max) > eh_max) || (ext2fs_le16_to_cpu(eh->eh_max) < (eh_max - 2))) return EXT2_ET_EXTENT_HEADER_BAD; @@ -731,7 +731,7 @@ done: return retval; } -errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, +errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags EXT2FS_ATTR((unused)), struct ext2fs_extent *extent) { @@ -1426,7 +1426,7 @@ int common_extent_args_process(int argc, char *argv[], int min_argc, if (common_args_process(argc, argv, min_argc, max_argc, cmd, usage, flags)) return 1; - + if (!current_handle) { com_err(cmd, 0, "Extent handle not open"); return 1; diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c index 8bf99fb9..70325a8f 100644 --- a/lib/ext2fs/fileio.c +++ b/lib/ext2fs/fileio.c @@ -1,6 +1,6 @@ /* * fileio.c --- Simple file I/O routines - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% @@ -50,7 +50,7 @@ errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino, retval = ext2fs_get_mem(sizeof(struct ext2_file), &file); if (retval) return retval; - + memset(file, 0, sizeof(struct ext2_file)); file->magic = EXT2_ET_MAGIC_EXT2_FILE; file->fs = fs; @@ -64,14 +64,14 @@ errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino, if (retval) goto fail; } - + retval = ext2fs_get_array(3, fs->blocksize, &file->buf); if (retval) goto fail; *ret = file; return 0; - + fail: if (file->buf) ext2fs_free_mem(&file->buf); @@ -103,7 +103,7 @@ errcode_t ext2fs_file_flush(ext2_file_t file) { errcode_t retval; ext2_filsys fs; - + EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE); fs = file->fs; @@ -176,7 +176,7 @@ static errcode_t load_buffer(ext2_file_t file, int dontfill) if (!dontfill) { if (file->physblock) { retval = io_channel_read_blk(fs->io, - file->physblock, + file->physblock, 1, file->buf); if (retval) return retval; @@ -187,16 +187,16 @@ static errcode_t load_buffer(ext2_file_t file, int dontfill) } return 0; } - + errcode_t ext2fs_file_close(ext2_file_t file) { errcode_t retval; - + EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE); retval = ext2fs_file_flush(file); - + if (file->buf) ext2fs_free_mem(&file->buf); ext2fs_free_mem(&file); @@ -232,14 +232,14 @@ errcode_t ext2fs_file_read(ext2_file_t file, void *buf, left = EXT2_I_SIZE(&file->inode) - file->pos ; if (c > left) c = left; - + memcpy(ptr, file->buf+start, c); file->pos += c; ptr += c; count += c; wanted -= c; } - + fail: if (got) *got = count; @@ -265,7 +265,7 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf, retval = sync_buffer_position(file); if (retval) goto fail; - + start = file->pos % fs->blocksize; c = fs->blocksize - start; if (c > nbytes) @@ -286,7 +286,7 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf, count += c; nbytes -= c; } - + fail: if (written) *written = count; @@ -318,7 +318,7 @@ errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset, { __u64 loffset, ret_loffset; errcode_t retval; - + loffset = offset; retval = ext2fs_file_llseek(file, loffset, whence, &ret_loffset); if (ret_pos) @@ -354,14 +354,14 @@ ext2_off_t ext2fs_file_get_size(ext2_file_t file) /* * This function sets the size of the file, truncating it if necessary - * + * * XXX still need to call truncate */ errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size) { errcode_t retval; EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE); - + file->inode.i_size = size; file->inode.i_size_high = 0; if (file->ino) { @@ -370,7 +370,7 @@ errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size) return retval; } - /* + /* * XXX truncate inode if necessary */ diff --git a/lib/ext2fs/finddev.c b/lib/ext2fs/finddev.c index 2e9d70a4..56b76dfc 100644 --- a/lib/ext2fs/finddev.c +++ b/lib/ext2fs/finddev.c @@ -1,7 +1,7 @@ /* * finddev.c -- this routine attempts to find a particular device in * /dev - * + * * Copyright (C) 2000 Theodore Ts'o. * * %Begin-Header% @@ -134,7 +134,7 @@ char *ext2fs_find_block_device(dev_t device) add_to_dirlist("/devices", &list); add_to_dirlist("/devfs", &list); add_to_dirlist("/dev", &list); - + while (list) { current = list; list = list->next; @@ -160,7 +160,7 @@ char *ext2fs_find_block_device(dev_t device) return ret_path; } - + #ifdef DEBUG int main(int argc, char** argv) { @@ -204,5 +204,5 @@ int main(int argc, char** argv) } return 0; } - + #endif diff --git a/lib/ext2fs/flushb.c b/lib/ext2fs/flushb.c index 18827955..f0630ea1 100644 --- a/lib/ext2fs/flushb.c +++ b/lib/ext2fs/flushb.c @@ -1,7 +1,7 @@ /* * flushb.c --- Hides system-dependent information for both syncing a * device to disk and to flush any buffers from disk cache. - * + * * Copyright (C) 2000 Theodore Ts'o. * * %Begin-Header% @@ -29,7 +29,7 @@ #include "ext2fs.h" /* - * For Linux, define BLKFLSBUF and FDFLUSH if necessary, since + * For Linux, define BLKFLSBUF and FDFLUSH if necessary, since * not all portable header file does so for us. This really should be * fixed in the glibc header files. (Recent glibcs appear to define * BLKFLSBUF in sys/mount.h, but FDFLUSH still doesn't seem to be diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c index d6ac9011..2a1c9152 100644 --- a/lib/ext2fs/freefs.c +++ b/lib/ext2fs/freefs.c @@ -1,6 +1,6 @@ /* * freefs.c --- free an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -52,7 +52,7 @@ void ext2fs_free(ext2_filsys fs) if (fs->icache) ext2fs_free_inode_cache(fs->icache); - + fs->magic = 0; ext2fs_free_mem(&fs); diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c index 66172e5d..a1b1d8f4 100644 --- a/lib/ext2fs/gen_bitmap.c +++ b/lib/ext2fs/gen_bitmap.c @@ -1,6 +1,6 @@ /* * gen_bitmap.c --- Generic (32-bit) bitmap routines - * + * * Copyright (C) 2001 Theodore Ts'o. * * %Begin-Header% @@ -38,7 +38,7 @@ struct ext2fs_struct_generic_bitmap { __u32 reserved[7]; }; -/* +/* * Used by previously inlined function, so we have to export this and * not change the function signature */ @@ -63,7 +63,7 @@ static errcode_t check_magic(ext2fs_generic_bitmap bitmap) return 0; } -errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, +errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, __u32 start, __u32 end, __u32 real_end, const char *descr, char *init_map, ext2fs_generic_bitmap *ret) @@ -72,7 +72,7 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, errcode_t retval; size_t size; - retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap), + retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap), &bitmap); if (retval) return retval; @@ -124,7 +124,7 @@ errcode_t ext2fs_allocate_generic_bitmap(__u32 start, const char *descr, ext2fs_generic_bitmap *ret) { - return ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_GENERIC_BITMAP, 0, + return ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_GENERIC_BITMAP, 0, start, end, real_end, descr, 0, ret); } @@ -132,7 +132,7 @@ errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, ext2fs_generic_bitmap *dest) { return (ext2fs_make_generic_bitmap(src->magic, src->fs, - src->start, src->end, + src->start, src->end, src->real_end, src->description, src->bitmap, dest)); @@ -209,7 +209,7 @@ errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap, ext2_ino_t end, ext2_ino_t *oend) { EXT2_CHECK_MAGIC(bitmap, magic); - + if (end > bitmap->real_end) return neq; if (oend) @@ -244,7 +244,7 @@ errcode_t ext2fs_resize_generic_bitmap(errcode_t magic, bmap->end = new_end; return 0; } - + size = ((bmap->real_end - bmap->start) / 8) + 1; new_size = ((new_real_end - bmap->start) / 8) + 1; @@ -266,7 +266,7 @@ errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq, ext2fs_generic_bitmap bm2) { blk_t i; - + if (!bm1 || bm1->magic != magic) return magic; if (!bm2 || bm2->magic != magic) @@ -291,8 +291,8 @@ void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map) __u32 i, j; /* Protect loop from wrap-around if map->real_end is maxed */ - for (i=map->end+1, j = i - map->start; - i <= map->real_end && i > map->end; + for (i=map->end+1, j = i - map->start; + i <= map->real_end && i > map->end; i++, j++) ext2fs_set_bit(j, map->bitmap); } @@ -348,7 +348,7 @@ void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap, blk_t block, int num) { int i; - + if ((block < bitmap->start) || (block+num-1 > bitmap->end)) { ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block, bitmap->description); @@ -362,13 +362,13 @@ void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap, blk_t block, int num) { int i; - + if ((block < bitmap->start) || (block+num-1 > bitmap->end)) { ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block, bitmap->description); return; } for (i=0; i < num; i++) - ext2fs_fast_clear_bit(block + i - bitmap->start, + ext2fs_fast_clear_bit(block + i - bitmap->start, bitmap->bitmap); } diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c index 23f593f6..c46b3a0a 100644 --- a/lib/ext2fs/get_pathname.c +++ b/lib/ext2fs/get_pathname.c @@ -1,6 +1,6 @@ /* * get_pathname.c --- do directry/inode -> name translation - * + * * Copyright (C) 1993, 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -15,7 +15,7 @@ * directory inode, and <ino> is the inode number itself. If * <ino> is zero, then ext2fs_get_pathname will return pathname * of the the directory <dir>. - * + * */ #include <stdio.h> @@ -65,8 +65,8 @@ static int get_pathname_proc(struct ext2_dir_entry *dirent, return 0; } -static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, - ext2_ino_t ino, int maxdepth, +static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, + ext2_ino_t ino, int maxdepth, char *buf, char **name) { struct get_pathname_struct gp; @@ -93,7 +93,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, gp.parent = 0; gp.name = 0; gp.errcode = 0; - + retval = ext2fs_dir_iterate(fs, dir, 0, buf, get_pathname_proc, &gp); if (retval) goto cleanup; @@ -110,15 +110,15 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, *name = parent_name; return 0; } - - if (gp.name) + + if (gp.name) retval = ext2fs_get_mem(strlen(parent_name)+strlen(gp.name)+2, &ret); else retval = ext2fs_get_mem(strlen(parent_name)+5, &ret); if (retval) goto cleanup; - + ret[0] = 0; if (parent_name[1]) strcat(ret, parent_name); @@ -130,7 +130,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, *name = ret; ext2fs_free_mem(&parent_name); retval = 0; - + cleanup: if (gp.name) ext2fs_free_mem(&gp.name); @@ -153,5 +153,5 @@ errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino, retval = ext2fs_get_pathname_int(fs, dir, ino, 32, buf, name); ext2fs_free_mem(&buf); return retval; - + } diff --git a/lib/ext2fs/getsectsize.c b/lib/ext2fs/getsectsize.c index e749d396..ae9139d0 100644 --- a/lib/ext2fs/getsectsize.c +++ b/lib/ext2fs/getsectsize.c @@ -1,6 +1,6 @@ /* * getsectsize.c --- get the sector size of a device. - * + * * Copyright (C) 1995, 1995 Theodore Ts'o. * Copyright (C) 2003 VMware, Inc. * diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c index 7f6ef71b..b45e285c 100644 --- a/lib/ext2fs/getsize.c +++ b/lib/ext2fs/getsize.c @@ -1,11 +1,11 @@ /* * getsize.c --- get the size of a partition. - * + * * Copyright (C) 1995, 1995 Theodore Ts'o. * Copyright (C) 2003 VMware, Inc. * * Windows version of ext2fs_get_device_size by Chris Li, VMware. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -82,10 +82,10 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize, DWORD filesize; #endif /* HAVE_GET_FILE_SIZE_EX */ - dev = CreateFile(file, GENERIC_READ, + dev = CreateFile(file, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE , - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (dev == INVALID_HANDLE_VALUE) return EBADF; if (DeviceIoControl(dev, IOCTL_DISK_GET_PARTITION_INFO, @@ -94,7 +94,7 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize, &retbytes, NULL)) { *retblocks = pi.PartitionLength.QuadPart / blocksize; - + } else if (DeviceIoControl(dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, &gi, sizeof(DISK_GEOMETRY), &gi, sizeof(DISK_GEOMETRY), @@ -300,7 +300,7 @@ int main(int argc, char **argv) { blk_t blocks; int retval; - + if (argc < 2) { fprintf(stderr, "Usage: %s device\n", argv[0]); exit(1); diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c index 9f7534ab..01543338 100644 --- a/lib/ext2fs/imager.c +++ b/lib/ext2fs/imager.c @@ -5,7 +5,7 @@ * Copyright (C) 2000 Theodore Ts'o. * * Note: this uses the POSIX IO interfaces, unlike most of the other - * functions in this library. So sue me. + * functions in this library. So sue me. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public @@ -69,7 +69,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags) buf = malloc(fs->blocksize * BUF_BLOCKS); if (!buf) return ENOMEM; - + for (group = 0; group < fs->group_desc_count; group++) { blk = fs->group_desc[(unsigned)group].bg_inode_table; if (!blk) { @@ -131,7 +131,7 @@ errout: /* * Read in the inode table and stuff it into place */ -errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, +errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags EXT2FS_ATTR((unused))) { unsigned int group, c, left; @@ -143,7 +143,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, buf = malloc(fs->blocksize * BUF_BLOCKS); if (!buf) return ENOMEM; - + for (group = 0; group < fs->group_desc_count; group++) { blk = fs->group_desc[(unsigned)group].bg_inode_table; if (!blk) { @@ -167,7 +167,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, retval = io_channel_write_blk(fs->io, blk, c, buf); if (retval) goto errout; - + blk += c; left -= c; } @@ -182,7 +182,7 @@ errout: /* * Write out superblock and group descriptors */ -errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, +errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags EXT2FS_ATTR((unused))) { char *buf, *cp; @@ -221,7 +221,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, retval = EXT2_ET_SHORT_WRITE; goto errout; } - + retval = 0; errout: @@ -232,7 +232,7 @@ errout: /* * Read the superblock and group descriptors and overwrite them. */ -errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, +errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, int flags EXT2FS_ATTR((unused))) { char *buf; @@ -314,7 +314,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags) if (size > (cnt >> 3)) size = (cnt >> 3); - retval = ext2fs_get_generic_bitmap_range(bmap, + retval = ext2fs_get_generic_bitmap_range(bmap, err, itr, size << 3, buf); if (retval) return retval; @@ -324,7 +324,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags) return errno; if (actual != (int) size) return EXT2_ET_SHORT_READ; - + itr += size << 3; cnt -= size << 3; } @@ -396,7 +396,7 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags) if (actual != (int) size) return EXT2_ET_SHORT_READ; - retval = ext2fs_set_generic_bitmap_range(bmap, + retval = ext2fs_set_generic_bitmap_range(bmap, err, itr, size << 3, buf); if (retval) return retval; diff --git a/lib/ext2fs/ind_block.c b/lib/ext2fs/ind_block.c index efd7fb10..09c04324 100644 --- a/lib/ext2fs/ind_block.c +++ b/lib/ext2fs/ind_block.c @@ -1,7 +1,7 @@ /* * ind_block.c --- indirect block I/O routines - * - * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, + * + * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, * 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index aa4f424d..22d18990 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -1,9 +1,9 @@ /* * initialize.c --- initialize a filesystem handle given superblock * parameters. Used by mke2fs when initializing a filesystem. - * + * * Copyright (C) 1994, 1995, 1996 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -44,13 +44,13 @@ #endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */ #endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */ #endif /* defined(__linux__) && defined(EXT2_OS_LINUX) */ - + /* * Note we override the kernel include file's idea of what the default * check interval (never) should be. It's a good idea to check at * least *occasionally*, specially since servers will never rarely get * to reboot, since Linux is so robust these days. :-) - * + * * 180 days (six months) seems like a good value. */ #ifdef EXT2_DFL_CHECKINTERVAL @@ -110,11 +110,11 @@ errcode_t ext2fs_initialize(const char *name, int flags, if (!param || !param->s_blocks_count) return EXT2_ET_INVALID_ARGUMENT; - + retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); if (retval) return retval; - + memset(fs, 0, sizeof(struct struct_ext2_filsys)); fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags | EXT2_FLAG_RW; @@ -199,7 +199,7 @@ errcode_t ext2fs_initialize(const char *name, int flags, if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super)) super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super); super->s_frags_per_group = super->s_blocks_per_group * frags_per_block; - + super->s_blocks_count = param->s_blocks_count; super->s_r_blocks_count = param->s_r_blocks_count; if (super->s_r_blocks_count >= param->s_blocks_count) { @@ -238,7 +238,7 @@ retry: */ if (super->s_inodes_count < EXT2_FIRST_INODE(super)+1) super->s_inodes_count = EXT2_FIRST_INODE(super)+1; - + /* * There should be at least as many inodes as the user * requested. Figure out how many inodes per group that @@ -358,13 +358,13 @@ ipg_retry: retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); if (retval) goto cleanup; - + strcpy(buf, "block bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; - + strcpy(buf, "inode bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); @@ -420,7 +420,7 @@ ipg_retry: fs->group_desc[i].bg_used_dirs_count = 0; ext2fs_group_desc_csum_set(fs, i); } - + c = (char) 255; if (((int) c) == -1) { super->s_flags |= EXT2_FLAGS_SIGNED_HASH; @@ -431,7 +431,7 @@ ipg_retry: ext2fs_mark_super_dirty(fs); ext2fs_mark_bb_dirty(fs); ext2fs_mark_ib_dirty(fs); - + io_channel_set_blksize(fs->io, fs->blocksize); *ret_fs = fs; diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c index 5833b1d9..13e2f835 100644 --- a/lib/ext2fs/inline.c +++ b/lib/ext2fs/inline.c @@ -2,7 +2,7 @@ * inline.c --- Includes the inlined functions defined in the header * files as standalone functions, in case the application program * is compiled with inlining turned off. - * + * * Copyright (C) 1993, 1994 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index b45de872..b75cb77d 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -1,6 +1,6 @@ /* * inode.c --- utility routines to read and write inodes - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -59,7 +59,7 @@ struct ext2_struct_inode_scan { errcode_t ext2fs_flush_icache(ext2_filsys fs) { int i; - + if (!fs->icache) return 0; @@ -73,7 +73,7 @@ errcode_t ext2fs_flush_icache(ext2_filsys fs) static errcode_t create_icache(ext2_filsys fs) { errcode_t retval; - + if (fs->icache) return 0; retval = ext2fs_get_mem(sizeof(struct ext2_inode_cache), &fs->icache); @@ -184,7 +184,7 @@ void ext2fs_close_inode_scan(ext2_inode_scan scan) { if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN)) return; - + ext2fs_free_mem(&scan->inode_buffer); scan->inode_buffer = NULL; ext2fs_free_mem(&scan->temp_buffer); @@ -202,7 +202,7 @@ void ext2fs_set_inode_callback(ext2_inode_scan scan, { if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN)) return; - + scan->done_group = done_group; scan->done_group_data = done_group_data; } @@ -358,7 +358,7 @@ static errcode_t get_next_blocks(ext2_inode_scan scan) if (retval) return retval; } - + if ((scan->scan_flags & EXT2_SF_BAD_INODE_BLK) || (scan->current_block == 0)) { memset(scan->inode_buffer, 0, @@ -390,7 +390,7 @@ static errcode_t get_next_blocks(ext2_inode_scan scan) static inline int is_empty_scan(ext2_inode_scan scan) { int i; - + if (scan->bytes_left == 0) return 0; @@ -406,7 +406,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, { errcode_t retval; int extra_bytes = 0; - + EXT2_CHECK_MAGIC(scan, EXT2_ET_MAGIC_INODE_SCAN); /* @@ -430,7 +430,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, return retval; } /* - * These checks are done outside the above if statement so + * These checks are done outside the above if statement so * they can be done for block group #0. */ if ((scan->scan_flags & EXT2_SF_DO_LAZY) && @@ -445,7 +445,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, } else return EXT2_ET_MISSING_INODE_TABLE; } - + /* * Have we run out of space in the inode buffer? If so, we @@ -477,9 +477,9 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, #ifdef WORDS_BIGENDIAN memset(inode, 0, bufsize); - ext2fs_swap_inode_full(scan->fs, + ext2fs_swap_inode_full(scan->fs, (struct ext2_inode_large *) inode, - (struct ext2_inode_large *) scan->temp_buffer, + (struct ext2_inode_large *) scan->temp_buffer, 0, bufsize); #else *inode = *((struct ext2_inode *) scan->temp_buffer); @@ -490,7 +490,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, } else { #ifdef WORDS_BIGENDIAN memset(inode, 0, bufsize); - ext2fs_swap_inode_full(scan->fs, + ext2fs_swap_inode_full(scan->fs, (struct ext2_inode_large *) inode, (struct ext2_inode_large *) scan->ptr, 0, bufsize); @@ -568,7 +568,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); if (!fs->group_desc[(unsigned)group].bg_inode_table) return EXT2_ET_MISSING_INODE_TABLE; - block_nr = fs->group_desc[(unsigned)group].bg_inode_table + + block_nr = fs->group_desc[(unsigned)group].bg_inode_table + block; io = fs->io; } @@ -602,8 +602,8 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, } #ifdef WORDS_BIGENDIAN - ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, - (struct ext2_inode_large *) inode, + ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, + (struct ext2_inode_large *) inode, 0, bufsize); #endif @@ -612,7 +612,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, fs->icache->cache_size; fs->icache->cache[fs->icache->cache_last].ino = ino; fs->icache->cache[fs->icache->cache_last].inode = *inode; - + return 0; } @@ -654,7 +654,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, if (retval) return retval; } - + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; @@ -674,8 +674,8 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, memset(w_inode, 0, length); #ifdef WORDS_BIGENDIAN - ext2fs_swap_inode_full(fs, w_inode, - (struct ext2_inode_large *) inode, + ext2fs_swap_inode_full(fs, w_inode, + (struct ext2_inode_large *) inode, 1, bufsize); #else memcpy(w_inode, inode, bufsize); @@ -712,11 +712,11 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, fs->icache->buffer_blk = block_nr; } - - memcpy((char *) fs->icache->buffer + (unsigned) offset, + + memcpy((char *) fs->icache->buffer + (unsigned) offset, ptr, clen); - retval = io_channel_write_blk(fs->io, block_nr, 1, + retval = io_channel_write_blk(fs->io, block_nr, 1, fs->icache->buffer); if (retval) goto errout; @@ -726,7 +726,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, length -= clen; block_nr++; } - + fs->flags |= EXT2_FLAG_CHANGED; errout: if (w_inode && w_inode != &temp_inode) @@ -741,7 +741,7 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, sizeof(struct ext2_inode)); } -/* +/* * This function should be called when writing a new inode. It makes * sure that extra part of large inodes is initialized properly. */ @@ -773,7 +773,7 @@ errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino, *buf = *inode; large_inode = (struct ext2_inode_large *) buf; - large_inode->i_extra_isize = sizeof(struct ext2_inode_large) - + large_inode->i_extra_isize = sizeof(struct ext2_inode_large) - EXT2_GOOD_OLD_INODE_SIZE; if (!large_inode->i_crtime) large_inode->i_crtime = t; @@ -783,13 +783,13 @@ errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino, return retval; } - + errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks) { struct ext2_inode inode; int i; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (ino > fs->super->s_inodes_count) @@ -811,7 +811,7 @@ errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino) { struct ext2_inode inode; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (ino > fs->super->s_inodes_count) diff --git a/lib/ext2fs/inode_io.c b/lib/ext2fs/inode_io.c index 0e234942..4d29a9f8 100644 --- a/lib/ext2fs/inode_io.c +++ b/lib/ext2fs/inode_io.c @@ -56,11 +56,11 @@ static errcode_t inode_write_blk(io_channel channel, unsigned long block, static errcode_t inode_flush(io_channel channel); static errcode_t inode_write_byte(io_channel channel, unsigned long offset, int size, const void *data); -static errcode_t inode_read_blk64(io_channel channel, +static errcode_t inode_read_blk64(io_channel channel, unsigned long long block, int count, void *data); -static errcode_t inode_write_blk64(io_channel channel, +static errcode_t inode_write_blk64(io_channel channel, unsigned long long block, int count, const void *data); - + static struct struct_io_manager struct_inode_manager = { EXT2_ET_MAGIC_IO_MANAGER, "Inode I/O Manager", @@ -158,7 +158,7 @@ static errcode_t inode_open(const char *name, int flags, io_channel *channel) &data->file); if (retval) goto cleanup; - + *channel = io; return 0; @@ -184,7 +184,7 @@ static errcode_t inode_close(io_channel channel) return 0; retval = ext2fs_file_close(data->file); - + ext2fs_free_mem(&channel->private_data); if (channel->name) ext2fs_free_mem(&channel->name); @@ -251,7 +251,7 @@ static errcode_t inode_write_blk64(io_channel channel, return ext2fs_file_write(data->file, buf, count, 0); } -static errcode_t inode_write_blk(io_channel channel, unsigned long block, +static errcode_t inode_write_blk(io_channel channel, unsigned long block, int count, const void *buf) { return inode_write_blk64(channel, block, count, buf); @@ -275,12 +275,12 @@ static errcode_t inode_write_byte(io_channel channel, unsigned long offset, } /* - * Flush data buffers to disk. + * Flush data buffers to disk. */ static errcode_t inode_flush(io_channel channel) { struct inode_private_data *data; - + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct inode_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_INODE_IO_CHANNEL); diff --git a/lib/ext2fs/io_manager.c b/lib/ext2fs/io_manager.c index 8d732530..6d0e2343 100644 --- a/lib/ext2fs/io_manager.c +++ b/lib/ext2fs/io_manager.c @@ -61,8 +61,8 @@ errcode_t io_channel_write_byte(io_channel channel, unsigned long offset, { EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); - if (channel->manager->write_byte) - return channel->manager->write_byte(channel, offset, + if (channel->manager->write_byte) + return channel->manager->write_byte(channel, offset, count, data); return EXT2_ET_UNIMPLEMENTED; diff --git a/lib/ext2fs/irel.h b/lib/ext2fs/irel.h index 9b943ced..45e031be 100644 --- a/lib/ext2fs/irel.h +++ b/lib/ext2fs/irel.h @@ -1,6 +1,6 @@ /* * irel.h - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/irel_ma.c b/lib/ext2fs/irel_ma.c index c6fa828a..f565939a 100644 --- a/lib/ext2fs/irel_ma.c +++ b/lib/ext2fs/irel_ma.c @@ -1,6 +1,6 @@ /* * irel_ma.c - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -77,18 +77,18 @@ errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode, if (retval) goto errout; memset(irel, 0, sizeof(struct ext2_inode_relocation_table)); - + retval = ext2fs_get_mem(strlen(name)+1, &irel->name); if (retval) goto errout; strcpy(irel->name, name); - + retval = ext2fs_get_mem(sizeof(struct irel_ma), &ma); if (retval) goto errout; memset(ma, 0, sizeof(struct irel_ma)); irel->priv_data = ma; - + size = (size_t) (sizeof(ext2_ino_t) * (max_inode+1)); retval = ext2fs_get_array(max_inode+1, sizeof(ext2_ino_t), &ma->orig_map); @@ -127,7 +127,7 @@ errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode, irel->move = ima_move; irel->delete = ima_delete; irel->free = ima_free; - + *new_irel = irel; return 0; @@ -156,7 +156,7 @@ static errcode_t ima_put(ext2_irel irel, ext2_ino_t old, ent->orig = old; else ent->orig = ma->entries[(unsigned) old].orig; - + /* * If max_refs has changed, reallocate the refs array */ @@ -245,12 +245,12 @@ static errcode_t ima_add_ref(ext2_irel irel, ext2_ino_t ino, ref_ent = ma->ref_entries + (unsigned) ino; ent = ma->entries + (unsigned) ino; - + /* * If the inode reference array doesn't exist, create it. */ if (ref_ent->refs == 0) { - size = (size_t) ((sizeof(struct ext2_inode_reference) * + size = (size_t) ((sizeof(struct ext2_inode_reference) * ent->max_refs)); retval = ext2fs_get_array(ent->max_refs, sizeof(struct ext2_inode_reference), &ref_ent->refs); @@ -288,7 +288,7 @@ static errcode_t ima_next_ref(ext2_irel irel, struct inode_reference_entry *ref_ent; ma = irel->priv_data; - + ref_ent = ma->ref_entries + ma->ref_current; if ((ref_ent->refs == NULL) || @@ -311,12 +311,12 @@ static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new) return EXT2_ET_INVALID_ARGUMENT; if (ma->entries[(unsigned) old].new == 0) return ENOENT; - + ma->entries[(unsigned) new] = ma->entries[(unsigned) old]; if (ma->ref_entries[(unsigned) new].refs) ext2fs_free_mem(&ma->ref_entries[(unsigned) new].refs); ma->ref_entries[(unsigned) new] = ma->ref_entries[(unsigned) old]; - + ma->entries[(unsigned) old].new = 0; ma->ref_entries[(unsigned) old].num = 0; ma->ref_entries[(unsigned) old].refs = 0; @@ -334,12 +334,12 @@ static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old) return EXT2_ET_INVALID_ARGUMENT; if (ma->entries[(unsigned) old].new == 0) return ENOENT; - + ma->entries[old].new = 0; if (ma->ref_entries[(unsigned) old].refs) ext2fs_free_mem(&ma->ref_entries[(unsigned) old].refs); ma->orig_map[ma->entries[(unsigned) old].orig] = 0; - + ma->ref_entries[(unsigned) old].num = 0; ma->ref_entries[(unsigned) old].refs = 0; return 0; diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index d6573ad2..4a7c8c69 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -1,6 +1,6 @@ /* * ismounted.c --- Check to see if the filesystem was mounted - * + * * Copyright (C) 1995,1996,1997,1998,1999,2000 Theodore Ts'o. * * %Begin-Header% @@ -38,9 +38,9 @@ /* * Helper function which checks a file in /etc/mtab format to see if a * filesystem is mounted. Returns an error if the file doesn't exist - * or can't be opened. + * or can't be opened. */ -static errcode_t check_mntent_file(const char *mtab_file, const char *file, +static errcode_t check_mntent_file(const char *mtab_file, const char *file, int *mount_flags, char *mtpt, int mtlen) { struct mntent *mnt; @@ -103,7 +103,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, } #ifndef __GNU__ /* The GNU hurd is deficient; what else is new? */ /* Validate the entry in case /etc/mtab is out of date */ - /* + /* * We need to be paranoid, because some broken distributions * (read: Slackware) don't initialize /etc/mtab before checking * all of the non-root filesystems on the disk. @@ -128,7 +128,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, } #endif /* __GNU__ */ *mount_flags = EXT2_MF_MOUNTED; - + #ifdef MNTOPT_RO /* Check to see if the ro option is set */ if (hasmntopt(mnt, MNTOPT_RO)) @@ -145,7 +145,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, */ if (!strcmp(mnt->mnt_dir, "/")) { is_root: -#define TEST_FILE "/.ismount-test-file" +#define TEST_FILE "/.ismount-test-file" *mount_flags |= EXT2_MF_ISROOT; fd = open(TEST_FILE, O_RDWR|O_CREAT, 0600); if (fd < 0) { @@ -184,7 +184,7 @@ static errcode_t check_mntent(const char *file, int *mount_flags, #endif /* MOUNTED */ retval = check_mntent_file(MOUNTED, file, mount_flags, mtpt, mtlen); return retval; -#else +#else *mount_flags = 0; return 0; #endif /* defined(MOUNTED) || defined(_PATH_MOUNTED) */ @@ -209,7 +209,7 @@ static errcode_t check_getmntinfo(const char *file, int *mount_flags, s1 = file; if (strncmp(_PATH_DEV, s1, len) == 0) s1 += len; - + *mount_flags = 0; while (--n >= 0) { s2 = mp->f_mntfromname; @@ -299,7 +299,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, } else { #ifdef HAVE_MNTENT_H retval = check_mntent(device, mount_flags, mtpt, mtlen); -#else +#else #ifdef HAVE_GETMNTINFO retval = check_getmntinfo(device, mount_flags, mtpt, mtlen); #else @@ -331,7 +331,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, /* * ext2fs_check_if_mounted() sets the mount_flags EXT2_MF_MOUNTED, * EXT2_MF_READONLY, and EXT2_MF_ROOT - * + * */ errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags) { @@ -343,7 +343,7 @@ int main(int argc, char **argv) { int retval, mount_flags; char mntpt[80]; - + if (argc < 2) { fprintf(stderr, "Usage: %s device\n", argv[0]); exit(1); diff --git a/lib/ext2fs/jfs_dat.h b/lib/ext2fs/jfs_dat.h index d6ad9c48..62778c62 100644 --- a/lib/ext2fs/jfs_dat.h +++ b/lib/ext2fs/jfs_dat.h @@ -9,7 +9,7 @@ * On-disk structures */ -/* +/* * Descriptor block types: */ @@ -28,8 +28,8 @@ typedef struct journal_header_s } journal_header_t; -/* - * The block tag: used to describe a single buffer in the journal +/* + * The block tag: used to describe a single buffer in the journal */ typedef struct journal_block_tag_s { @@ -55,10 +55,10 @@ typedef struct journal_superblock_s __u32 s_blocksize; /* journal device blocksize */ __u32 s_maxlen; /* total blocks in journal file */ __u32 s_first; /* first block of log information */ - + /* Dynamic information describing the current state of the log */ __u32 s_sequence; /* first commit ID expected in log */ __u32 s_start; /* blocknr of start of log */ - + } journal_superblock_t; diff --git a/lib/ext2fs/kernel-jbd.h b/lib/ext2fs/kernel-jbd.h index 158d7641..331b0e47 100644 --- a/lib/ext2fs/kernel-jbd.h +++ b/lib/ext2fs/kernel-jbd.h @@ -1,6 +1,6 @@ /* * linux/include/linux/jbd.h - * + * * Written by Stephen C. Tweedie <sct@redhat.com> * * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved @@ -59,7 +59,7 @@ extern int journal_enable_debug; #define jbd_debug(f, a...) /**/ #else #define jbd_debug(f, ...) /**/ -#endif +#endif #endif #else #define jbd_debug(x) /* AIX doesn't do STDC */ @@ -88,7 +88,7 @@ typedef struct journal_s journal_t; /* Journal control structure */ * On-disk structures */ -/* +/* * Descriptor block types: */ @@ -133,8 +133,8 @@ struct commit_header { __u32 h_commit_nsec; }; -/* - * The block tag: used to describe a single buffer in the journal +/* + * The block tag: used to describe a single buffer in the journal */ typedef struct journal_block_tag_s { @@ -146,9 +146,9 @@ typedef struct journal_block_tag_s #define JBD_TAG_SIZE64 (sizeof(journal_block_tag_t)) #define JBD_TAG_SIZE32 (8) -/* +/* * The revoke descriptor: used on disk to describe a series of blocks to - * be revoked from the log + * be revoked from the log */ typedef struct journal_revoke_header_s { @@ -177,7 +177,7 @@ typedef struct journal_superblock_s __u32 s_blocksize; /* journal device blocksize */ __u32 s_maxlen; /* total blocks in journal file */ __u32 s_first; /* first block of log information */ - + /* 0x0018 */ /* Dynamic information describing the current state of the log */ __u32 s_sequence; /* first commit ID expected in log */ @@ -197,9 +197,9 @@ typedef struct journal_superblock_s /* 0x0040 */ __u32 s_nr_users; /* Nr of filesystems sharing log */ - + __u32 s_dynsuper; /* Blocknr of dynamic superblock copy*/ - + /* 0x0048 */ __u32 s_max_transaction; /* Limit of journal blocks per trans.*/ __u32 s_max_trans_data; /* Limit of data blocks per trans. */ @@ -311,7 +311,7 @@ struct jbd_revoke_table_s; * the transaction, so that at all times we know how many buffers the * outstanding updates on a transaction might possibly touch. */ -struct handle_s +struct handle_s { /* Which compound transaction is this update a part of? */ transaction_t * h_transaction; @@ -349,14 +349,14 @@ struct handle_s * flushed to home for finished transactions. */ -struct transaction_s +struct transaction_s { /* Pointer to the journal for this transaction. */ journal_t * t_journal; - + /* Sequence number for this transaction */ tid_t t_tid; - + /* Transaction's current state */ enum { T_RUNNING, @@ -364,74 +364,74 @@ struct transaction_s T_RUNDOWN, T_FLUSH, T_COMMIT, - T_FINISHED + T_FINISHED } t_state; /* Where in the log does this transaction's commit start? */ unsigned long t_log_start; - + /* Doubly-linked circular list of all inodes owned by this transaction */ /* AKPM: unused */ struct inode * t_ilist; - + /* Number of buffers on the t_buffers list */ int t_nr_buffers; - + /* Doubly-linked circular list of all buffers reserved but not yet modified by this transaction */ struct journal_head * t_reserved_list; - + /* Doubly-linked circular list of all metadata buffers owned by this transaction */ struct journal_head * t_buffers; - + /* * Doubly-linked circular list of all data buffers still to be * flushed before this transaction can be committed. * Protected by journal_datalist_lock. */ struct journal_head * t_sync_datalist; - + /* * Doubly-linked circular list of all writepage data buffers * still to be written before this transaction can be committed. * Protected by journal_datalist_lock. */ struct journal_head * t_async_datalist; - + /* Doubly-linked circular list of all forget buffers (superceded buffers which we can un-checkpoint once this transaction commits) */ struct journal_head * t_forget; - + /* * Doubly-linked circular list of all buffers still to be * flushed before this transaction can be checkpointed. */ /* Protected by journal_datalist_lock */ struct journal_head * t_checkpoint_list; - + /* Doubly-linked circular list of temporary buffers currently undergoing IO in the log */ struct journal_head * t_iobuf_list; - + /* Doubly-linked circular list of metadata buffers being shadowed by log IO. The IO buffers on the iobuf list and the shadow buffers on this list match each other one for one at all times. */ struct journal_head * t_shadow_list; - + /* Doubly-linked circular list of control buffers being written to the log. */ struct journal_head * t_log_list; - + /* Number of outstanding updates running on this transaction */ int t_updates; /* Number of buffers reserved for use by all handles in this * transaction handle but not yet modified. */ int t_outstanding_credits; - + /* * Forward and backward links for the circular list of all * transactions awaiting checkpoint. @@ -450,7 +450,7 @@ struct transaction_s /* The journal_t maintains all of the journaling state information for a * single filesystem. It is linked to from the fs superblock structure. - * + * * We use the journal_t to keep track of all outstanding transaction * activity on the filesystem, and to manage the state of the log * writing process. */ @@ -463,7 +463,7 @@ struct journal_s /* Is there an outstanding uncleared error on the journal (from * a prior abort)? */ int j_errno; - + /* The superblock buffer */ struct buffer_head * j_sb_buffer; journal_superblock_t * j_superblock; @@ -473,16 +473,16 @@ struct journal_s /* Number of processes waiting to create a barrier lock */ int j_barrier_count; - + /* The barrier lock itself */ struct semaphore j_barrier; - + /* Transactions: The current running transaction... */ transaction_t * j_running_transaction; - + /* ... the transaction we are pushing to disk ... */ transaction_t * j_committing_transaction; - + /* ... and a linked circular list of all transactions waiting * for checkpointing. */ /* Protected by journal_datalist_lock */ @@ -491,19 +491,19 @@ struct journal_s /* Wait queue for waiting for a locked transaction to start committing, or for a barrier lock to be released */ wait_queue_head_t j_wait_transaction_locked; - + /* Wait queue for waiting for checkpointing to complete */ wait_queue_head_t j_wait_logspace; - + /* Wait queue for waiting for commit to complete */ wait_queue_head_t j_wait_done_commit; - + /* Wait queue to trigger checkpointing */ wait_queue_head_t j_wait_checkpoint; - + /* Wait queue to trigger commit */ wait_queue_head_t j_wait_commit; - + /* Wait queue to wait for updates to complete */ wait_queue_head_t j_wait_updates; @@ -512,10 +512,10 @@ struct journal_s /* The main journal lock, used by lock_journal() */ struct semaphore j_sem; - + /* Journal head: identifies the first unused block in the journal. */ unsigned long j_head; - + /* Journal tail: identifies the oldest still-used block in the * journal. */ unsigned long j_tail; @@ -588,8 +588,8 @@ struct journal_s unsigned int j_failed_commit; }; -/* - * Journal flag definitions +/* + * Journal flag definitions */ #define JFS_UNMOUNT 0x001 /* Journal thread is being destroyed */ #define JFS_ABORT 0x002 /* Journaling has been aborted for errors. */ @@ -597,7 +597,7 @@ struct journal_s #define JFS_FLUSHED 0x008 /* The journal superblock has been flushed */ #define JFS_LOADED 0x010 /* The journal superblock has been loaded */ -/* +/* * Function declarations for the journaling transaction and buffer * management */ @@ -627,7 +627,7 @@ extern void journal_insert_checkpoint(struct journal_head *, transaction_t *); extern void __journal_insert_checkpoint(struct journal_head *,transaction_t *); /* Buffer IO */ -extern int +extern int journal_write_metadata_buffer(transaction_t *transaction, struct journal_head *jh_in, struct journal_head **jh_out, @@ -641,7 +641,7 @@ extern void __wait_on_journal (journal_t *); * * We need to lock the journal during transaction state changes so that * nobody ever tries to take a handle on the running transaction while - * we are in the middle of moving it to the commit phase. + * we are in the middle of moving it to the commit phase. * * Note that the locking is completely interrupt unsafe. We never touch * journal structures from interrupts. @@ -675,7 +675,7 @@ static inline handle_t *journal_current_handle(void) /* The journaling code user interface: * * Create and destroy handles - * Register buffer modifications against the current transaction. + * Register buffer modifications against the current transaction. */ extern handle_t *journal_start(journal_t *, int nblocks); @@ -703,11 +703,11 @@ extern journal_t * journal_init_dev(kdev_t dev, kdev_t fs_dev, int start, int len, int bsize); extern journal_t * journal_init_inode (struct inode *); extern int journal_update_format (journal_t *); -extern int journal_check_used_features +extern int journal_check_used_features (journal_t *, unsigned long, unsigned long, unsigned long); -extern int journal_check_available_features +extern int journal_check_available_features (journal_t *, unsigned long, unsigned long, unsigned long); -extern int journal_set_features +extern int journal_set_features (journal_t *, unsigned long, unsigned long, unsigned long); extern int journal_create (journal_t *); extern int journal_load (journal_t *journal); @@ -785,7 +785,7 @@ do { \ * bit, when set, indicates that we have had a fatal error somewhere, * either inside the journaling layer or indicated to us by the client * (eg. ext3), and that we and should not commit any further - * transactions. + * transactions. */ static inline int is_journal_aborted(journal_t *journal) @@ -867,7 +867,7 @@ extern int journal_blocks_per_page(struct inode *inode); #define BJ_LogCtl 7 /* Buffer contains log descriptors */ #define BJ_Reserved 8 /* Buffer is reserved for access by journal */ #define BJ_Types 9 - + extern int jbd_blocks_per_page(struct inode *inode); #ifdef __KERNEL__ diff --git a/lib/ext2fs/kernel-list.h b/lib/ext2fs/kernel-list.h index 24e6ab4a..e07d06b6 100644 --- a/lib/ext2fs/kernel-list.h +++ b/lib/ext2fs/kernel-list.h @@ -29,7 +29,7 @@ struct list_head { #endif /* - * Insert a new entry between two known consecutive entries. + * Insert a new entry between two known consecutive entries. * * This is only for internal list manipulation where we know * the prev/next entries already! diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c index b2834889..5ed63942 100644 --- a/lib/ext2fs/link.c +++ b/lib/ext2fs/link.c @@ -1,6 +1,6 @@ /* * link.c --- create links in a ext2fs directory - * + * * Copyright (C) 1993, 1994 Theodore Ts'o. * * %Begin-Header% @@ -26,7 +26,7 @@ struct link_struct { int done; unsigned int blocksize; struct ext2_super_block *sb; -}; +}; static int link_proc(struct ext2_dir_entry *dirent, int offset, @@ -99,7 +99,7 @@ static int link_proc(struct ext2_dir_entry *dirent, #ifdef __TURBOC__ #pragma argsused #endif -errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name, +errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name, ext2_ino_t ino, int flags) { errcode_t retval; diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c index 5a5e560b..073cf91a 100644 --- a/lib/ext2fs/llseek.c +++ b/lib/ext2fs/llseek.c @@ -74,7 +74,7 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin) #ifndef __i386__ retval = _llseek(fd, ((unsigned long long) offset) >> 32, -#else +#else retval = syscall(__NR__llseek, fd, (unsigned long long) (offset >> 32), #endif ((unsigned long long) offset) & 0xffffffff, @@ -100,7 +100,7 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin) errno = EINVAL; return -1; } - + result = my_llseek (fd, offset, origin); if (result == -1 && errno == ENOSYS) { /* diff --git a/lib/ext2fs/lookup.c b/lib/ext2fs/lookup.c index 1745f33a..9cb97f1b 100644 --- a/lib/ext2fs/lookup.c +++ b/lib/ext2fs/lookup.c @@ -1,6 +1,6 @@ /* * lookup.c --- ext2fs directory lookup operations - * + * * Copyright (C) 1993, 1994, 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -23,7 +23,7 @@ struct lookup_struct { int len; ext2_ino_t *inode; int found; -}; +}; #ifdef __TURBOC__ #pragma argsused diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index e769ed50..88bc6fa2 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -1,6 +1,6 @@ /* * mkdir.c --- make a directory in the filesystem - * + * * Copyright (C) 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -93,7 +93,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, retval = ext2fs_write_dir_block(fs, blk, block); if (retval) goto cleanup; - retval = ext2fs_write_new_inode(fs, ino, &inode); + retval = ext2fs_write_new_inode(fs, ino, &inode); if (retval) goto cleanup; @@ -124,7 +124,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, if (retval) goto cleanup; } - + /* * Update accounting.... */ diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index c112be9b..96b574eb 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -2,7 +2,7 @@ * mkjournal.c --- make a journal for a filesystem * * Copyright (C) 2000 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -215,7 +215,7 @@ static int mkjournal_proc(ext2_filsys fs, struct mkjournal_struct *es = (struct mkjournal_struct *) priv_data; blk_t new_blk; errcode_t retval; - + if (*blocknr) { es->goal = *blocknr; return 0; @@ -265,7 +265,7 @@ static int mkjournal_proc(ext2_filsys fs, return (BLOCK_CHANGED | BLOCK_ABORT); else return BLOCK_CHANGED; - + } /* @@ -282,7 +282,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, if ((retval = ext2fs_create_journal_superblock(fs, size, flags, &buf))) return retval; - + if ((retval = ext2fs_read_bitmaps(fs))) return retval; @@ -309,7 +309,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, * the filesystem. Pick a group that has the largest number * of free blocks. */ - group = ext2fs_group_of_blk(fs, (fs->super->s_blocks_count - + group = ext2fs_group_of_blk(fs, (fs->super->s_blocks_count - fs->super->s_first_data_block) / 2); start = (group > 0) ? group-1 : group; end = ((group+1) < fs->group_desc_count) ? group+1 : group; @@ -393,7 +393,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) /* Make sure the device exists and is a block device */ if (stat(journal_dev->device_name, &st) < 0) return errno; - + if (!S_ISBLK(st.st_mode)) return EXT2_ET_JOURNAL_NOT_BLOCK; /* Must be a block device */ @@ -428,7 +428,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) /* Writeback the journal superblock */ if ((retval = io_channel_write_blk(journal_dev->io, start, -1024, buf))) return retval; - + fs->super->s_journal_inum = 0; fs->super->s_journal_dev = st.st_rdev; memcpy(fs->super->s_journal_uuid, jsb->s_uuid, @@ -460,7 +460,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) strcat(jfile, "/.journal"); /* - * If .../.journal already exists, make sure any + * If .../.journal already exists, make sure any * immutable or append-only flags are cleared. */ #if defined(HAVE_CHFLAGS) && defined(UF_NODUMP) @@ -482,7 +482,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) if ((retval = write_journal_file(fs, jfile, size, flags))) goto errout; - + /* Get inode number of the journal file */ if (fstat(fd, &st) < 0) goto errout; @@ -497,7 +497,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) #endif if (retval) goto errout; - + close(fd); journal_ino = st.st_ino; } else { @@ -511,7 +511,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) size, flags))) return retval; } - + fs->super->s_journal_inum = journal_ino; fs->super->s_journal_dev = 0; memset(fs->super->s_journal_uuid, 0, @@ -538,7 +538,7 @@ main(int argc, char **argv) exit(1); } device_name = argv[1]; - + retval = ext2fs_open (device_name, EXT2_FLAG_RW, 0, 0, unix_io_manager, &fs); if (retval) { @@ -558,6 +558,6 @@ main(int argc, char **argv) } ext2fs_close(fs); exit(0); - + } #endif diff --git a/lib/ext2fs/namei.c b/lib/ext2fs/namei.c index c380939d..2b28a54f 100644 --- a/lib/ext2fs/namei.c +++ b/lib/ext2fs/namei.c @@ -1,6 +1,6 @@ /* * namei.c --- ext2fs directory lookup operations - * + * * Copyright (C) 1993, 1994, 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -36,7 +36,7 @@ static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir, #ifdef NAMEI_DEBUG printf("follow_link: root=%lu, dir=%lu, inode=%lu, lc=%d\n", root, dir, inode, link_count); - + #endif retval = ext2fs_read_inode (fs, inode, &ei); if (retval) return retval; @@ -152,13 +152,13 @@ errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, { char *buf; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_get_mem(fs->blocksize, &buf); if (retval) return retval; - + retval = open_namei(fs, root, cwd, name, strlen(name), 0, 0, buf, inode); @@ -171,13 +171,13 @@ errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, { char *buf; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_get_mem(fs->blocksize, &buf); if (retval) return retval; - + retval = open_namei(fs, root, cwd, name, strlen(name), 1, 0, buf, inode); @@ -190,7 +190,7 @@ errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, { char *buf; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_get_mem(fs->blocksize, &buf); diff --git a/lib/ext2fs/native.c b/lib/ext2fs/native.c index 85d09896..738c34bd 100644 --- a/lib/ext2fs/native.c +++ b/lib/ext2fs/native.c @@ -1,8 +1,8 @@ /* * native.c --- returns the ext2_flag for a native byte order - * + * * Copyright (C) 1996 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -23,5 +23,5 @@ int ext2fs_native_flag(void) #endif } - - + + diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c index c2ca9034..4e7b40d6 100644 --- a/lib/ext2fs/newdir.c +++ b/lib/ext2fs/newdir.c @@ -1,6 +1,6 @@ /* * newdir.c --- create a new directory block - * + * * Copyright (C) 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -65,7 +65,7 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino, dir->name_len = 2 | filetype; dir->name[0] = '.'; dir->name[1] = '.'; - + } *block = buf; return 0; diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 525693ec..841aa34b 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -1,8 +1,8 @@ /* * openfs.c --- open an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -59,10 +59,10 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i) } errcode_t ext2fs_open(const char *name, int flags, int superblock, - unsigned int block_size, io_manager manager, + unsigned int block_size, io_manager manager, ext2_filsys *ret_fs) { - return ext2fs_open2(name, 0, flags, superblock, block_size, + return ext2fs_open2(name, 0, flags, superblock, block_size, manager, ret_fs); } @@ -71,7 +71,7 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, * Superblock and block_size can be zero to use the default size. * * Valid flags for ext2fs_open() - * + * * EXT2_FLAG_RW - Open the filesystem for read/write. * EXT2_FLAG_FORCE - Open the filesystem even if some of the * features aren't supported. @@ -79,7 +79,7 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, */ errcode_t ext2fs_open2(const char *name, const char *io_options, int flags, int superblock, - unsigned int block_size, io_manager manager, + unsigned int block_size, io_manager manager, ext2_filsys *ret_fs) { ext2_filsys fs; @@ -93,13 +93,13 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, struct ext2_group_desc *gdp; int j; #endif - + EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER); retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); if (retval) return retval; - + memset(fs, 0, sizeof(struct struct_ext2_filsys)); fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags; @@ -115,7 +115,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, *cp++ = 0; io_options = cp; } - + io_flags = 0; if (flags & EXT2_FLAG_RW) io_flags |= IO_FLAG_RW; @@ -124,7 +124,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, retval = manager->open(fs->device_name, io_flags, &fs->io); if (retval) goto cleanup; - if (io_options && + if (io_options && (retval = io_channel_set_options(fs->io, io_options))) goto cleanup; fs->image_io = fs->io; @@ -189,7 +189,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; } #endif - + if (fs->super->s_magic != EXT2_SUPER_MAGIC) { retval = EXT2_ET_BAD_MAGIC; goto cleanup; @@ -231,7 +231,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; } } - + if ((fs->super->s_log_block_size + EXT2_MIN_BLOCK_LOG_SIZE) > EXT2_MAX_BLOCK_LOG_SIZE) { retval = EXT2_ET_CORRUPT_SUPERBLOCK; @@ -268,7 +268,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, *ret_fs = fs; return 0; } - + /* * Read group descriptors */ @@ -336,7 +336,7 @@ cleanup: /* * Set/get the filesystem data I/O channel. - * + * * These functions are only valid if EXT2_FLAG_IMAGE_FILE is true. */ errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io) @@ -362,7 +362,7 @@ errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io) if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0) return EXT2_ET_NOT_IMAGE_FILE; fs->io = fs->image_io = new_io; - fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW | + fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW | EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY; fs->flags &= ~EXT2_FLAG_IMAGE_FILE; return 0; diff --git a/lib/ext2fs/read_bb.c b/lib/ext2fs/read_bb.c index 875be9fc..112d07fb 100644 --- a/lib/ext2fs/read_bb.c +++ b/lib/ext2fs/read_bb.c @@ -38,16 +38,16 @@ struct read_bb_record { #pragma argsused #endif static int mark_bad_block(ext2_filsys fs, blk_t *block_nr, - e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), + e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), blk_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *priv_data) { struct read_bb_record *rb = (struct read_bb_record *) priv_data; - + if (blockcnt < 0) return 0; - + if ((*block_nr < fs->super->s_first_data_block) || (*block_nr >= fs->super->s_blocks_count)) return 0; /* Ignore illegal blocks */ diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c index 2ac71f46..60dec426 100644 --- a/lib/ext2fs/read_bb_file.c +++ b/lib/ext2fs/read_bb_file.c @@ -29,7 +29,7 @@ /* * Reads a list of bad blocks from a FILE * */ -errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, +errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void *priv_data, void (*invalid)(ext2_filsys fs, @@ -76,7 +76,7 @@ struct compat_struct { }; static void call_compat_invalid(ext2_filsys fs, blk_t blk, - char *badstr EXT2FS_ATTR((unused)), + char *badstr EXT2FS_ATTR((unused)), void *priv_data) { struct compat_struct *st; @@ -90,7 +90,7 @@ static void call_compat_invalid(ext2_filsys fs, blk_t blk, /* * Reads a list of bad blocks from a FILE * */ -errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, +errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void (*invalid)(ext2_filsys fs, blk_t blk)) { diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c index 848a02a2..dda7c2b4 100644 --- a/lib/ext2fs/res_gdt.c +++ b/lib/ext2fs/res_gdt.c @@ -92,7 +92,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs) goto out_inode; } else { blk_t goal = sb->s_first_data_block + fs->desc_blocks + - sb->s_reserved_gdt_blocks + 2 + + sb->s_reserved_gdt_blocks + 2 + fs->inode_blocks_per_group; retval = ext2fs_alloc_block(fs, goal, 0, &dindir_blk); diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index d4e94da6..341f834a 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -58,7 +58,7 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) memset(block_buf, 0xff, fs->blocksize); } if (do_inode) { - inode_nbytes = (size_t) + inode_nbytes = (size_t) ((EXT2_INODES_PER_GROUP(fs->super)+7) / 8); retval = ext2fs_get_mem(fs->blocksize, &inode_buf); if (retval) @@ -71,10 +71,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) goto skip_block_bitmap; if (csum_flag && fs->group_desc[i].bg_flags & - EXT2_BG_BLOCK_UNINIT) + EXT2_BG_BLOCK_UNINIT) goto skip_this_block_bitmap; - - retval = ext2fs_get_block_bitmap_range(fs->block_map, + + retval = ext2fs_get_block_bitmap_range(fs->block_map, blk_itr, block_nbytes << 3, block_buf); if (retval) return retval; @@ -103,10 +103,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) continue; if (csum_flag && fs->group_desc[i].bg_flags & - EXT2_BG_INODE_UNINIT) + EXT2_BG_INODE_UNINIT) goto skip_this_inode_bitmap; - - retval = ext2fs_get_inode_bitmap_range(fs->inode_map, + + retval = ext2fs_get_inode_bitmap_range(fs->inode_map, ino_itr, inode_nbytes << 3, inode_buf); if (retval) return retval; @@ -169,7 +169,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; - retval = ext2fs_get_mem(do_image ? fs->blocksize : + retval = ext2fs_get_mem(do_image ? fs->blocksize : (unsigned) block_nbytes, &block_bitmap); if (retval) goto cleanup; @@ -183,7 +183,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); if (retval) goto cleanup; - retval = ext2fs_get_mem(do_image ? fs->blocksize : + retval = ext2fs_get_mem(do_image ? fs->blocksize : (unsigned) inode_nbytes, &inode_bitmap); if (retval) goto cleanup; @@ -202,7 +202,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) cnt = fs->blocksize << 3; if (cnt > ino_cnt) cnt = ino_cnt; - retval = ext2fs_set_inode_bitmap_range(fs->inode_map, + retval = ext2fs_set_inode_bitmap_range(fs->inode_map, ino_itr, cnt, inode_bitmap); if (retval) goto cleanup; @@ -212,7 +212,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) } blk = (fs->image_header->offset_blockmap / fs->blocksize); - blk_cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * + blk_cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count; while (block_nbytes > 0) { retval = io_channel_read_blk(fs->image_io, blk++, @@ -222,7 +222,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) cnt = fs->blocksize << 3; if (cnt > blk_cnt) cnt = blk_cnt; - retval = ext2fs_set_block_bitmap_range(fs->block_map, + retval = ext2fs_set_block_bitmap_range(fs->block_map, blk_itr, cnt, block_bitmap); if (retval) goto cleanup; @@ -250,7 +250,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) } else memset(block_bitmap, 0xff, block_nbytes); cnt = block_nbytes << 3; - retval = ext2fs_set_block_bitmap_range(fs->block_map, + retval = ext2fs_set_block_bitmap_range(fs->block_map, blk_itr, cnt, block_bitmap); if (retval) goto cleanup; @@ -272,7 +272,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) } else memset(inode_bitmap, 0xff, inode_nbytes); cnt = inode_nbytes << 3; - retval = ext2fs_set_inode_bitmap_range(fs->inode_map, + retval = ext2fs_set_inode_bitmap_range(fs->inode_map, ino_itr, cnt, inode_bitmap); if (retval) goto cleanup; @@ -285,7 +285,7 @@ success_cleanup: if (block_bitmap) ext2fs_free_mem(&block_bitmap); return 0; - + cleanup: if (do_block) { ext2fs_free_mem(&fs->block_map); diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c index 5fe32927..5ccc87f0 100644 --- a/lib/ext2fs/swapfs.c +++ b/lib/ext2fs/swapfs.c @@ -1,6 +1,6 @@ /* * swapfs.c --- swap ext2 filesystem data structures - * + * * Copyright (C) 1995, 1996, 2002 Theodore Ts'o. * * %Begin-Header% @@ -166,11 +166,11 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t, t->i_links_count = ext2fs_swab16(f->i_links_count); t->i_file_acl = ext2fs_swab32(f->i_file_acl); if (hostorder) - has_data_blocks = ext2fs_inode_data_blocks(fs, + has_data_blocks = ext2fs_inode_data_blocks(fs, (struct ext2_inode *) f); t->i_blocks = ext2fs_swab32(f->i_blocks); if (!hostorder) - has_data_blocks = ext2fs_inode_data_blocks(fs, + has_data_blocks = ext2fs_inode_data_blocks(fs, (struct ext2_inode *) t); if (hostorder && (f->i_flags & EXT4_EXTENTS_FL)) has_extents = 1; @@ -193,7 +193,7 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t, case EXT2_OS_LINUX: t->osd1.linux1.l_i_version = ext2fs_swab32(f->osd1.linux1.l_i_version); - t->osd2.linux2.l_i_blocks_hi = + t->osd2.linux2.l_i_blocks_hi = ext2fs_swab16(f->osd2.linux2.l_i_blocks_hi); t->osd2.linux2.l_i_file_acl_high = ext2fs_swab16(f->osd2.linux2.l_i_file_acl_high); diff --git a/lib/ext2fs/tdb.c b/lib/ext2fs/tdb.c index b7cf43d4..0c82a248 100644 --- a/lib/ext2fs/tdb.c +++ b/lib/ext2fs/tdb.c @@ -3,17 +3,17 @@ URL: svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/tdb/common Rev: 23590 Last Changed Date: 2007-06-22 13:36:10 -0400 (Fri, 22 Jun 2007) */ - /* + /* trivial database library - standalone version Copyright (C) Andrew Tridgell 1999-2005 Copyright (C) Jeremy Allison 2000-2006 Copyright (C) Paul `Rusty' Russell 2000 - + ** NOTE! The following LGPL license applies to the tdb ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -327,11 +327,11 @@ const char *tdb_errorstr(struct tdb_context *tdb) this functions locks/unlocks 1 byte at the specified offset. On error, errno is also set so that errors are passed back properly - through tdb_open(). + through tdb_open(). note that a len of zero means lock to end of file */ -int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, +int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len) { struct flock fl; @@ -363,7 +363,7 @@ int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, if (!probe && lck_type != F_SETLK) { /* Ensure error code is set for log fun to examine. */ tdb->ecode = TDB_ERR_LOCK; - TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d\n", + TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d\n", tdb->fd, offset, rw_type, lck_type, (int)len)); } return TDB_ERRCODE(TDB_ERR_LOCK, -1); @@ -376,7 +376,7 @@ int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, upgrade a read lock to a write lock. This needs to be handled in a special way as some OSes (such as solaris) have too conservative deadlock detection and claim a deadlock when progress can be - made. For those OSes we may loop for a while. + made. For those OSes we may loop for a while. */ int tdb_brlock_upgrade(struct tdb_context *tdb, tdb_off_t offset, size_t len) { @@ -409,7 +409,7 @@ static int _tdb_lock(struct tdb_context *tdb, int list, int ltype, int op) ltype &= ~TDB_MARK_LOCK; /* a global lock allows us to avoid per chain locks */ - if (tdb->global_lock.count && + if (tdb->global_lock.count && (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) { return 0; } @@ -419,7 +419,7 @@ static int _tdb_lock(struct tdb_context *tdb, int list, int ltype, int op) } if (list < -1 || list >= (int)tdb->header.hash_size) { - TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid list %d for ltype=%d\n", + TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid list %d for ltype=%d\n", list, ltype)); return -1; } @@ -504,7 +504,7 @@ int tdb_unlock(struct tdb_context *tdb, int list, int ltype) ltype &= ~TDB_MARK_LOCK; /* a global lock allows us to avoid per chain locks */ - if (tdb->global_lock.count && + if (tdb->global_lock.count && (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) { return 0; } @@ -574,7 +574,7 @@ int tdb_unlock(struct tdb_context *tdb, int list, int ltype) } if (ret) - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: An error occurred unlocking!\n")); + TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: An error occurred unlocking!\n")); return ret; } @@ -586,7 +586,7 @@ int tdb_transaction_lock(struct tdb_context *tdb, int ltype) if (tdb->have_transaction_lock || tdb->global_lock.count) { return 0; } - if (tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, ltype, + if (tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, ltype, F_SETLKW, 0, 1) == -1) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_lock: failed to get transaction lock\n")); tdb->ecode = TDB_ERR_LOCK; @@ -635,7 +635,7 @@ static int _tdb_lockall(struct tdb_context *tdb, int ltype, int op) /* a global lock of a different type exists */ return TDB_ERRCODE(TDB_ERR_LOCK, -1); } - + if (tdb->num_locks != 0) { /* can't combine global and chain locks */ return TDB_ERRCODE(TDB_ERR_LOCK, -1); @@ -680,7 +680,7 @@ static int _tdb_unlockall(struct tdb_context *tdb, int ltype) } if (!mark_lock && - tdb->methods->tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, + tdb->methods->tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 4*tdb->header.hash_size)) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlockall failed (%s)\n", strerror(errno))); return -1; @@ -831,7 +831,7 @@ int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off) /* check for an out of bounds access - if it is out of bounds then see if the database has been expanded by someone else and expand - if necessary + if necessary note that "len" is the minimum length needed for the db */ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe) @@ -872,7 +872,7 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe) } /* write a lump of data at a specified offset */ -static int tdb_write(struct tdb_context *tdb, tdb_off_t off, +static int tdb_write(struct tdb_context *tdb, tdb_off_t off, const void *buf, tdb_len_t len) { if (len == 0) { @@ -910,7 +910,7 @@ void *tdb_convert(void *buf, u32 size) /* read a lump of data at a specified offset, maybe convert */ -static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf, +static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf, tdb_len_t len, int cv) { if (tdb->methods->tdb_oob(tdb, off + len, 0) != 0) { @@ -942,7 +942,7 @@ static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf, /* do an unlocked scan of the hash table heads to find the next non-zero head. The value will then be confirmed with the lock held -*/ +*/ static void tdb_next_hash_chain(struct tdb_context *tdb, u32 *chain) { u32 h = *chain; @@ -987,8 +987,8 @@ void tdb_mmap(struct tdb_context *tdb) #ifdef HAVE_MMAP if (!(tdb->flags & TDB_NOMMAP)) { - tdb->map_ptr = mmap(NULL, tdb->map_size, - PROT_READ|(tdb->read_only? 0:PROT_WRITE), + tdb->map_ptr = mmap(NULL, tdb->map_size, + PROT_READ|(tdb->read_only? 0:PROT_WRITE), MAP_SHARED|MAP_FILE, tdb->fd, 0); /* @@ -997,7 +997,7 @@ void tdb_mmap(struct tdb_context *tdb) if (tdb->map_ptr == MAP_FAILED) { tdb->map_ptr = NULL; - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %d (%s)\n", + TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %d (%s)\n", tdb->map_size, strerror(errno))); } } else { @@ -1022,7 +1022,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad if (ftruncate(tdb->fd, size+addition) == -1) { char b = 0; if (pwrite(tdb->fd, &b, 1, (size+addition) - 1) != 1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n", + TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n", size+addition, strerror(errno))); return -1; } @@ -1036,7 +1036,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad int n = addition>sizeof(buf)?sizeof(buf):addition; int ret = pwrite(tdb->fd, buf, n, size); if (ret != n) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of %d failed (%s)\n", + TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of %d failed (%s)\n", n, strerror(errno))); return -1; } @@ -1262,7 +1262,7 @@ void tdb_io_init(struct tdb_context *tdb) - allow for nested calls to tdb_transaction_start(), re-using the existing transaction record. If the inner transaction is cancelled then a subsequent commit will fail - + - keep a mirrored copy of the tdb hash chain heads to allow for the fast hash heads scan on traverse, updating the mirrored copy in the transaction version of tdb_write @@ -1334,7 +1334,7 @@ struct tdb_transaction { read while in a transaction. We need to check first if the data is in our list of transaction elements, then if not do a real read */ -static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, +static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, tdb_len_t len, int cv) { struct tdb_transaction_el *el; @@ -1373,7 +1373,7 @@ static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, len -= partial; off += partial; buf = (void *)(partial + (char *)buf); - + if (len != 0 && transaction_read(tdb, off, buf, len, cv) != 0) { goto fail; } @@ -1395,7 +1395,7 @@ fail: /* write while in a transaction */ -static int transaction_write(struct tdb_context *tdb, tdb_off_t off, +static int transaction_write(struct tdb_context *tdb, tdb_off_t off, const void *buf, tdb_len_t len) { struct tdb_transaction_el *el, *best_el=NULL; @@ -1403,7 +1403,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, if (len == 0) { return 0; } - + /* if the write is to a hash head, then update the transaction hash heads */ if (len == sizeof(tdb_off_t) && off >= FREELIST_TOP && @@ -1447,7 +1447,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, len -= partial; off += partial; buf = (const void *)(partial + (const char *)buf); - + if (len != 0 && transaction_write(tdb, off, buf, len) != 0) { goto fail; } @@ -1456,7 +1456,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, } /* see if we can append the new entry to an existing entry */ - if (best_el && best_el->offset + best_el->length == off && + if (best_el && best_el->offset + best_el->length == off && (off+len < tdb->transaction->old_map_size || off > tdb->transaction->old_map_size)) { unsigned char *data = best_el->data; @@ -1482,7 +1482,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, el = (struct tdb_transaction_el *)malloc(sizeof(*el)); if (el == NULL) { tdb->ecode = TDB_ERR_OOM; - tdb->transaction->transaction_error = 1; + tdb->transaction->transaction_error = 1; return -1; } el->next = NULL; @@ -1493,7 +1493,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, if (el->data == NULL) { free(el); tdb->ecode = TDB_ERR_OOM; - tdb->transaction->transaction_error = 1; + tdb->transaction->transaction_error = 1; return -1; } if (buf) { @@ -1545,7 +1545,7 @@ static int transaction_oob(struct tdb_context *tdb, tdb_off_t len, int probe) /* transaction version of tdb_expand(). */ -static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, +static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t addition) { /* add a write to the transaction elements, so subsequent @@ -1560,7 +1560,7 @@ static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, /* brlock during a transaction - ignore them */ -static int transaction_brlock(struct tdb_context *tdb, tdb_off_t offset, +static int transaction_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len) { return 0; @@ -1592,7 +1592,7 @@ int tdb_transaction_start(struct tdb_context *tdb) /* cope with nested tdb_transaction_start() calls */ if (tdb->transaction != NULL) { tdb->transaction->nesting++; - TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", + TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", tdb->transaction->nesting)); return 0; } @@ -1629,7 +1629,7 @@ int tdb_transaction_start(struct tdb_context *tdb) SAFE_FREE(tdb->transaction); return -1; } - + /* get a read lock from the freelist to the end of file. This is upgraded to a write lock during the commit */ if (tdb_brlock(tdb, FREELIST_TOP, F_RDLCK, F_SETLKW, 0, 0) == -1) { @@ -1665,7 +1665,7 @@ int tdb_transaction_start(struct tdb_context *tdb) /* by calling this transaction write here, we ensure that we don't grow the transaction linked list due to hash table updates */ - if (transaction_write(tdb, FREELIST_TOP, tdb->transaction->hash_heads, + if (transaction_write(tdb, FREELIST_TOP, tdb->transaction->hash_heads, TDB_HASHTABLE_SIZE(tdb)) != 0) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_start: failed to prime hash table\n")); tdb->ecode = TDB_ERR_IO; @@ -1674,7 +1674,7 @@ int tdb_transaction_start(struct tdb_context *tdb) } return 0; - + fail: tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 0); tdb_transaction_unlock(tdb); @@ -1688,7 +1688,7 @@ fail: cancel the current transaction */ int tdb_transaction_cancel(struct tdb_context *tdb) -{ +{ if (tdb->transaction == NULL) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_cancel: no transaction\n")); return -1; @@ -1698,7 +1698,7 @@ int tdb_transaction_cancel(struct tdb_context *tdb) tdb->transaction->transaction_error = 1; tdb->transaction->nesting--; return 0; - } + } tdb->map_size = tdb->transaction->old_map_size; @@ -1735,7 +1735,7 @@ int tdb_transaction_cancel(struct tdb_context *tdb) tdb_transaction_unlock(tdb); SAFE_FREE(tdb->transaction->hash_heads); SAFE_FREE(tdb->transaction); - + return 0; } @@ -1743,7 +1743,7 @@ int tdb_transaction_cancel(struct tdb_context *tdb) sync to disk */ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t length) -{ +{ if (fsync(tdb->fd) != 0) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n")); @@ -1752,7 +1752,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t #ifdef MS_SYNC if (tdb->map_ptr) { tdb_off_t moffset = offset & ~(tdb->page_size-1); - if (msync(moffset + (char *)tdb->map_ptr, + if (msync(moffset + (char *)tdb->map_ptr, length + (offset - moffset), MS_SYNC) != 0) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: msync failed - %s\n", @@ -1788,7 +1788,7 @@ static tdb_len_t tdb_recovery_size(struct tdb_context *tdb) allocate the recovery area, or use an existing recovery area if it is large enough */ -static int tdb_recovery_allocate(struct tdb_context *tdb, +static int tdb_recovery_allocate(struct tdb_context *tdb, tdb_len_t *recovery_size, tdb_off_t *recovery_offset, tdb_len_t *recovery_max_size) @@ -1804,7 +1804,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, rec.rec_len = 0; - if (recovery_head != 0 && + if (recovery_head != 0 && methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to read recovery record\n")); return -1; @@ -1839,7 +1839,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, *recovery_offset = tdb->map_size; recovery_head = *recovery_offset; - if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, + if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, (tdb->map_size - tdb->transaction->old_map_size) + sizeof(rec) + *recovery_max_size) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to create recovery area\n")); @@ -1856,7 +1856,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, /* write the recovery header offset and sync - we can sync without a race here as the magic ptr in the recovery record has not been set */ CONVERT(recovery_head); - if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD, + if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD, &recovery_head, sizeof(tdb_off_t)) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n")); return -1; @@ -1869,7 +1869,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, /* setup the recovery data that will be used on a crash during commit */ -static int transaction_setup_recovery(struct tdb_context *tdb, +static int transaction_setup_recovery(struct tdb_context *tdb, tdb_off_t *magic_offset) { struct tdb_transaction_el *el; @@ -1884,7 +1884,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb, /* check that the recovery area has enough space */ - if (tdb_recovery_allocate(tdb, &recovery_size, + if (tdb_recovery_allocate(tdb, &recovery_size, &recovery_offset, &recovery_max_size) == -1) { return -1; } @@ -1979,7 +1979,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb, commit the current transaction */ int tdb_transaction_commit(struct tdb_context *tdb) -{ +{ const struct tdb_methods *methods; tdb_off_t magic_offset = 0; u32 zero = 0; @@ -1999,7 +1999,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) if (tdb->transaction->nesting != 0) { tdb->transaction->nesting--; return 0; - } + } /* check for a null transaction */ if (tdb->transaction->elements == NULL) { @@ -2008,7 +2008,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) } methods = tdb->transaction->io_methods; - + /* if there are any locks pending then the caller has not nested their locks properly, so fail the transaction */ if (tdb->num_locks || tdb->global_lock.count) { @@ -2047,8 +2047,8 @@ int tdb_transaction_commit(struct tdb_context *tdb) /* expand the file to the new size if needed */ if (tdb->map_size != tdb->transaction->old_map_size) { - if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, - tdb->map_size - + if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, + tdb->map_size - tdb->transaction->old_map_size) == -1) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: expansion failed\n")); @@ -2066,12 +2066,12 @@ int tdb_transaction_commit(struct tdb_context *tdb) if (methods->tdb_write(tdb, el->offset, el->data, el->length) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed during commit\n")); - + /* we've overwritten part of the data and possibly expanded the file, so we need to run the crash recovery code */ tdb->methods = methods; - tdb_transaction_recover(tdb); + tdb_transaction_recover(tdb); tdb_transaction_cancel(tdb); tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1); @@ -2080,9 +2080,9 @@ int tdb_transaction_commit(struct tdb_context *tdb) return -1; } tdb->transaction->elements = el->next; - free(el->data); + free(el->data); free(el); - } + } if (!(tdb->flags & TDB_NOSYNC)) { /* ensure the new data is on disk */ @@ -2151,9 +2151,9 @@ int tdb_transaction_recover(struct tdb_context *tdb) } /* read the recovery record */ - if (tdb->methods->tdb_read(tdb, recovery_head, &rec, + if (tdb->methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n")); + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n")); tdb->ecode = TDB_ERR_IO; return -1; } @@ -2173,7 +2173,7 @@ int tdb_transaction_recover(struct tdb_context *tdb) data = (unsigned char *)malloc(rec.data_len); if (data == NULL) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n")); + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n")); tdb->ecode = TDB_ERR_OOM; return -1; } @@ -2181,7 +2181,7 @@ int tdb_transaction_recover(struct tdb_context *tdb) /* read the full recovery data */ if (tdb->methods->tdb_read(tdb, recovery_head + sizeof(rec), data, rec.data_len, 0) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n")); + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n")); tdb->ecode = TDB_ERR_IO; return -1; } @@ -2218,24 +2218,24 @@ int tdb_transaction_recover(struct tdb_context *tdb) if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &zero) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery head\n")); tdb->ecode = TDB_ERR_IO; - return -1; + return -1; } } /* remove the recovery magic */ - if (tdb_ofs_write(tdb, recovery_head + offsetof(struct list_struct, magic), + if (tdb_ofs_write(tdb, recovery_head + offsetof(struct list_struct, magic), &zero) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery magic\n")); tdb->ecode = TDB_ERR_IO; - return -1; + return -1; } - + /* reduce the file size to the old size */ tdb_munmap(tdb); if (ftruncate(tdb->fd, recovery_eof) != 0) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to reduce to recovery size\n")); tdb->ecode = TDB_ERR_IO; - return -1; + return -1; } tdb->map_size = recovery_eof; tdb_mmap(tdb); @@ -2246,7 +2246,7 @@ int tdb_transaction_recover(struct tdb_context *tdb) return -1; } - TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n", + TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n", recovery_eof)); /* all done */ @@ -2264,7 +2264,7 @@ static int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list if (rec->magic == TDB_MAGIC) { /* this happens when a app is showdown while deleting a record - we should not completely fail when this happens */ - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read non-free magic 0x%x at offset=%d - fixing\n", + TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read non-free magic 0x%x at offset=%d - fixing\n", rec->magic, off)); rec->magic = TDB_FREE_MAGIC; if (tdb->methods->tdb_write(tdb, off, rec, sizeof(*rec)) == -1) @@ -2274,7 +2274,7 @@ static int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list if (rec->magic != TDB_FREE_MAGIC) { /* Ensure ecode is set for log fn. */ tdb->ecode = TDB_ERR_CORRUPT; - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read bad magic 0x%x at offset=%d\n", + TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read bad magic 0x%x at offset=%d\n", rec->magic, off)); return TDB_ERRCODE(TDB_ERR_CORRUPT, -1); } @@ -2359,7 +2359,7 @@ left: if (left > TDB_DATA_START(tdb->header.hash_size)) { struct list_struct l; tdb_off_t leftsize; - + /* Read in tailer and jump back to header */ if (tdb_ofs_read(tdb, left, &leftsize) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left offset read failed at %u\n", left)); @@ -2417,7 +2417,7 @@ update: } -/* +/* the core of tdb_allocate - called when we have decided which free list entry to use */ @@ -2433,22 +2433,22 @@ static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, tdb_len_t length, tdb if (rec->rec_len > length + MIN_REC_SIZE) { /* Length of left piece */ length = TDB_ALIGN(length, TDB_ALIGNMENT); - + /* Right piece to go on free list */ newrec.rec_len = rec->rec_len - (sizeof(*rec) + length); newrec_ptr = rec_ptr + sizeof(*rec) + length; - + /* And left record is shortened */ rec->rec_len = length; } else { newrec_ptr = 0; } - + /* Remove allocated record from the free list */ if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1) { return 0; } - + /* Update header: do this before we drop alloc lock, otherwise tdb_free() might try to merge with us, thinking we're free. @@ -2457,7 +2457,7 @@ static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, tdb_len_t length, tdb if (tdb_rec_write(tdb, rec_ptr, rec) == -1) { return 0; } - + /* Did we create new block? */ if (newrec_ptr) { /* Update allocated record tailer (we @@ -2465,13 +2465,13 @@ static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, tdb_len_t length, tdb if (update_tailer(tdb, rec_ptr, rec) == -1) { return 0; } - + /* Free new record */ if (tdb_free(tdb, newrec_ptr, &newrec) == -1) { return 0; } } - + /* all done - return the new record offset */ return rec_ptr; } @@ -2507,7 +2507,7 @@ tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_st bestfit.last_ptr = 0; bestfit.rec_len = 0; - /* + /* this is a best fit allocation strategy. Originally we used a first fit strategy, but it suffered from massive fragmentation issues when faced with a slowly increasing record size. @@ -2655,7 +2655,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc common for the use of tdb with ldb, where large hashes are used. In that case we spend most of our time in tdb_brlock(), locking empty hash chains. - + To avoid this, we do an unlocked pre-check to see if the hash chain is empty before starting to look inside it. If it is empty then we can avoid that @@ -2663,7 +2663,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc the value we get back, as we read it without a lock, so instead we get the lock and re-fetch the value below. - + Notice that not doing this optimisation on the first hash chain is critical. We must guarantee that we have done at least one fcntl lock at the @@ -2673,7 +2673,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc could possibly miss those with this trick, but we could miss them anyway without this trick, so the semantics don't change. - + With a non-indexed ldb search this trick gains us a factor of around 80 in speed on a linux 2.6.x system (testing using ldbtest). @@ -2727,7 +2727,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc /* Try to clean dead ones from old traverses */ current = tlock->off; tlock->off = rec->next; - if (!(tdb->read_only || tdb->traverse_read) && + if (!(tdb->read_only || tdb->traverse_read) && tdb_do_delete(tdb, current, rec) != 0) goto fail; } @@ -2749,7 +2749,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc if fn is NULL then it is not called a non-zero return value from fn() indicates that the traversal should stop */ -static int tdb_traverse_internal(struct tdb_context *tdb, +static int tdb_traverse_internal(struct tdb_context *tdb, tdb_traverse_func fn, void *private_data, struct tdb_traverse_lock *tl) { @@ -2769,7 +2769,7 @@ static int tdb_traverse_internal(struct tdb_context *tdb, while ((ret = tdb_next_lock(tdb, tl, &rec)) > 0) { count++; /* now read the full record */ - key.dptr = tdb_alloc_read(tdb, tl->off + sizeof(rec), + key.dptr = tdb_alloc_read(tdb, tl->off + sizeof(rec), rec.key_len + rec.data_len); if (!key.dptr) { ret = -1; @@ -2813,7 +2813,7 @@ out: /* a write style traverse - temporarily marks the db read only */ -int tdb_traverse_read(struct tdb_context *tdb, +int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *private_data) { struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK }; @@ -2838,7 +2838,7 @@ int tdb_traverse_read(struct tdb_context *tdb, a write style traverse - needs to get the transaction lock to prevent deadlocks */ -int tdb_traverse(struct tdb_context *tdb, +int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *private_data) { struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK }; @@ -2847,7 +2847,7 @@ int tdb_traverse(struct tdb_context *tdb, if (tdb->read_only || tdb->traverse_read) { return tdb_traverse_read(tdb, fn, private_data); } - + if (tdb_transaction_lock(tdb, F_WRLCK)) { return -1; } @@ -2953,7 +2953,7 @@ static tdb_off_t tdb_dump_record(struct tdb_context *tdb, int hash, struct list_struct rec; tdb_off_t tailer_ofs, tailer; - if (tdb->methods->tdb_read(tdb, offset, (char *)&rec, + if (tdb->methods->tdb_read(tdb, offset, (char *)&rec, sizeof(rec), DOCONV()) == -1) { printf("ERROR: failed to read record at %u\n", offset); return 0; @@ -3030,7 +3030,7 @@ int tdb_printfreelist(struct tdb_context *tdb) printf("freelist top=[0x%08x]\n", rec_ptr ); while (rec_ptr) { - if (tdb->methods->tdb_read(tdb, rec_ptr, (char *)&rec, + if (tdb->methods->tdb_read(tdb, rec_ptr, (char *)&rec, sizeof(rec), DOCONV()) == -1) { tdb_unlock(tdb, -1, F_WRLCK); return -1; @@ -3042,14 +3042,14 @@ int tdb_printfreelist(struct tdb_context *tdb) return -1; } - printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)] (end = 0x%08x)\n", + printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)] (end = 0x%08x)\n", rec_ptr, rec.rec_len, rec.rec_len, rec_ptr + rec.rec_len); total_free += rec.rec_len; /* move to the next record */ rec_ptr = rec.next; } - printf("total rec_len = [0x%08x (%d)]\n", (int)total_free, + printf("total rec_len = [0x%08x (%d)]\n", (int)total_free, (int)total_free); return tdb_unlock(tdb, -1, F_WRLCK); @@ -3066,7 +3066,7 @@ TDB_DATA tdb_null; void tdb_increment_seqnum_nonblock(struct tdb_context *tdb) { tdb_off_t seqnum=0; - + if (!(tdb->flags & TDB_SEQNUM)) { return; } @@ -3109,7 +3109,7 @@ static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, u32 hash, struct list_struct *r) { tdb_off_t rec_ptr; - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) return 0; @@ -3173,7 +3173,7 @@ static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash, TDB_ rec.data_len = dbuf.dsize; return tdb_rec_write(tdb, rec_ptr, &rec); } - + return 0; } @@ -3243,7 +3243,7 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, return ret; } -/* check if an entry in the database exists +/* check if an entry in the database exists note that 1 is returned if the key is found and 0 is returned if not found this doesn't match the conventions in the rest of this module, but is @@ -3252,7 +3252,7 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, static int tdb_exists_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash) { struct list_struct rec; - + if (tdb_find_lock_hash(tdb, key, hash, F_RDLCK, &rec) == 0) return 0; tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK); @@ -3305,7 +3305,7 @@ static int tdb_count_dead(struct tdb_context *tdb, u32 hash) int res = 0; tdb_off_t rec_ptr; struct list_struct rec; - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) return 0; @@ -3334,7 +3334,7 @@ static int tdb_purge_dead(struct tdb_context *tdb, u32 hash) if (tdb_lock(tdb, -1, F_WRLCK) == -1) { return -1; } - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) goto fail; @@ -3426,7 +3426,7 @@ static tdb_off_t tdb_find_dead(struct tdb_context *tdb, u32 hash, struct list_struct *r, tdb_len_t length) { tdb_off_t rec_ptr; - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) return 0; @@ -3449,7 +3449,7 @@ static tdb_off_t tdb_find_dead(struct tdb_context *tdb, u32 hash, } /* store an element in the database, replacing any existing element - with the same key + with the same key return 0 on success, -1 on failure */ @@ -3585,7 +3585,7 @@ int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) tdb_increment_seqnum(tdb); } - SAFE_FREE(p); + SAFE_FREE(p); tdb_unlock(tdb, BUCKET(hash), F_WRLCK); return ret; } @@ -3625,7 +3625,7 @@ int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf) dbuf.dsize += new_dbuf.dsize; ret = tdb_store(tdb, key, dbuf, 0); - + failed: tdb_unlock(tdb, BUCKET(hash), F_WRLCK); SAFE_FREE(dbuf.dptr); @@ -3720,7 +3720,7 @@ static unsigned int default_tdb_hash(TDB_DATA *key) for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++) value = (value + (key->dptr[i] << (i*5 % 24))); - return (1103515243 * value + 12345); + return (1103515243 * value + 12345); } @@ -3774,7 +3774,7 @@ static int tdb_already_open(dev_t device, ino_t ino) { struct tdb_context *i; - + for (i = tdbs; i; i = i->next) { if (i->device == device && i->inode == ino) { return 1; @@ -3784,13 +3784,13 @@ static int tdb_already_open(dev_t device, return 0; } -/* open the database, creating it if necessary +/* open the database, creating it if necessary The open_flags and mode are passed straight to the open call on the database file. A flags value of O_WRONLY is invalid. The hash size is advisory, use zero for a default value. - Return is NULL on error, in which case errno is also set. Don't + Return is NULL on error, in which case errno is also set. Don't try to call tdb_error or tdb_errname, just do strerror(errno). @param name may be NULL for internal databases. */ @@ -3849,7 +3849,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, errno = EINVAL; goto fail; } - + if (hash_size == 0) hash_size = DEFAULT_HASH_SIZE; if ((open_flags & O_ACCMODE) == O_RDONLY) { @@ -3983,7 +3983,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, if (!tdb) return NULL; - + if (tdb->map_ptr) { if (tdb->flags & TDB_INTERNAL) SAFE_FREE(tdb->map_ptr); @@ -4091,7 +4091,7 @@ int tdb_reopen(struct tdb_context *tdb) TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: open failed (%s)\n", strerror(errno))); goto fail; } - if ((tdb->flags & TDB_CLEAR_IF_FIRST) && + if ((tdb->flags & TDB_CLEAR_IF_FIRST) && (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1)) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: failed to obtain active lock\n")); goto fail; diff --git a/lib/ext2fs/tdb.h b/lib/ext2fs/tdb.h index 447d6a16..bfcd9436 100644 --- a/lib/ext2fs/tdb.h +++ b/lib/ext2fs/tdb.h @@ -1,17 +1,17 @@ #ifndef __TDB_H__ #define __TDB_H__ -/* +/* Unix SMB/CIFS implementation. trivial database library Copyright (C) Andrew Tridgell 1999-2004 - + ** NOTE! The following LGPL license applies to the tdb ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -51,12 +51,12 @@ extern "C" { #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) /* error codes */ -enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, +enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY}; /* debugging uses one of the following levels */ -enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, +enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, TDB_DEBUG_WARNING, TDB_DEBUG_TRACE}; typedef struct TDB_DATA { diff --git a/lib/ext2fs/tdbtool.c b/lib/ext2fs/tdbtool.c index 0366cdac..130fc588 100644 --- a/lib/ext2fs/tdbtool.c +++ b/lib/ext2fs/tdbtool.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. Samba database functions Copyright (C) Andrew Tridgell 1999-2000 @@ -10,12 +10,12 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -130,7 +130,7 @@ static void print_data(const char *buf,int len) printf("%02X ",(int)buf[i]); i++; if (i%8 == 0) printf(" "); - if (i%16 == 0) { + if (i%16 == 0) { print_asc(&buf[i-16],8); printf(" "); print_asc(&buf[i-8],8); printf("\n"); if (i<len) printf("[%03X] ",i); @@ -138,18 +138,18 @@ static void print_data(const char *buf,int len) } if (i%16) { int n; - + n = 16 - (i%16); printf(" "); if (n>8) printf(" "); while (n--) printf(" "); - + n = i%16; if (n > 8) n = 8; print_asc(&buf[i-(i%16)],n); printf(" "); n = (i%16) - n; - if (n>0) print_asc(&buf[i-n],n); - printf("\n"); + if (n>0) print_asc(&buf[i-n],n); + printf("\n"); } } @@ -171,7 +171,7 @@ static void help(void) " delete key : delete a record by key\n" " list : print the database hash table and freelist\n" " free : print the database freelist\n" -" ! command : execute system command\n" +" ! command : execute system command\n" " 1 | first : print the first record\n" " n | next : print the next record\n" " q | quit : terminate\n" @@ -266,11 +266,11 @@ static void show_tdb(char *keyname, size_t keylen) terror("fetch failed"); return; } - + print_rec(tdb, key, dbuf, NULL); - + free( dbuf.dptr ); - + return; } @@ -314,23 +314,23 @@ static void move_rec(char *keyname, size_t keylen, char* tdbname) terror("fetch failed"); return; } - + print_rec(tdb, key, dbuf, NULL); - + dst_tdb = tdb_open(tdbname, 0, 0, O_RDWR, 0600); if ( !dst_tdb ) { terror("unable to open destination tdb"); return; } - + if ( tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) == -1 ) { terror("failed to move record"); } else printf("record moved\n"); - + tdb_close( dst_tdb ); - + return; } @@ -399,7 +399,7 @@ static void first_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey) { TDB_DATA dbuf; *pkey = tdb_firstkey(the_tdb); - + dbuf = tdb_fetch(the_tdb, *pkey); if (!dbuf.dptr) terror("fetch failed"); else { @@ -411,9 +411,9 @@ static void next_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey) { TDB_DATA dbuf; *pkey = tdb_nextkey(the_tdb, *pkey); - + dbuf = tdb_fetch(the_tdb, *pkey); - if (!dbuf.dptr) + if (!dbuf.dptr) terror("fetch failed"); else print_rec(the_tdb, *pkey, dbuf, NULL); @@ -536,7 +536,7 @@ static char *convert_string(char *instring, size_t *sizep) size_t length = 0; char *outp, *inp; char temp[3]; - + outp = inp = instring; diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c index c2f5449e..39b39bfb 100644 --- a/lib/ext2fs/test_io.c +++ b/lib/ext2fs/test_io.c @@ -40,7 +40,7 @@ #define EXT2_CHECK_MAGIC(struct, code) \ if ((struct)->magic != (code)) return (code) - + struct test_private_data { int magic; io_channel real; @@ -70,7 +70,7 @@ static errcode_t test_write_blk64(io_channel channel, unsigned long long block, static errcode_t test_flush(io_channel channel); static errcode_t test_write_byte(io_channel channel, unsigned long offset, int count, const void *buf); -static errcode_t test_set_option(io_channel channel, const char *option, +static errcode_t test_set_option(io_channel channel, const char *option, const char *arg); static errcode_t test_get_stats(io_channel channel, io_stats *stats); @@ -232,7 +232,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) data->flags = 0; if ((value = safe_getenv("TEST_IO_FLAGS")) != NULL) data->flags = strtoul(value, NULL, 0); - + data->block = 0; if ((value = safe_getenv("TEST_IO_BLOCK")) != NULL) data->block = strtoul(value, NULL, 0); @@ -244,7 +244,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) data->write_abort_count = 0; if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL) data->write_abort_count = strtoul(value, NULL, 0); - + *channel = io; return 0; @@ -267,13 +267,13 @@ static errcode_t test_close(io_channel channel) if (--channel->refcount > 0) return 0; - + if (data->real) retval = io_channel_close(data->real); if (data->outfile && data->outfile != stderr) fclose(data->outfile); - + ext2fs_free_mem(&channel->private_data); if (channel->name) ext2fs_free_mem(&channel->name); @@ -326,7 +326,7 @@ static errcode_t test_read_blk(io_channel channel, unsigned long block, test_dump_block(channel, data, block, buf); if (--data->read_abort_count == 0) test_abort(channel, block); - } + } return retval; } @@ -380,7 +380,7 @@ static errcode_t test_read_blk64(io_channel channel, unsigned long long block, test_dump_block(channel, data, block, buf); if (--data->read_abort_count == 0) test_abort(channel, block); - } + } return retval; } @@ -439,22 +439,22 @@ static errcode_t test_flush(io_channel channel) { struct test_private_data *data; errcode_t retval = 0; - + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct test_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); if (data->real) retval = io_channel_flush(data->real); - + if (data->flags & TEST_FLAG_FLUSH) fprintf(data->outfile, "Test_io: flush() returned %s\n", retval ? error_message(retval) : "OK"); - + return retval; } -static errcode_t test_set_option(io_channel channel, const char *option, +static errcode_t test_set_option(io_channel channel, const char *option, const char *arg) { struct test_private_data *data; @@ -466,10 +466,10 @@ static errcode_t test_set_option(io_channel channel, const char *option, if (data->flags & TEST_FLAG_SET_OPTION) - fprintf(data->outfile, "Test_io: set_option(%s, %s) ", + fprintf(data->outfile, "Test_io: set_option(%s, %s) ", option, arg); if (data->real && data->real->manager->set_option) { - retval = (data->real->manager->set_option)(data->real, + retval = (data->real->manager->set_option)(data->real, option, arg); if (data->flags & TEST_FLAG_SET_OPTION) fprintf(data->outfile, "returned %s\n", diff --git a/lib/ext2fs/tst_badblocks.c b/lib/ext2fs/tst_badblocks.c index 2453f472..358da209 100644 --- a/lib/ext2fs/tst_badblocks.c +++ b/lib/ext2fs/tst_badblocks.c @@ -2,7 +2,7 @@ * This testing program makes sure the badblocks implementation works. * * Copyright (C) 1996 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -42,7 +42,7 @@ blk_t test4a[] = { 11, 0, 12, 1, 13, 1, - 14, 0, + 14, 0, 80, 0, 45, 0, 66, 1, @@ -60,7 +60,7 @@ blk_t test5a[] = { 1, DEL_BLK, 0 }; - + static int test_fail = 0; static int test_expected_fail = 0; @@ -70,7 +70,7 @@ static errcode_t create_test_list(blk_t *vec, badblocks_list *ret) errcode_t retval; badblocks_list bb; int i; - + retval = ext2fs_badblocks_list_create(&bb, 5); if (retval) { com_err("create_test_list", retval, "while creating list"); @@ -95,7 +95,7 @@ static void print_list(badblocks_list bb, int verify) badblocks_iterate iter; blk_t blk; int i, ok; - + retval = ext2fs_badblocks_list_iterate_begin(bb, &iter); if (retval) { com_err("print_list", retval, "while setting up iterator"); @@ -156,7 +156,7 @@ static void do_test_seq(badblocks_list bb, blk_t *vec) ext2fs_badblocks_list_del(bb, vec[i]); match = ext2fs_badblocks_list_test(bb, vec[i]); printf("Removing block %u --- now %s\n", vec[i], - ext2fs_badblocks_list_test(bb, vec[i]) ? + ext2fs_badblocks_list_test(bb, vec[i]) ? "present" : "absent"); if (match) { printf("FAILURE!\n"); @@ -254,7 +254,7 @@ int file_test_invalid(badblocks_list bb) printf("Expected test failure didn't happen!\n"); test_fail++; } - + if (ext2fs_badblocks_equal(bb, new_bb)) { printf("Block bitmap matched after reading and writing.\n"); @@ -278,7 +278,7 @@ int main(int argc, char **argv) if (retval == 0) print_list(bb1, 1); printf("\n"); - + printf("test2: "); retval = create_test_list(test2, &bb2); if (retval == 0) @@ -290,7 +290,7 @@ int main(int argc, char **argv) if (retval == 0) print_list(bb3, 1); printf("\n"); - + printf("test4: "); retval = create_test_list(test4, &bb4); if (retval == 0) { @@ -315,31 +315,31 @@ int main(int argc, char **argv) if (bb1 && bb2 && bb3 && bb4 && bb5) { printf("Comparison tests:\n"); equal = ext2fs_badblocks_equal(bb1, bb2); - printf("bb1 and bb2 are %sequal.\n", equal ? "" : "NOT "); + printf("bb1 and bb2 are %sequal.\n", equal ? "" : "NOT "); if (equal) test_fail++; equal = ext2fs_badblocks_equal(bb1, bb3); - printf("bb1 and bb3 are %sequal.\n", equal ? "" : "NOT "); + printf("bb1 and bb3 are %sequal.\n", equal ? "" : "NOT "); if (!equal) test_fail++; - + equal = ext2fs_badblocks_equal(bb1, bb4); - printf("bb1 and bb4 are %sequal.\n", equal ? "" : "NOT "); + printf("bb1 and bb4 are %sequal.\n", equal ? "" : "NOT "); if (equal) test_fail++; equal = ext2fs_badblocks_equal(bb4, bb5); - printf("bb4 and bb5 are %sequal.\n", equal ? "" : "NOT "); + printf("bb4 and bb5 are %sequal.\n", equal ? "" : "NOT "); if (!equal) test_fail++; printf("\n"); } - + file_test(bb4); file_test_invalid(bb4); - + if (test_fail == 0) printf("ext2fs library badblocks tests checks out OK!\n"); diff --git a/lib/ext2fs/tst_bitops.c b/lib/ext2fs/tst_bitops.c index eede295b..6febe685 100644 --- a/lib/ext2fs/tst_bitops.c +++ b/lib/ext2fs/tst_bitops.c @@ -2,7 +2,7 @@ * This testing program makes sure the bitops functions work * * Copyright (C) 2001 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -97,7 +97,7 @@ int main(int argc, char **argv) } } printf("ext2fs_clear_bit test succeed.\n"); - + /* Do bigarray test */ bigarray = malloc(1 << 29); @@ -150,7 +150,7 @@ int main(int argc, char **argv) } } printf("ext2fs_clear_bit test succeed.\n"); - + bigarray[BIG_TEST_BIT >> 3] = 0; diff --git a/lib/ext2fs/tst_byteswap.c b/lib/ext2fs/tst_byteswap.c index d73fb419..ba79c7c6 100644 --- a/lib/ext2fs/tst_byteswap.c +++ b/lib/ext2fs/tst_byteswap.c @@ -2,7 +2,7 @@ * This testing program makes sure the byteswap functions work * * Copyright (C) 2000 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -66,7 +66,7 @@ int main(int argc, char **argv) } i += 2; } while (test1[i] != 0); - + printf("Testing ext2fs_swab32\n"); i = 0; do { @@ -87,6 +87,6 @@ int main(int argc, char **argv) if (!errors) printf("No errors found in the byteswap implementation!\n"); - + return errors; } diff --git a/lib/ext2fs/tst_getsectsize.c b/lib/ext2fs/tst_getsectsize.c index 9967b615..cb1b8c65 100644 --- a/lib/ext2fs/tst_getsectsize.c +++ b/lib/ext2fs/tst_getsectsize.c @@ -1,8 +1,8 @@ /* * tst_getsize.c --- this function tests the getsize function - * + * * Copyright (C) 1997 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -29,7 +29,7 @@ int main(int argc, char **argv) { int sectsize; int retval; - + if (argc < 2) { fprintf(stderr, "Usage: %s device\n", argv[0]); exit(1); diff --git a/lib/ext2fs/tst_getsize.c b/lib/ext2fs/tst_getsize.c index 17f900cc..f9fc9d73 100644 --- a/lib/ext2fs/tst_getsize.c +++ b/lib/ext2fs/tst_getsize.c @@ -1,8 +1,8 @@ /* * tst_getsize.c --- this function tests the getsize function - * + * * Copyright (C) 1997 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. diff --git a/lib/ext2fs/tst_iscan.c b/lib/ext2fs/tst_iscan.c index d7fdc12d..b0c7fc30 100644 --- a/lib/ext2fs/tst_iscan.c +++ b/lib/ext2fs/tst_iscan.c @@ -1,8 +1,8 @@ /* * tst_inode.c --- this function tests the inode scan function - * + * * Copyright (C) 1996 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -75,7 +75,7 @@ static void setup(void) test_io_cb_read_blk = test_read_blk; - + retval = ext2fs_initialize("test fs", 0, ¶m, test_io_manager, &test_fs); if (retval) { @@ -110,7 +110,7 @@ static void setup(void) "While allocating bad inode bitmap"); exit(1); } - + retval = ext2fs_badblocks_list_create(&test_badblocks, 5); if (retval) { com_err("setup", retval, "while creating badblocks list"); diff --git a/lib/ext2fs/tst_super_size.c b/lib/ext2fs/tst_super_size.c index 476b1a6e..47fa5bac 100644 --- a/lib/ext2fs/tst_super_size.c +++ b/lib/ext2fs/tst_super_size.c @@ -2,7 +2,7 @@ * This testing program makes sure superblock size is 1024 bytes long * * Copyright (C) 2007 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -25,4 +25,4 @@ int main(int argc, char **argv) } exit(0); } - + diff --git a/lib/ext2fs/tst_types.c b/lib/ext2fs/tst_types.c index 78de7bcf..fbe35dcb 100644 --- a/lib/ext2fs/tst_types.c +++ b/lib/ext2fs/tst_types.c @@ -2,7 +2,7 @@ * This testing program makes sure the ext2_types header file * * Copyright (C) 2006 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index eedbcdb3..d77e59db 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -4,7 +4,7 @@ * * Implements a one-block write-through cache. * - * Includes support for Windows NT support under Cygwin. + * Includes support for Windows NT support under Cygwin. * * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, * 2002 by Theodore Ts'o. @@ -83,7 +83,7 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, static errcode_t unix_flush(io_channel channel); static errcode_t unix_write_byte(io_channel channel, unsigned long offset, int size, const void *data); -static errcode_t unix_set_option(io_channel channel, const char *option, +static errcode_t unix_set_option(io_channel channel, const char *option, const char *arg); static errcode_t unix_get_stats(io_channel channel, io_stats *stats) ; @@ -169,7 +169,7 @@ static errcode_t raw_read_blk(io_channel channel, goto error_out; } return 0; - + error_out: memset((char *) buf+actual, 0, size-actual); if (channel->read_error) @@ -258,14 +258,14 @@ static errcode_t raw_write_blk(io_channel channel, retval = errno ? errno : EXT2_ET_LLSEEK_FAILED; goto error_out; } - + actual = write(data->dev, buf, size); if (actual != size) { retval = EXT2_ET_SHORT_WRITE; goto error_out; } return 0; - + error_out: if (channel->write_error) retval = (channel->write_error)(channel, block, count, buf, @@ -285,7 +285,7 @@ static errcode_t alloc_cache(io_channel channel, errcode_t retval; struct unix_cache *cache; int i; - + data->access_time = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { cache->block = 0; @@ -304,7 +304,7 @@ static void free_cache(struct unix_private_data *data) { struct unix_cache *cache; int i; - + data->access_time = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { cache->block = 0; @@ -329,7 +329,7 @@ static struct unix_cache *find_cached_block(struct unix_private_data *data, { struct unix_cache *cache, *unused_cache, *oldest_cache; int i; - + unused_cache = oldest_cache = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { if (!cache->in_use) { @@ -376,18 +376,18 @@ static errcode_t flush_cached_blocks(io_channel channel, struct unix_cache *cache; errcode_t retval, retval2; int i; - + retval2 = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { if (!cache->in_use) continue; - + if (invalidate) cache->in_use = 0; - + if (!cache->dirty) continue; - + retval = raw_write_blk(channel, data, cache->block, 1, cache->buf); if (retval) @@ -465,7 +465,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) * block devices are wrongly getting hit by the filesize * limit. This workaround isn't perfect, since it won't work * if glibc wasn't built against 2.2 header files. (Sigh.) - * + * */ if ((flags & IO_FLAG_RW) && (uname(&ut) == 0) && @@ -476,7 +476,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) (fstat(data->dev, &st) == 0) && (S_ISBLK(st.st_mode))) { struct rlimit rlim; - + rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY; setrlimit(RLIMIT_FSIZE, &rlim); getrlimit(RLIMIT_FSIZE, &rlim); @@ -541,7 +541,7 @@ static errcode_t unix_set_blksize(io_channel channel, int blksize) if ((retval = flush_cached_blocks(channel, data, 0))) return retval; #endif - + channel->block_size = blksize; free_cache(data); if ((retval = alloc_cache(channel, data))) @@ -602,7 +602,7 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block, #endif if ((retval = raw_read_blk(channel, data, block, i, cp))) return retval; - + /* Save the results in the cache */ for (j=0; j < i; j++) { count--; @@ -637,7 +637,7 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block, #ifdef NO_IO_CACHE return raw_write_blk(channel, data, block, count, buf); -#else +#else /* * If we're doing an odd-sized write or a very large write, * flush out the cache completely and then do a direct write. @@ -656,7 +656,7 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block, writethrough = channel->flags & CHANNEL_FLAGS_WRITETHROUGH; if (writethrough) retval = raw_write_blk(channel, data, block, count, buf); - + cp = buf; while (count > 0) { cache = find_cached_block(data, block, &reuse); @@ -701,7 +701,7 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset, if (lseek(data->dev, offset + data->offset, SEEK_SET) < 0) return errno; - + actual = write(data->dev, buf, size); if (actual != size) return EXT2_ET_SHORT_WRITE; @@ -710,13 +710,13 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset, } /* - * Flush data buffers to disk. + * Flush data buffers to disk. */ static errcode_t unix_flush(io_channel channel) { struct unix_private_data *data; errcode_t retval = 0; - + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct unix_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); @@ -728,7 +728,7 @@ static errcode_t unix_flush(io_channel channel) return retval; } -static errcode_t unix_set_option(io_channel channel, const char *option, +static errcode_t unix_set_option(io_channel channel, const char *option, const char *arg) { struct unix_private_data *data; diff --git a/lib/ext2fs/unlink.c b/lib/ext2fs/unlink.c index a48b8775..ffe8dbe9 100644 --- a/lib/ext2fs/unlink.c +++ b/lib/ext2fs/unlink.c @@ -1,6 +1,6 @@ /* * unlink.c --- delete links in a ext2fs directory - * + * * Copyright (C) 1993, 1994, 1997 Theodore Ts'o. * * %Begin-Header% @@ -25,7 +25,7 @@ struct link_struct { int flags; struct ext2_dir_entry *prev; int done; -}; +}; #ifdef __TURBOC__ #pragma argsused @@ -89,7 +89,7 @@ errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, ls.done = 0; ls.prev = 0; - retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY, + retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY, 0, unlink_proc, &ls); if (retval) return retval; diff --git a/lib/ext2fs/valid_blk.c b/lib/ext2fs/valid_blk.c index 29ff27a7..d0367e71 100644 --- a/lib/ext2fs/valid_blk.c +++ b/lib/ext2fs/valid_blk.c @@ -2,12 +2,12 @@ * valid_blk.c --- does the inode have valid blocks? * * Copyright 1997 by Theodore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -33,7 +33,7 @@ int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode) if (!LINUX_S_ISDIR(inode->i_mode) && !LINUX_S_ISREG(inode->i_mode) && !LINUX_S_ISLNK(inode->i_mode)) return 0; - + /* * If the symbolic link is a "fast symlink", then the symlink * target is stored in the block entries. diff --git a/lib/fpopen.c b/lib/fpopen.c index 47346e1d..0df25e4e 100644 --- a/lib/fpopen.c +++ b/lib/fpopen.c @@ -46,7 +46,7 @@ FILE *fpopen(const char *cmd, const char *mode) errno = EFAULT; return NULL; } - + switch (*mode) { case 'r': do_stdin = 0; @@ -91,7 +91,7 @@ FILE *fpopen(const char *cmd, const char *mode) */ if (pipe(fds) < 0) return NULL; - + /* Fork and execute the correct program. */ if ((pid = fork()) < 0) { perror("fork"); diff --git a/lib/ss/error.c b/lib/ss/error.c index 14c0570f..9a4b5269 100644 --- a/lib/ss/error.c +++ b/lib/ss/error.c @@ -18,13 +18,13 @@ #include "ss_internal.h" #include <stdarg.h> - + char * ss_name(sci_idx) int sci_idx; { register char *ret_val; register ss_data *infop; - + infop = ss_info(sci_idx); if (infop->current_request == (char const *)NULL) { ret_val = malloc((unsigned) @@ -38,7 +38,7 @@ char * ss_name(sci_idx) else { register char *cp; register char const *cp1; - ret_val = malloc((unsigned)sizeof(char) * + ret_val = malloc((unsigned)sizeof(char) * (strlen(infop->subsystem_name)+ strlen(infop->current_request)+ 4)); diff --git a/lib/ss/get_readline.c b/lib/ss/get_readline.c index 70099b09..16679a30 100644 --- a/lib/ss/get_readline.c +++ b/lib/ss/get_readline.c @@ -25,7 +25,7 @@ static void ss_release_readline(ss_data *info) #ifdef HAVE_DLOPEN if (!info->readline_handle) return; - + info->readline = 0; info->add_history = 0; info->redisplay = 0; @@ -46,7 +46,7 @@ void ss_get_readline(int sci_idx) const char **t, *libpath = 0; char *tmp, *cp, *next; char **(**completion_func)(const char *, int, int); - + if (info->readline_handle) return; @@ -55,7 +55,7 @@ void ss_get_readline(int sci_idx) libpath = DEFAULT_LIBPATH; if (*libpath == 0 || !strcmp(libpath, "none")) return; - + tmp = malloc(strlen(libpath)+1); if (!tmp) return; @@ -94,4 +94,4 @@ void ss_get_readline(int sci_idx) #endif } - + diff --git a/lib/ss/listen.c b/lib/ss/listen.c index 05d0dc06..bd7c8c09 100644 --- a/lib/ss/listen.c +++ b/lib/ss/listen.c @@ -3,7 +3,7 @@ * * $Header$ * $Locker$ - * + * * Copyright 1987, 1988 by MIT Student Information Processing Board * * Permission to use, copy, modify, and distribute this software and @@ -56,7 +56,7 @@ int ss_listen (int sci_idx) jmp_buf old_jmpb; ss_data *old_info = current_info; char *line; - + current_info = info = ss_info(sci_idx); sig_cont = (sigret_t (*)(int)) 0; info->abort = 0; @@ -81,7 +81,7 @@ int ss_listen (int sci_idx) line = input; else line = NULL; - + input[BUFSIZ-1] = 0; } if (line == NULL) { @@ -89,7 +89,7 @@ int ss_listen (int sci_idx) (void) signal(SIGCONT, sig_cont); goto egress; } - + cp = strchr(line, '\n'); if (cp) { *cp = '\0'; @@ -130,11 +130,11 @@ void ss_abort_subsystem(int sci_idx, int code) { ss_info(sci_idx)->abort = 1; ss_info(sci_idx)->exit_status = code; - + } -void ss_quit(int argc __SS_ATTR((unused)), - const char * const *argv __SS_ATTR((unused)), +void ss_quit(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), int sci_idx, pointer infop __SS_ATTR((unused))) { ss_abort_subsystem(sci_idx, 0); @@ -151,7 +151,7 @@ static char *cmd_generator(const char *text, int state) static char const * const * name; ss_request_entry *request; char *ret; - + if (state == 0) { len = strlen(text); rqtbl = current_info->rqt_tables; @@ -187,7 +187,7 @@ static char *cmd_generator(const char *text, int state) return 0; } -char **ss_rl_completion(const char *text, int start, +char **ss_rl_completion(const char *text, int start, int end __SS_ATTR((unused))) { if ((start == 0) && current_info->rl_completion_matches) diff --git a/lib/ss/pager.c b/lib/ss/pager.c index a7a2a092..ca05519c 100644 --- a/lib/ss/pager.c +++ b/lib/ss/pager.c @@ -71,10 +71,10 @@ char *ss_safe_getenv(const char *arg) */ #ifndef NO_FORK -int ss_pager_create(void) +int ss_pager_create(void) { int filedes[2]; - + if (pipe(filedes) != 0) return(-1); @@ -110,7 +110,7 @@ void ss_page_stdin() { int i; sigset_t mask; - + for (i = 3; i < 32; i++) (void) close(i); (void) signal(SIGINT, SIG_DFL); diff --git a/lib/ss/requests.c b/lib/ss/requests.c index 80133688..2e061000 100644 --- a/lib/ss/requests.c +++ b/lib/ss/requests.c @@ -18,7 +18,7 @@ #define DECLARE(name) void name(int argc,const char * const *argv, \ int sci_idx, void *infop) - + /* * ss_self_identify -- assigned by default to the "." request */ @@ -36,7 +36,7 @@ void ss_self_identify(int argc __SS_ATTR((unused)), */ void ss_subsystem_name(int argc __SS_ATTR((unused)), const char * const *argv __SS_ATTR((unused)), - int sci_idx, + int sci_idx, void *infop __SS_ATTR((unused))) { printf("%s\n", ss_info(sci_idx)->subsystem_name); @@ -47,7 +47,7 @@ void ss_subsystem_name(int argc __SS_ATTR((unused)), */ void ss_subsystem_version(int argc __SS_ATTR((unused)), const char * const *argv __SS_ATTR((unused)), - int sci_idx, + int sci_idx, void *infop __SS_ATTR((unused))) { printf("%s\n", ss_info(sci_idx)->subsystem_version); diff --git a/lib/ss/test_ss.c b/lib/ss/test_ss.c index 36e899d3..aba7cbcd 100644 --- a/lib/ss/test_ss.c +++ b/lib/ss/test_ss.c @@ -1,6 +1,6 @@ /* * test_ss.c - * + * * Copyright 1987, 1988 by MIT Student Information Processing Board * * Permission to use, copy, modify, and distribute this software and @@ -11,7 +11,7 @@ * M.I.T. S.I.P.B. make no representations about the suitability of * this software for any purpose. It is provided "as is" without * express or implied warranty. - + */ #include <unistd.h> diff --git a/lib/uuid/clear.c b/lib/uuid/clear.c index f3a1005b..2d91fee9 100644 --- a/lib/uuid/clear.c +++ b/lib/uuid/clear.c @@ -1,6 +1,6 @@ /* * clear.c -- Clear a UUID - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/compare.c b/lib/uuid/compare.c index a9c505c7..f28a7267 100644 --- a/lib/uuid/compare.c +++ b/lib/uuid/compare.c @@ -2,7 +2,7 @@ * compare.c --- compare whether or not two UUID's are the same * * Returns 0 if the two UUID's are different, and 1 if they are the same. - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -18,7 +18,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/copy.c b/lib/uuid/copy.c index 963bc818..ead33aa2 100644 --- a/lib/uuid/copy.c +++ b/lib/uuid/copy.c @@ -1,6 +1,6 @@ /* * copy.c --- copy UUIDs - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index 152a6c09..a3052d4b 100644 --- a/lib/uuid/gen_uuid.c +++ b/lib/uuid/gen_uuid.c @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -144,7 +144,7 @@ static int get_random_fd(void) fd = open("/dev/random", O_RDONLY | O_NONBLOCK); if (fd >= 0) { i = fcntl(fd, F_GETFD); - if (i >= 0) + if (i >= 0) fcntl(fd, F_SETFD, i | FD_CLOEXEC); } #endif @@ -187,7 +187,7 @@ static void get_random_bytes(void *buf, int nbytes) lose_counter = 0; } } - + /* * We do this all the time, but this is the only source of * randomness if /dev/random/urandom is out to lunch. @@ -199,7 +199,7 @@ static void get_random_bytes(void *buf, int nbytes) jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid); for (cp = buf, i = 0; i < nbytes; i++) *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF; - memcpy(jrand_seed, tmp_seed, + memcpy(jrand_seed, tmp_seed, sizeof(jrand_seed)-sizeof(unsigned short)); #endif @@ -230,7 +230,7 @@ static int get_node_id(unsigned char *node_id) /* * BSD 4.4 defines the size of an ifreq to be * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len - * However, under earlier systems, sa_len isn't present, so the size is + * However, under earlier systems, sa_len isn't present, so the size is * just sizeof(struct ifreq) */ #ifdef HAVE_SA_LEN @@ -377,7 +377,7 @@ try_again: adjustment = 0; last = tv; } - + clock_reg = tv.tv_usec*10 + adjustment; clock_reg += ((uint64_t) tv.tv_sec)*10000000; clock_reg += (((uint64_t) 0x01B21DD2) << 32) + 0x13814000; @@ -459,7 +459,7 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num) access_ret = access(uuidd_path, X_OK); if (access_ret == 0 && start_attempts++ < 5) { if ((pid = fork()) == 0) { - execl(uuidd_path, "uuidd", "-qT", "300", + execl(uuidd_path, "uuidd", "-qT", "300", (char *) NULL); exit(1); } diff --git a/lib/uuid/isnull.c b/lib/uuid/isnull.c index 54a83003..931e7e7d 100644 --- a/lib/uuid/isnull.c +++ b/lib/uuid/isnull.c @@ -1,6 +1,6 @@ /* * isnull.c --- Check whether or not the UUID is null - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/pack.c b/lib/uuid/pack.c index 348d4321..097516d2 100644 --- a/lib/uuid/pack.c +++ b/lib/uuid/pack.c @@ -1,6 +1,6 @@ /* * Internal routine for packing UUID's - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -48,7 +48,7 @@ void uuid_pack(const struct uuid *uu, uuid_t ptr) out[1] = (unsigned char) tmp; tmp >>= 8; out[0] = (unsigned char) tmp; - + tmp = uu->time_mid; out[5] = (unsigned char) tmp; tmp >>= 8; diff --git a/lib/uuid/parse.c b/lib/uuid/parse.c index 07b894d1..074383ef 100644 --- a/lib/uuid/parse.c +++ b/lib/uuid/parse.c @@ -1,6 +1,6 @@ /* * parse.c --- UUID parsing - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -73,7 +73,7 @@ int uuid_parse(const char *in, uuid_t uu) buf[1] = *cp++; uuid.node[i] = strtoul(buf, NULL, 16); } - + uuid_pack(&uuid, uu); return 0; } diff --git a/lib/uuid/tst_uuid.c b/lib/uuid/tst_uuid.c index 01606d7c..e03138f7 100644 --- a/lib/uuid/tst_uuid.c +++ b/lib/uuid/tst_uuid.c @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/unpack.c b/lib/uuid/unpack.c index 9502fc2a..beaaff3c 100644 --- a/lib/uuid/unpack.c +++ b/lib/uuid/unpack.c @@ -1,6 +1,6 @@ /* * Internal routine for unpacking UUID - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -49,7 +49,7 @@ void uuid_unpack(const uuid_t in, struct uuid *uu) tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_mid = tmp; - + tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_hi_and_version = tmp; diff --git a/lib/uuid/unparse.c b/lib/uuid/unparse.c index c0e08ef4..a95bbb04 100644 --- a/lib/uuid/unparse.c +++ b/lib/uuid/unparse.c @@ -1,6 +1,6 @@ /* * unparse.c -- convert a UUID to string - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -36,10 +36,10 @@ #include "uuidP.h" -static const char *fmt_lower = +static const char *fmt_lower = "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"; -static const char *fmt_upper = +static const char *fmt_upper = "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"; #ifdef UUID_UNPARSE_DEFAULT_UPPER diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h index 1c241e3e..ca846da0 100644 --- a/lib/uuid/uuid.h +++ b/lib/uuid/uuid.h @@ -1,6 +1,6 @@ /* * Public include file for the UUID library - * + * * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/uuidP.h b/lib/uuid/uuidP.h index adf233da..d0e24c69 100644 --- a/lib/uuid/uuidP.h +++ b/lib/uuid/uuidP.h @@ -1,6 +1,6 @@ /* * uuid.h -- private header file for uuids - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/uuid_time.c b/lib/uuid/uuid_time.c index fc1d2665..f25f5c90 100644 --- a/lib/uuid/uuid_time.c +++ b/lib/uuid/uuid_time.c @@ -2,7 +2,7 @@ * uuid_time.c --- Interpret the time field from a uuid. This program * violates the UUID abstraction barrier by reaching into the guts * of a UUID and interpreting it. - * + * * Copyright (C) 1998, 1999 Theodore Ts'o. * * %Begin-Header% @@ -18,7 +18,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -61,7 +61,7 @@ time_t uuid_time(const uuid_t uu, struct timeval *ret_tv) uint64_t clock_reg; uuid_unpack(uu, &uuid); - + high = uuid.time_mid | ((uuid.time_hi_and_version & 0xFFF) << 16); clock_reg = uuid.time_low | ((uint64_t) high << 32); @@ -79,7 +79,7 @@ int uuid_type(const uuid_t uu) { struct uuid uuid; - uuid_unpack(uu, &uuid); + uuid_unpack(uu, &uuid); return ((uuid.time_hi_and_version >> 12) & 0xF); } @@ -88,7 +88,7 @@ int uuid_variant(const uuid_t uu) struct uuid uuid; int var; - uuid_unpack(uu, &uuid); + uuid_unpack(uu, &uuid); var = uuid.clock_seq; if ((var & 0x8000) == 0) @@ -115,7 +115,7 @@ static const char *variant_string(int variant) } } - + int main(int argc, char **argv) { @@ -165,7 +165,7 @@ main(int argc, char **argv) } printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec, ctime(&time_reg)); - + return 0; } #endif diff --git a/misc/badblocks.c b/misc/badblocks.c index ef6ab5b2..6261cbea 100644 --- a/misc/badblocks.c +++ b/misc/badblocks.c @@ -10,7 +10,7 @@ * * This file is based on the minix file system programs fsck and mkfs * written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi> - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -24,7 +24,7 @@ * 99/06/30...99/07/26 - Added non-destructive write-testing, * configurable blocks-at-once parameter, * loading of badblocks list to avoid testing - * blocks known to be bad, multiple passes to + * blocks known to be bad, multiple passes to * make sure that no new blocks are added to the * list. (Work done by David Beattie) */ @@ -92,8 +92,8 @@ static void usage(void) static void exclusive_usage(void) { - fprintf(stderr, - _("%s: The -n and -w options are mutually exclusive.\n\n"), + fprintf(stderr, + _("%s: The -n and -w options are mutually exclusive.\n\n"), program_name); exit(1); } @@ -108,7 +108,7 @@ static ext2_badblocks_iterate bb_iter = NULL; static void *allocate_buffer(size_t size) { void *ret = 0; - + #ifdef HAVE_POSIX_MEMALIGN if (posix_memalign(&ret, sys_page_size, size) < 0) ret = 0; @@ -119,7 +119,7 @@ static void *allocate_buffer(size_t size) #ifdef HAVE_VALLOC ret = valloc(size); #endif /* HAVE_VALLOC */ -#endif /* HAVE_MEMALIGN */ +#endif /* HAVE_MEMALIGN */ #endif /* HAVE_POSIX_MEMALIGN */ if (!ret) @@ -149,7 +149,7 @@ static int bb_output (blk_t bad) } /* kludge: - increment the iteration through the bb_list if + increment the iteration through the bb_list if an element was just added before the current iteration position. This should not cause next_bad to change. */ if (bb_iter && bad < next_bad) @@ -159,7 +159,7 @@ static int bb_output (blk_t bad) static void print_status(void) { - fprintf(stderr, "%15lu/%15lu", (unsigned long) currently_testing, + fprintf(stderr, "%15lu/%15lu", (unsigned long) currently_testing, (unsigned long) num_blocks); fputs("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", stderr); fflush (stderr); @@ -211,7 +211,7 @@ static void set_o_direct(int dev, unsigned char *buffer, size_t size, #ifdef O_DIRECT int new_flag = O_DIRECT; int flag; - + if ((((unsigned long) buffer & (sys_page_size - 1)) != 0) || ((size & (sys_page_size - 1)) != 0) || ((current_block & ((sys_page_size >> 9)-1)) != 0)) @@ -235,7 +235,7 @@ static void pattern_fill(unsigned char *buffer, unsigned int pattern, { unsigned int i, nb; unsigned char bpattern[sizeof(pattern)], *ptr; - + if (pattern == (unsigned int) ~0) { for (ptr = buffer; ptr < buffer + n; ptr++) { (*ptr) = random() % (1 << (8 * sizeof(char))); @@ -296,7 +296,7 @@ static int do_read (int dev, unsigned char * buffer, int try, int block_size, if (d_flag) gettimeofday(&tv2, NULL); if (got < 0) - got = 0; + got = 0; if (got & 511) fprintf(stderr, _("Weird value (%ld) in do_read\n"), got); got /= block_size; @@ -361,7 +361,7 @@ static int do_write(int dev, unsigned char * buffer, int try, int block_size, /* Try the write */ got = write (dev, buffer, try * block_size); if (got < 0) - got = 0; + got = 0; if (got & 511) fprintf(stderr, "Weird value (%ld) in do_write\n", got); got /= block_size; @@ -410,8 +410,8 @@ static unsigned int test_ro (int dev, blk_t last_block, exit (1); } if (v_flag) { - fprintf (stderr, _("Checking blocks %lu to %lu\n"), - (unsigned long) first_block, + fprintf (stderr, _("Checking blocks %lu to %lu\n"), + (unsigned long) first_block, (unsigned long) last_block - 1); } if (t_flag) { @@ -466,7 +466,7 @@ static unsigned int test_ro (int dev, blk_t last_block, if ( (blocks_at_once >= sys_page_size >> 9) && (currently_testing % (sys_page_size >> 9)!= 0)) try -= (sys_page_size >> 9) - - (currently_testing + - (currently_testing % (sys_page_size >> 9)); continue; } @@ -501,7 +501,7 @@ static unsigned int test_rw (int dev, blk_t last_block, buffer = allocate_buffer(2 * blocks_at_once * block_size); read_buffer = buffer + blocks_at_once * block_size; - + if (!buffer) { com_err (program_name, ENOMEM, _("while allocating buffers")); exit (1); @@ -510,10 +510,10 @@ static unsigned int test_rw (int dev, blk_t last_block, flush_bufs(); if (v_flag) { - fputs(_("Checking for bad blocks in read-write mode\n"), + fputs(_("Checking for bad blocks in read-write mode\n"), stderr); fprintf(stderr, _("From block %lu to %lu\n"), - (unsigned long) first_block, + (unsigned long) first_block, (unsigned long) last_block - 1); } if (t_flag) { @@ -551,10 +551,10 @@ static unsigned int test_rw (int dev, blk_t last_block, try = blocks_at_once; /* recover page-aligned offset for O_DIRECT */ if ( (blocks_at_once >= sys_page_size >> 9) - && (currently_testing % + && (currently_testing % (sys_page_size >> 9)!= 0)) try -= (sys_page_size >> 9) - - (currently_testing + - (currently_testing % (sys_page_size >> 9)); continue; } else @@ -563,7 +563,7 @@ static unsigned int test_rw (int dev, blk_t last_block, bb_count += bb_output(currently_testing++); } } - + num_blocks = 0; alarm (0); if (s_flag | v_flag) @@ -603,14 +603,14 @@ static unsigned int test_rw (int dev, blk_t last_block, if ( (blocks_at_once >= sys_page_size >> 9) && (currently_testing % (sys_page_size >> 9)!= 0)) try = blocks_at_once - (sys_page_size >> 9) - - (currently_testing + - (currently_testing % (sys_page_size >> 9)); else try = blocks_at_once; if (v_flag > 1) print_status(); } - + num_blocks = 0; alarm (0); if (s_flag | v_flag) @@ -668,13 +668,13 @@ static unsigned int test_nd (int dev, blk_t last_block, save_base = blkbuf; test_base = blkbuf + (blocks_at_once * block_size); read_base = blkbuf + (2 * blocks_at_once * block_size); - + num_saved = 0; flush_bufs(); if (v_flag) { fputs(_("Checking for bad blocks in non-destructive read-write mode\n"), stderr); - fprintf (stderr, _("From block %lu to %lu\n"), + fprintf (stderr, _("From block %lu to %lu\n"), (unsigned long) first_block, (unsigned long) last_block - 1); } @@ -697,7 +697,7 @@ static unsigned int test_nd (int dev, blk_t last_block, fflush (out); exit(1); } - + /* set up abend handler */ capture_terminate(terminate_env); @@ -763,7 +763,7 @@ static unsigned int test_nd (int dev, blk_t last_block, if (written != got) com_err (program_name, errno, _("during test data write, block %lu"), - (unsigned long) currently_testing + + (unsigned long) currently_testing + written); buf_used += got; @@ -810,7 +810,7 @@ static unsigned int test_nd (int dev, blk_t last_block, try = test_record[used2].num; used2++; } - + got = do_read (dev, read_ptr, try, block_size, currently_testing); @@ -824,7 +824,7 @@ static unsigned int test_nd (int dev, blk_t last_block, bb_count += bb_output(currently_testing + got); got++; } - + /* write back original data */ do_write (dev, save_ptr, got, block_size, currently_testing); @@ -903,7 +903,7 @@ static unsigned int parse_uint(const char *str, const char *descr) { char *tmp; unsigned long ret; - + errno = 0; ret = strtoul(str, &tmp, 0); if (*tmp || errno || (ret > UINT_MAX) || @@ -958,7 +958,7 @@ int main (int argc, char ** argv) sys_page_size = sysval; #endif /* _SC_PAGESIZE */ #endif /* HAVE_SYSCONF */ - + if (argc && *argv) program_name = *argv; while ((c = getopt (argc, argv, "b:d:e:fi:o:svwnc:p:h:t:X")) != EOF) { @@ -1008,7 +1008,7 @@ int main (int argc, char ** argv) d_flag = parse_uint(optarg, "read delay factor"); break; case 'p': - num_passes = parse_uint(optarg, + num_passes = parse_uint(optarg, "number of clean passes"); break; case 'h': @@ -1018,7 +1018,7 @@ int main (int argc, char ** argv) if (t_flag + 1 > t_max) { unsigned int *t_patts_new; - t_patts_new = realloc(t_patts, sizeof(int) * + t_patts_new = realloc(t_patts, sizeof(int) * (t_max + T_INC)); if (!t_patts_new) { com_err(program_name, ENOMEM, @@ -1095,7 +1095,7 @@ int main (int argc, char ** argv) } if (w_flag) check_mount(device_name); - + open_flag = w_flag ? O_RDWR : O_RDONLY; dev = open (device_name, open_flag); if (dev == -1) { @@ -1180,10 +1180,10 @@ int main (int argc, char ** argv) passes_clean = 0; else ++passes_clean; - + if (v_flag) fprintf(stderr, - _("Pass completed, %u bad blocks found.\n"), + _("Pass completed, %u bad blocks found.\n"), bb_count); } while (passes_clean < num_passes); diff --git a/misc/base_device.c b/misc/base_device.c index 6237d0e6..aad2ba05 100644 --- a/misc/base_device.c +++ b/misc/base_device.c @@ -5,12 +5,12 @@ * assure that we only fsck one partition on a particular drive at any * one time. Otherwise, the disk heads will be seeking all over the * place. If the base device can not be determined, return NULL. - * + * * The base_device() function returns an allocated string which must * be freed. - * + * * Written by Theodore Ts'o, <tytso@mit.edu> - * + * * Copyright (C) 2000 Theodore Ts'o. * * %Begin-Header% @@ -58,7 +58,7 @@ char *base_device(const char *device) /* Skip over /dev/dsk/... */ if (strncmp(cp, "dsk/", 4) == 0) cp += 4; - + /* * For md devices, we treat them all as if they were all * on one disk, since we don't know how to parallelize them. diff --git a/misc/blkid.c b/misc/blkid.c index c7679ad5..4bbf9fbf 100644 --- a/misc/blkid.c +++ b/misc/blkid.c @@ -410,8 +410,8 @@ int main(int argc, char **argv) BLKID_DEV_NORMAL); if (dev) { - if (search_type && - !blkid_dev_has_tag(dev, search_type, + if (search_type && + !blkid_dev_has_tag(dev, search_type, search_value)) continue; print_tags(dev, show, numtag, output_format); diff --git a/misc/chattr.c b/misc/chattr.c index daae163d..3d67519d 100644 --- a/misc/chattr.c +++ b/misc/chattr.c @@ -111,7 +111,7 @@ static const struct flags_char flags_array[] = { static unsigned long get_flag(char c) { const struct flags_char *fp; - + for (fp = flags_array; fp->flag != 0; fp++) { if (fp->optchar == c) return fp->flag; diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index 98a63159..9ef54769 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -57,7 +57,7 @@ static void usage(void) static void print_number(unsigned long num) { - if (hex_format) + if (hex_format) printf("0x%04lx", num); else printf("%lu", num); @@ -65,7 +65,7 @@ static void print_number(unsigned long num) static void print_range(unsigned long a, unsigned long b) { - if (hex_format) + if (hex_format) printf("0x%04lx-0x%04lx", a, b); else printf("%lu-%lu", a, b); @@ -162,7 +162,7 @@ static void list_desc (ext2_filsys fs) first_block = ext2fs_group_first_block(fs, i); last_block = ext2fs_group_last_block(fs, i); - ext2fs_super_and_bgd_loc(fs, i, &super_blk, + ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk, &new_desc_blk, 0); printf (_("Group %lu: (Blocks "), i); @@ -181,12 +181,12 @@ static void list_desc (ext2_filsys fs) } if (old_desc_blk) { printf(_(", Group descriptors at ")); - print_range(old_desc_blk, + print_range(old_desc_blk, old_desc_blk + old_desc_blocks - 1); if (reserved_gdt) { printf(_("\n Reserved GDT blocks at ")); print_range(old_desc_blk + old_desc_blocks, - old_desc_blk + old_desc_blocks + + old_desc_blk + old_desc_blocks + reserved_gdt - 1); } } else if (new_desc_blk) { @@ -225,7 +225,7 @@ static void list_desc (ext2_filsys fs) fs->group_desc[i].bg_itable_unused); if (block_bitmap) { fputs(_(" Free blocks: "), stdout); - ext2fs_get_block_bitmap_range(fs->block_map, + ext2fs_get_block_bitmap_range(fs->block_map, blk_itr, block_nbytes << 3, block_bitmap); print_free (i, block_bitmap, fs->super->s_blocks_per_group, @@ -235,7 +235,7 @@ static void list_desc (ext2_filsys fs) } if (inode_bitmap) { fputs(_(" Free inodes: "), stdout); - ext2fs_get_inode_bitmap_range(fs->inode_map, + ext2fs_get_inode_bitmap_range(fs->inode_map, ino_itr, inode_nbytes << 3, inode_bitmap); print_free (i, inode_bitmap, fs->super->s_inodes_per_group, 1); @@ -285,7 +285,7 @@ static void print_inline_journal_information(ext2_filsys fs) errcode_t retval; ino_t ino = fs->super->s_journal_inum; int size; - + retval = ext2fs_read_inode(fs, ino, &inode); if (retval) { com_err(program_name, retval, @@ -346,7 +346,7 @@ static void print_journal_information(ext2_filsys fs) } } -static void parse_extended_opts(const char *opts, blk_t *superblock, +static void parse_extended_opts(const char *opts, blk_t *superblock, int *blocksize) { char *buf, *token, *next, *p, *arg, *badopt = 0; @@ -421,7 +421,7 @@ static void parse_extended_opts(const char *opts, blk_t *superblock, exit(1); } free(buf); -} +} int main (int argc, char ** argv) { @@ -447,7 +447,7 @@ int main (int argc, char ** argv) E2FSPROGS_DATE); if (argc && *argv) program_name = *argv; - + while ((c = getopt (argc, argv, "bfhixVo:")) != EOF) { switch (c) { case 'b': @@ -463,7 +463,7 @@ int main (int argc, char ** argv) image_dump++; break; case 'o': - parse_extended_opts(optarg, &use_superblock, + parse_extended_opts(optarg, &use_superblock, &use_blocksize); break; case 'V': @@ -486,7 +486,7 @@ int main (int argc, char ** argv) flags |= EXT2_FLAG_FORCE; if (image_dump) flags |= EXT2_FLAG_IMAGE_FILE; - + if (use_superblock && !use_blocksize) { for (use_blocksize = EXT2_MIN_BLOCK_SIZE; use_blocksize <= EXT2_MAX_BLOCK_SIZE; diff --git a/misc/e2image.c b/misc/e2image.c index 358b3614..9659d496 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -47,7 +47,7 @@ char * device_name = NULL; static void usage(void) { - fprintf(stderr, _("Usage: %s [-rsI] device image_file\n"), + fprintf(stderr, _("Usage: %s [-rsI] device image_file\n"), program_name); exit (1); } @@ -68,10 +68,10 @@ static void write_header(int fd, struct ext2_image_hdr *hdr, int blocksize) exit(1); } memset(header_buf, 0, blocksize); - + if (hdr) memcpy(header_buf, hdr, sizeof(struct ext2_image_hdr)); - + actual = write(fd, header_buf, blocksize); if (actual < 0) { perror("write header"); @@ -100,7 +100,7 @@ static void write_image_file(ext2_filsys fs, int fd) com_err(program_name, retval, _("while writing superblock")); exit(1); } - + hdr.offset_inode = lseek(fd, 0, SEEK_CUR); retval = ext2fs_image_inode_write(fs, fd, (fd != 1) ? IMAGER_FLAG_SPARSEWRITE : 0); @@ -108,7 +108,7 @@ static void write_image_file(ext2_filsys fs, int fd) com_err(program_name, retval, _("while writing inode table")); exit(1); } - + hdr.offset_blockmap = lseek(fd, 0, SEEK_CUR); retval = ext2fs_image_bitmap_write(fs, fd, 0); if (retval) { @@ -129,7 +129,7 @@ static void write_image_file(ext2_filsys fs, int fd) strncpy(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name)-1); hdr.fs_device_name[sizeof(hdr.fs_device_name) - 1] = 0; hdr.fs_blocksize = fs->blocksize; - + if (stat(device_name, &st) == 0) hdr.fs_device = st.st_rdev; @@ -163,12 +163,12 @@ struct process_block_struct { static ino_t stashed_ino = 0; static struct ext2_inode *stashed_inode; -static errcode_t meta_get_blocks(ext2_filsys fs EXT2FS_ATTR((unused)), +static errcode_t meta_get_blocks(ext2_filsys fs EXT2FS_ATTR((unused)), ext2_ino_t ino, blk_t *blocks) { int i; - + if ((ino != stashed_ino) || !stashed_inode) return EXT2_ET_CALLBACK_NOTHANDLED; @@ -177,7 +177,7 @@ static errcode_t meta_get_blocks(ext2_filsys fs EXT2FS_ATTR((unused)), return 0; } -static errcode_t meta_check_directory(ext2_filsys fs EXT2FS_ATTR((unused)), +static errcode_t meta_check_directory(ext2_filsys fs EXT2FS_ATTR((unused)), ext2_ino_t ino) { if ((ino != stashed_ino) || !stashed_inode) @@ -188,7 +188,7 @@ static errcode_t meta_check_directory(ext2_filsys fs EXT2FS_ATTR((unused)), return 0; } -static errcode_t meta_read_inode(ext2_filsys fs EXT2FS_ATTR((unused)), +static errcode_t meta_read_inode(ext2_filsys fs EXT2FS_ATTR((unused)), ext2_ino_t ino, struct ext2_inode *inode) { @@ -212,11 +212,11 @@ static void use_inode_shortcuts(ext2_filsys fs, int bool) } } -static int process_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)), +static int process_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t *block_nr, - e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), + e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), blk_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *priv_data EXT2FS_ATTR((unused))) { struct process_block_struct *p; @@ -224,16 +224,16 @@ static int process_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)), p = (struct process_block_struct *) priv_data; ext2fs_mark_block_bitmap(meta_block_map, *block_nr); - if (scramble_block_map && p->is_dir && blockcnt >= 0) + if (scramble_block_map && p->is_dir && blockcnt >= 0) ext2fs_mark_block_bitmap(scramble_block_map, *block_nr); return 0; } -static int process_file_block(ext2_filsys fs EXT2FS_ATTR((unused)), +static int process_file_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t *block_nr, - e2_blkcnt_t blockcnt, + e2_blkcnt_t blockcnt, blk_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *priv_data EXT2FS_ATTR((unused))) { if (blockcnt < 0) { @@ -246,13 +246,13 @@ static void mark_table_blocks(ext2_filsys fs) { blk_t first_block, b; unsigned int i,j; - + first_block = fs->super->s_first_data_block; /* * Mark primary superblock */ ext2fs_mark_block_bitmap(meta_block_map, first_block); - + /* * Mark the primary superblock descriptors */ @@ -271,17 +271,17 @@ static void mark_table_blocks(ext2_filsys fs) j++, b++) ext2fs_mark_block_bitmap(meta_block_map, b); } - + /* - * Mark block used for the block bitmap + * Mark block used for the block bitmap */ if (fs->group_desc[i].bg_block_bitmap) { ext2fs_mark_block_bitmap(meta_block_map, fs->group_desc[i].bg_block_bitmap); } - + /* - * Mark block used for the inode bitmap + * Mark block used for the inode bitmap */ if (fs->group_desc[i].bg_inode_bitmap) { ext2fs_mark_block_bitmap(meta_block_map, @@ -358,7 +358,7 @@ static void scramble_dir_block(ext2_filsys fs, blk_t blk, char *buf) if (rec_len < 8 || (rec_len % 4) || (p+rec_len > end)) { printf("Corrupt directory block %lu: " - "bad rec_len (%d)\n", (unsigned long) blk, + "bad rec_len (%d)\n", (unsigned long) blk, rec_len); rec_len = end - p; #ifdef WORDS_BIGENDIAN @@ -368,7 +368,7 @@ static void scramble_dir_block(ext2_filsys fs, blk_t blk, char *buf) } if (dirent->name_len + 8 > rec_len) { printf("Corrupt directory block %lu: " - "bad name_len (%d)\n", (unsigned long) blk, + "bad name_len (%d)\n", (unsigned long) blk, dirent->name_len); dirent->name_len = rec_len - 8; continue; @@ -420,7 +420,7 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd) com_err(program_name, retval, "error reading block %u", blk); } - if (scramble_block_map && + if (scramble_block_map && ext2fs_test_block_bitmap(scramble_block_map, blk)) scramble_dir_block(fs, blk, buf); if ((fd != 1) && check_zero_block(buf, fs->blocksize)) @@ -455,7 +455,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag) ext2_ino_t ino; errcode_t retval; char * block_buf; - + retval = ext2fs_allocate_block_bitmap(fs, "in-use block map", &meta_block_map); if (retval) { @@ -467,12 +467,12 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag) retval = ext2fs_allocate_block_bitmap(fs, "scramble block map", &scramble_block_map); if (retval) { - com_err(program_name, retval, + com_err(program_name, retval, "while allocating scramble block bitmap"); exit(1); } } - + mark_table_blocks(fs); retval = ext2fs_open_inode_scan(fs, 0, &scan); @@ -486,7 +486,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag) com_err(program_name, 0, "Can't allocate block buffer"); exit(1); } - + use_inode_shortcuts(fs, 1); stashed_inode = &inode; while (1) { @@ -508,7 +508,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag) } if (!ext2fs_inode_has_valid_blocks(&inode)) continue; - + stashed_ino = ino; pb.ino = ino; pb.is_dir = LINUX_S_ISDIR(inode.i_mode); @@ -559,7 +559,7 @@ static void install_image(char *device, char *image_fn, int raw_flag) com_err(program_name, 0, "Raw images cannot be installed"); exit(1); } - + #ifdef CONFIG_TESTIO_DEBUG io_ptr = test_io_manager; test_io_backing_manager = unix_io_manager; @@ -591,7 +591,7 @@ static void install_image(char *device, char *image_fn, int raw_flag) exit(1); } - retval = io_ptr->open(device, IO_FLAG_RW, &io); + retval = io_ptr->open(device, IO_FLAG_RW, &io); if (retval) { com_err(device, 0, "while opening device file"); exit(1); diff --git a/misc/e2initrd_helper.c b/misc/e2initrd_helper.c index 8b8a00c9..df09aa1d 100644 --- a/misc/e2initrd_helper.c +++ b/misc/e2initrd_helper.c @@ -24,7 +24,7 @@ #include <utime.h> #ifdef HAVE_GETOPT_H #include <getopt.h> -#else +#else extern int optind; extern char *optarg; #endif @@ -67,7 +67,7 @@ static void usage(void) exit (1); } -static errcode_t get_file(ext2_filsys fs, const char * filename, +static errcode_t get_file(ext2_filsys fs, const char * filename, struct mem_file *ret_file) { errcode_t retval; @@ -81,7 +81,7 @@ static errcode_t get_file(ext2_filsys fs, const char * filename, ret_file->size = 0; ret_file->ptr = 0; - retval = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, + retval = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, filename, &ino); if (retval) return retval; @@ -103,7 +103,7 @@ static errcode_t get_file(ext2_filsys fs, const char * filename, return retval; retval = ext2fs_file_read(e2_file, buf, inode.i_size, &got); - if (retval) + if (retval) goto errout; retval = ext2fs_file_close(e2_file); @@ -246,7 +246,7 @@ static int parse_fstab_line(char *line, struct fs_info *fs) if (!device) return -1; /* Allow blank lines */ - + if (!mntpnt || !type) return -1; @@ -275,7 +275,7 @@ static int parse_fstab_line(char *line, struct fs_info *fs) if (dev) free(dev); - + return 0; } @@ -311,7 +311,7 @@ static void PRS(int argc, char **argv) break; case 'v': - printf("%s %s (%s)\n", program_name, + printf("%s %s (%s)\n", program_name, E2FSPROGS_VERSION, E2FSPROGS_DATE); break; default: @@ -322,7 +322,7 @@ static void PRS(int argc, char **argv) usage(); device_name = blkid_get_devname(NULL, argv[optind], NULL); if (!device_name) { - com_err("tune2fs", 0, _("Unable to resolve '%s'"), + com_err("tune2fs", 0, _("Unable to resolve '%s'"), argv[optind]); exit(1); } @@ -342,9 +342,9 @@ static void get_root_type(ext2_filsys fs) buf = get_line(&file); if (!buf) continue; - + ret = parse_fstab_line(buf, &fs_info); - if (ret < 0) + if (ret < 0) goto next_line; if (!strcmp(fs_info.mountpt, "/")) @@ -368,7 +368,7 @@ int main (int argc, char ** argv) blkid_get_cache(&cache, NULL); PRS(argc, argv); - + #ifdef CONFIG_TESTIO_DEBUG io_ptr = test_io_manager; test_io_backing_manager = unix_io_manager; @@ -379,7 +379,7 @@ int main (int argc, char ** argv) if (retval) exit(1); - if (root_type) + if (root_type) get_root_type(fs); remove_error_table(&et_ext2_error_table); diff --git a/misc/e2label.c b/misc/e2label.c index cf655135..e96101ae 100644 --- a/misc/e2label.c +++ b/misc/e2label.c @@ -2,7 +2,7 @@ * e2label.c - Print or change the volume label on an ext2 fs * * Written by Andries Brouwer (aeb@cwi.nl), 970714 - * + * * Copyright 1997, 1998 by Theodore Ts'o. * * %Begin-Header% diff --git a/misc/filefrag.c b/misc/filefrag.c index 27675b19..79f8fafe 100644 --- a/misc/filefrag.c +++ b/misc/filefrag.c @@ -1,6 +1,6 @@ /* * filefrag.c -- report if a particular file is fragmented - * + * * Copyright 2003 by Theodore Ts'o. * * %Begin-Header% @@ -106,16 +106,16 @@ static void frag_report(const char *filename) printf("%s: Not a regular file\n", filename); return; } - if ((fsinfo.f_type == 0xef51) || (fsinfo.f_type == 0xef52) || + if ((fsinfo.f_type == 0xef51) || (fsinfo.f_type == 0xef52) || (fsinfo.f_type == 0xef53)) is_ext2++; if (verbose) { - printf("Filesystem type is: %lx\n", + printf("Filesystem type is: %lx\n", (unsigned long) fsinfo.f_type); } cylgroups = div_ceil(fsinfo.f_blocks, fsinfo.f_bsize*8); if (verbose) { - printf("Filesystem cylinder groups is approximately %ld\n", + printf("Filesystem cylinder groups is approximately %ld\n", cylgroups); } #ifdef HAVE_OPEN64 @@ -143,7 +143,7 @@ static void frag_report(const char *filename) bpib = bs / 4; numblocks = (fileinfo.st_size + (bs-1)) / bs; if (verbose) { - printf("File size of %s is %lld (%ld blocks)\n", filename, + printf("File size of %s is %lld (%ld blocks)\n", filename, (long long) fileinfo.st_size, numblocks); printf("First block: %lu\nLast block: %lu\n", get_bmap(fd, 0), get_bmap(fd, numblocks - 1)); diff --git a/misc/findsuper.c b/misc/findsuper.c index 5eade889..fbc28a37 100644 --- a/misc/findsuper.c +++ b/misc/findsuper.c @@ -6,7 +6,7 @@ * using gpart program. * * Portions Copyright 1998-2000, Theodore Ts'o. - * + * * Well, here's my linux version of findsuper. * I'm sure you coulda done it faster. :) * IMHO there isn't as much interesting data to print in the @@ -18,7 +18,7 @@ * * I wanted to add msdos support, but I couldn't make heads or tails * of the kernel include files to find anything I could look for in msdos. - * + * * Reading every block of a Sun partition is fairly quick. Doing the * same under linux (slower hardware I suppose) just isn't the same. * It might be more useful to default to reading the first (second?) block @@ -59,26 +59,26 @@ /* * Documentation addendum added by Andreas dwguest@win.tue.nl/aeb@cwi.nl - * + * * The program findsuper is a utility that scans a disk and finds * copies of ext2 superblocks (by checking for the ext2 signature). - * + * * For each superblock found, it prints the offset in bytes, the * offset in 1024-byte blocks, the size of the ext2 partition in fs * blocks, the filesystem blocksize (in bytes), the block group number * (always 0 for older ext2 systems), and a timestamp (s_mtime). - * + * * This program can be used to retrieve partitions that have been * lost. The superblock for block group 0 is found 1 block (2 * sectors) after the partition start. - * + * * For new systems that have a block group number in the superblock it * is immediately clear which superblock is the first of a partition. * For old systems where no group numbers are given, the first * superblock can be recognised by the timestamp: all superblock * copies have the creation time in s_mtime, except the first, which * has the last time e2fsck or tune2fs wrote to the filesystem. - * + * */ #define _FILE_OFFSET_BITS 64 @@ -102,9 +102,9 @@ #define WHY(fmt, arg...) { continue; } #endif -static void usage(void) +static void usage(void) { - fprintf(stderr, + fprintf(stderr, _("Usage: findsuper device [skipbytes [startkb]]\n")); exit(1); } @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) fprintf(stderr, _("startkb should be positive, not %Lu\n"), sk); exit(1); } - + fd = open(device_name, O_RDONLY); if (fd < 0) { perror(device_name); diff --git a/misc/fsck.c b/misc/fsck.c index 28c8d6c4..ea8f0e2d 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -7,7 +7,7 @@ * parallel execution. * * Written by Theodore Ts'o, <tytso@mit.edu> - * + * * Miquel van Smoorenburg (miquels@drinkel.ow.org) 20-Oct-1994: * o Changed -t fstype to behave like with mount when -A (all file * systems) or -M (like mount) is specified. @@ -16,7 +16,7 @@ * can be added without changing this front-end. * o -R flag skip root file system. * - * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, + * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, * 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o. * * %Begin-Header% @@ -244,7 +244,7 @@ static void free_instance(struct fsck_instance *i) } static struct fs_info *create_fs_device(const char *device, const char *mntpnt, - const char *type, const char *opts, + const char *type, const char *opts, int freq, int passno) { struct fs_info *fs; @@ -312,7 +312,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs) passno ? atoi(passno) : -1); if (dev) free(dev); - + if (!fs) return -1; *ret_fs = fs; @@ -322,7 +322,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs) static void interpret_type(struct fs_info *fs) { char *t; - + if (strcmp(fs->type, "auto") != 0) return; t = blkid_get_tag_value(cache, "TYPE", fs->device); @@ -365,21 +365,21 @@ static void load_fs_info(const char *filename) else old_fstab = 0; } - + fclose(f); - + if (old_fstab && filesys_info) { fputs(_("\007\007\007" "WARNING: Your /etc/fstab does not contain the fsck passno\n" " field. I will kludge around things for you, but you\n" " should fix your /etc/fstab file as soon as you can.\n\n"), stderr); - + for (fs = filesys_info; fs; fs = fs->next) { fs->passno = 1; } } } - + /* Lookup filesys in /etc/fstab and return the corresponding entry. */ static struct fs_info *lookup(char *filesys) { @@ -451,7 +451,7 @@ static int execute(const char *type, const char *device, const char *mntpt, sprintf(prog, "fsck.%s", type); argv[0] = string_copy(prog); argc = 1; - + for (i=0; i <num_args; i++) argv[argc++] = string_copy(args[i]); @@ -490,7 +490,7 @@ static int execute(const char *type, const char *device, const char *mntpt, printf("%s ", argv[i]); printf("\n"); } - + /* Fork and execute the correct program. */ if (noexecute) pid = -1; @@ -509,7 +509,7 @@ static int execute(const char *type, const char *device, const char *mntpt, for (i=0; i < argc; i++) free(argv[i]); - + inst->pid = pid; inst->prog = string_copy(prog); inst->type = string_copy(type); @@ -527,7 +527,7 @@ static int execute(const char *type, const char *device, const char *mntpt, p->next = inst; else instance_list = inst; - + return 0; } @@ -580,7 +580,7 @@ static struct fsck_instance *wait_one(int flags) * (inst and prev are thought to be uninitialized variables) */ inst = prev = NULL; - + do { pid = waitpid(-1, &status, flags); if (cancel_requested && !kill_sent) { @@ -609,7 +609,7 @@ static struct fsck_instance *wait_one(int flags) } } while (!inst); - if (WIFEXITED(status)) + if (WIFEXITED(status)) status = WEXITSTATUS(status); else if (WIFSIGNALED(status)) { sig = WTERMSIG(status); @@ -694,11 +694,11 @@ static int wait_many(int flags) /* * Run the fsck program on a particular device - * + * * If the type is specified using -t, and it isn't prefixed with "no" * (as in "noext2") and only one filesystem type is specified, then * use that type regardless of what is specified in /etc/fstab. - * + * * If the type isn't specified by the user, then use either the type * specified in /etc/fstab, or DEFAULT_FSTYPE. */ @@ -712,7 +712,7 @@ static void fsck_device(struct fs_info *fs, int interactive) if (strcmp(fs->type, "auto") != 0) type = fs->type; else if (fstype && strncmp(fstype, "no", 2) && - strncmp(fstype, "opts=", 5) && strncmp(fstype, "loop", 4) && + strncmp(fstype, "opts=", 5) && strncmp(fstype, "loop", 4) && !strchr(fstype, ',')) type = fstype; else @@ -761,7 +761,7 @@ static void compile_fs_type(char *fs_type, struct fs_type_compile *cmp) cmp->list = malloc(num * sizeof(char *)); cmp->type = malloc(num * sizeof(int)); if (!cmp->list || !cmp->type) { - fputs(_("Couldn't allocate memory for filesystem types\n"), + fputs(_("Couldn't allocate memory for filesystem types\n"), stderr); exit(EXIT_ERROR); } @@ -771,7 +771,7 @@ static void compile_fs_type(char *fs_type, struct fs_type_compile *cmp) if (!fs_type) return; - + list = string_copy(fs_type); num = 0; s = strtok(list, ","); @@ -822,7 +822,7 @@ static int opt_in_list(const char *opt, char *optlist) if (!optlist) return 0; list = string_copy(optlist); - + s = strtok(list, ","); while(s) { if (strcmp(s, opt) == 0) { @@ -896,7 +896,7 @@ static int ignore(struct fs_info *fs) * ignore it. */ if (!fs_match(fs, &fs_type_compiled)) return 1; - + /* Are we ignoring this type? */ for(ip = ignored_types; *ip; ip++) if (strcmp(fs->type, *ip) == 0) return 1; @@ -945,7 +945,7 @@ static int device_already_active(char *device) * If we don't know the base device, assume that the device is * already active if there are any fsck instances running. */ - if (!base) + if (!base) return (instance_list != 0); for (inst = instance_list; inst; inst = inst->next) { if (!inst->base_device || !strcmp(base, inst->base_device)) { @@ -978,7 +978,7 @@ static int check_all(NOARGS) if (ignore(fs)) fs->flags |= FLAG_DONE; } - + /* * Find and check the root filesystem. */ @@ -1062,7 +1062,7 @@ static int check_all(NOARGS) status |= wait_many(pass_done ? FLAG_WAIT_ALL : FLAG_WAIT_ATLEAST_ONE); if (pass_done) { - if (verbose > 1) + if (verbose > 1) printf("----------------------------------\n"); passno++; } else @@ -1107,7 +1107,7 @@ static void PRS(int argc, char *argv[]) sigaction(SIGINT, &sa, 0); sigaction(SIGTERM, &sa, 0); #endif - + num_devices = 0; num_args = 0; instance_list = 0; @@ -1177,7 +1177,7 @@ static void PRS(int argc, char *argv[]) progress_fd = 0; else goto next_arg; - } else if ((i+1) < argc && + } else if ((i+1) < argc && !strncmp(argv[i+1], "-", 1) == 0) { progress_fd = string_to_int(argv[i]); if (progress_fd < 0) @@ -1295,7 +1295,7 @@ int main(int argc, char *argv[]) } else { fsck_path = string_copy(fsck_prefix_path); } - + if ((num_devices == 1) || (serialize)) interactive = 1; @@ -1335,7 +1335,7 @@ int main(int argc, char *argv[]) status |= inst->exit_status; free_instance(inst); } - if (verbose > 1) + if (verbose > 1) printf("----------------------------------\n"); } } diff --git a/misc/logsave.c b/misc/logsave.c index aa3235ee..f0011f81 100644 --- a/misc/logsave.c +++ b/misc/logsave.c @@ -52,10 +52,10 @@ static void usage(char *progname) static void send_output(const char *buffer, int c, int flag) { char *n; - + if (c == 0) c = strlen(buffer); - + if (flag & SEND_CONSOLE) write(1, buffer, c); if (!(flag & SEND_LOG)) @@ -147,7 +147,7 @@ static int run_program(char **argv) dup2(fds[1],1); /* fds[1] replaces stdout */ dup2(fds[1],2); /* fds[1] replaces stderr */ close(fds[0]); /* don't need this here */ - + execvp(argv[0], argv); perror(argv[0]); exit(1); @@ -201,8 +201,8 @@ static int copy_from_stdin(void) bad_read = 0; } return 0; -} - +} + int main(int argc, char **argv) @@ -213,7 +213,7 @@ int main(int argc, char **argv) int send_flag = SEND_LOG; int do_stdin; time_t t; - + while ((c = getopt(argc, argv, "+asv")) != EOF) { switch (c) { case 'a': @@ -238,7 +238,7 @@ int main(int argc, char **argv) outfd = open(outfn, openflags, 0644); do_stdin = !strcmp(argv[0], "-"); - + send_output("Log of ", 0, send_flag); if (do_stdin) send_output("stdin", 0, send_flag); @@ -257,7 +257,7 @@ int main(int argc, char **argv) rc = copy_from_stdin(); else rc = run_program(argv); - + send_output("\n", 0, send_flag); t = time(0); send_output(ctime(&t), 0, send_flag); @@ -279,11 +279,11 @@ int main(int argc, char **argv) while (outfd < 0) { outfd = open(outfn, openflags, 0644); sleep(1); - } + } write(outfd, outbuf, outbufsize); free(outbuf); } close(outfd); - + exit(rc); } diff --git a/misc/lsattr.c b/misc/lsattr.c index 093f50f4..254ebb4a 100644 --- a/misc/lsattr.c +++ b/misc/lsattr.c @@ -120,7 +120,7 @@ static void lsattr_args (const char * name) } } -static int lsattr_dir_proc (const char * dir_name, struct dirent * de, +static int lsattr_dir_proc (const char * dir_name, struct dirent * de, void * private EXT2FS_ATTR((unused))) { STRUCT_STAT st; diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 9cba3b5d..c1850a4d 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1,6 +1,6 @@ /* * mke2fs.c - Make a ext2fs filesystem. - * + * * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, * 2003, 2004, 2005 by Theodore Ts'o. * @@ -11,9 +11,9 @@ */ /* Usage: mke2fs [options] device - * + * * The device may be a block device or a image of one, but this isn't - * enforced (but it's not much fun on a character device :-). + * enforced (but it's not much fun on a character device :-). */ #define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX in Solaris */ @@ -232,7 +232,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list) if (!bb_list) return; - + /* * The primary superblock and group descriptors *must* be * good; if not, abort. @@ -257,13 +257,13 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list) */ group_block = fs->super->s_first_data_block + fs->super->s_blocks_per_group; - + for (i = 1; i < fs->group_desc_count; i++) { group_bad = 0; for (j=0; j < fs->desc_blocks+1; j++) { if (ext2fs_badblocks_list_test(bb_list, group_block + j)) { - if (!group_bad) + if (!group_bad) fprintf(stderr, _("Warning: the backup superblock/group descriptors at block %u contain\n" " bad blocks.\n\n"), @@ -277,7 +277,7 @@ _("Warning: the backup superblock/group descriptors at block %u contain\n" } group_block += fs->super->s_blocks_per_group; } - + /* * Mark all the bad blocks as used... */ @@ -287,7 +287,7 @@ _("Warning: the backup superblock/group descriptors at block %u contain\n" _("while marking bad blocks as used")); exit(1); } - while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) + while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) ext2fs_mark_block_bitmap(fs->block_map, blk); ext2fs_badblocks_list_iterate_end(bb_iter); } @@ -361,7 +361,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag) for (i = 0; i < fs->group_desc_count; i++) { progress_update(&progress, i); - + blk = fs->group_desc[i].bg_inode_table; num = fs->inode_blocks_per_group; @@ -452,7 +452,7 @@ static void create_lost_and_found(ext2_filsys fs) _("while looking up /lost+found")); exit(1); } - + for (i=1; i < EXT2_NDIR_BLOCKS; i++) { /* Ensure that lost+found is at least 2 blocks, so we always * test large empty blocks for big-block filesystems. */ @@ -471,7 +471,7 @@ static void create_lost_and_found(ext2_filsys fs) static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list) { errcode_t retval; - + ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_BAD_INO); ext2fs_inode_alloc_stats2(fs, EXT2_BAD_INO, +1, 0); retval = ext2fs_update_bb_inode(fs, bb_list); @@ -595,7 +595,7 @@ static void show_stats(ext2_filsys fs) blk_t group_block; dgrp_t i; int need, col_left; - + if (fs_param.s_blocks_count != s->s_blocks_count) fprintf(stderr, _("warning: %u blocks unused.\n\n"), fs_param.s_blocks_count - s->s_blocks_count); @@ -678,7 +678,7 @@ static int set_os(struct ext2_super_block *sb, char *os) #define PATH_SET "PATH=/sbin" -static void parse_extended_opts(struct ext2_super_block *param, +static void parse_extended_opts(struct ext2_super_block *param, const char *opts) { char *buf, *token, *next, *p, *arg, *badopt = 0; @@ -746,18 +746,18 @@ static void parse_extended_opts(struct ext2_super_block *param, continue; } - resize = parse_num_blocks(arg, + resize = parse_num_blocks(arg, param->s_log_block_size); if (resize == 0) { - fprintf(stderr, + fprintf(stderr, _("Invalid resize parameter: %s\n"), arg); r_usage++; continue; } if (resize <= param->s_blocks_count) { - fprintf(stderr, + fprintf(stderr, _("The resize maximum must be greater " "than the filesystem size.\n")); r_usage++; @@ -769,19 +769,19 @@ static void parse_extended_opts(struct ext2_super_block *param, if (!bpg) bpg = blocksize * 8; gdpb = EXT2_DESC_PER_BLOCK(param); - group_desc_count = + group_desc_count = ext2fs_div_ceil(param->s_blocks_count, bpg); desc_blocks = (group_desc_count + gdpb - 1) / gdpb; rsv_groups = ext2fs_div_ceil(resize, bpg); - rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) - + rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) - desc_blocks; if (rsv_gdb > (int) EXT2_ADDR_PER_BLOCK(param)) rsv_gdb = EXT2_ADDR_PER_BLOCK(param); if (rsv_gdb > 0) { if (param->s_rev_level == EXT2_GOOD_OLD_REV) { - fprintf(stderr, + fprintf(stderr, _("On-line resizing not supported with revision 0 filesystems\n")); free(buf); exit(1); @@ -825,7 +825,7 @@ static void parse_extended_opts(struct ext2_super_block *param, param->s_raid_stripe_width, param->s_raid_stride); free(buf); -} +} static __u32 ok_features[3] = { /* Compat */ @@ -851,7 +851,7 @@ static __u32 ok_features[3] = { static void syntax_err_report(const char *filename, long err, int line_num) { - fprintf(stderr, + fprintf(stderr, _("Syntax error in mke2fs config file (%s, line #%d)\n\t%s\n"), filename, line_num, error_message(err)); exit(1); @@ -859,13 +859,13 @@ static void syntax_err_report(const char *filename, long err, int line_num) static const char *config_fn[] = { ROOT_SYSCONFDIR "/mke2fs.conf", 0 }; -static void edit_feature(const char *str, __u32 *compat_array) +static void edit_feature(const char *str, __u32 *compat_array) { if (!str) return; if (e2p_edit_feature(str, compat_array, ok_features)) { - fprintf(stderr, _("Invalid filesystem option set: %s\n"), + fprintf(stderr, _("Invalid filesystem option set: %s\n"), str); exit(1); } @@ -1135,7 +1135,7 @@ static void PRS(int argc, char *argv[]) profile_init(default_files, &profile); profile_set_default(profile, mke2fs_default_profile); } - + setbuf(stdout, NULL); setbuf(stderr, NULL); add_error_table(&et_ext2_error_table); @@ -1177,7 +1177,7 @@ static void PRS(int argc, char *argv[]) fprintf(stderr, _("Warning: blocksize %d not " "usable on most systems.\n"), blocksize); - if (blocksize > 0) + if (blocksize > 0) fs_param.s_log_block_size = int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE); @@ -1341,11 +1341,11 @@ static void PRS(int argc, char *argv[]) device_name = argv[optind++]; if (!quiet || show_version_only) - fprintf (stderr, "mke2fs %s (%s)\n", E2FSPROGS_VERSION, + fprintf (stderr, "mke2fs %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); if (show_version_only) { - fprintf(stderr, _("\tUsing %s\n"), + fprintf(stderr, _("\tUsing %s\n"), error_message(EXT2_ET_BASE)); exit(0); } @@ -1399,7 +1399,7 @@ static void PRS(int argc, char *argv[]) blocksize, sys_page_size); } if (optind < argc) { - fs_param.s_blocks_count = parse_num_blocks(argv[optind++], + fs_param.s_blocks_count = parse_num_blocks(argv[optind++], fs_param.s_log_block_size); if (!fs_param.s_blocks_count) { com_err(program_name, 0, _("invalid blocks count - %s"), @@ -1425,14 +1425,14 @@ static void PRS(int argc, char *argv[]) EXT2_BLOCK_SIZE(&fs_param), &dev_size); if ((retval == EFBIG) && - (blocksize == 0) && + (blocksize == 0) && (fs_param.s_log_block_size == 0)) { fs_param.s_log_block_size = 2; blocksize = 4096; goto retry; } } - + if (retval == EFBIG) { fprintf(stderr, _("%s: Size of device %s too big " "to be expressed in 32 bits\n\t" @@ -1470,7 +1470,7 @@ static void PRS(int argc, char *argv[]) fs_param.s_blocks_count &= ~((sys_page_size / EXT2_BLOCK_SIZE(&fs_param))-1); } - + } else if (!force && (fs_param.s_blocks_count > dev_size)) { com_err(program_name, 0, _("Filesystem larger than apparent device size.")); @@ -1519,7 +1519,7 @@ static void PRS(int argc, char *argv[]) print_str_list(fs_types); } - if (r_opt == EXT2_GOOD_OLD_REV && + if (r_opt == EXT2_GOOD_OLD_REV && (fs_param.s_feature_compat || fs_param.s_feature_incompat || fs_param.s_feature_ro_compat)) { fprintf(stderr, _("Filesystem features not supported " @@ -1545,11 +1545,11 @@ static void PRS(int argc, char *argv[]) "with revision 0 filesystems\n")); exit(1); } - fs_param.s_feature_compat |= + fs_param.s_feature_compat |= EXT3_FEATURE_COMPAT_HAS_JOURNAL; } - if (fs_param.s_feature_incompat & + if (fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) { reserved_ratio = 0; fs_param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV; @@ -1582,7 +1582,7 @@ static void PRS(int argc, char *argv[]) if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL) sector_size = atoi(tmp); - + if (blocksize <= 0) { use_bsize = get_int_from_profile(fs_types, "blocksize", 4096); @@ -1612,9 +1612,9 @@ static void PRS(int argc, char *argv[]) blocksize = EXT2_BLOCK_SIZE(&fs_param); - lazy_itable_init = get_bool_from_profile(fs_types, + lazy_itable_init = get_bool_from_profile(fs_types, "lazy_itable_init", 0); - + /* Get options from profile */ for (cpp = fs_types; *cpp; cpp++) { tmp = NULL; @@ -1696,13 +1696,13 @@ static void PRS(int argc, char *argv[]) /* * Calculate number of inodes based on the inode ratio */ - fs_param.s_inodes_count = num_inodes ? num_inodes : + fs_param.s_inodes_count = num_inodes ? num_inodes : ((__u64) fs_param.s_blocks_count * blocksize) / inode_ratio; if ((((long long)fs_param.s_inodes_count) * (inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE)) >= - (((long long)fs_param.s_blocks_count) * + (((long long)fs_param.s_blocks_count) * EXT2_BLOCK_SIZE(&fs_param))) { com_err(program_name, 0, _("inode_size (%u) * inodes_count " "(%u) too big for a\n\t" @@ -1710,7 +1710,7 @@ static void PRS(int argc, char *argv[]) "specify higher inode_ratio (-i)\n\t" "or lower inode count (-N).\n"), inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE, - fs_param.s_inodes_count, + fs_param.s_inodes_count, (unsigned long) fs_param.s_blocks_count); exit(1); } @@ -1927,7 +1927,7 @@ int main (int argc, char *argv[]) strncpy(fs->super->s_last_mounted, mount_dir, sizeof(fs->super->s_last_mounted)); } - + if (!quiet || noaction) show_stats(fs); @@ -1989,7 +1989,7 @@ int main (int argc, char *argv[]) create_lost_and_found(fs); reserve_inodes(fs); create_bad_block_inode(fs, bb_list); - if (fs->super->s_feature_compat & + if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) { retval = ext2fs_create_resize_inode(fs); if (retval) { @@ -2002,9 +2002,9 @@ int main (int argc, char *argv[]) if (journal_device) { ext2_filsys jfs; - + if (!force) - check_plausibility(journal_device); + check_plausibility(journal_device); check_mount(journal_device, force, _("journal")); retval = ext2fs_open(journal_device, EXT2_FLAG_RW| @@ -2017,14 +2017,14 @@ int main (int argc, char *argv[]) exit(1); } if (!quiet) { - printf(_("Adding journal to device %s: "), + printf(_("Adding journal to device %s: "), journal_device); fflush(stdout); } retval = ext2fs_add_journal_device(fs, jfs); if(retval) { - com_err (program_name, retval, - _("\n\twhile trying to add journal to device %s"), + com_err (program_name, retval, + _("\n\twhile trying to add journal to device %s"), journal_device); exit(1); } @@ -2033,7 +2033,7 @@ int main (int argc, char *argv[]) ext2fs_close(jfs); free(journal_device); } else if ((journal_size) || - (fs_param.s_feature_compat & + (fs_param.s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { journal_blocks = figure_journal_size(journal_size, fs); diff --git a/misc/mklost+found.c b/misc/mklost+found.c index a0e71f00..8d5fa7be 100644 --- a/misc/mklost+found.c +++ b/misc/mklost+found.c @@ -53,7 +53,7 @@ int main (int argc, char ** argv) perror ("mkdir"); exit(1); } - + i = 0; memset (name, 'x', 246); do { diff --git a/misc/partinfo.c b/misc/partinfo.c index 149a193b..48b395f6 100644 --- a/misc/partinfo.c +++ b/misc/partinfo.c @@ -4,7 +4,7 @@ * Originally written by Alain Knaff, <alknaff@innet.lu>. * * Cleaned up by Theodore Ts'o, <tytso@mit.edu>. - * + * */ #include <sys/types.h> @@ -41,7 +41,7 @@ int main(int argc, char **argv) "For example: %s /dev/hda\n\n"), argv[0], argv[0]); exit(1); } - + for (i=1; i < argc; i++) { fd = open(argv[i], O_RDONLY); @@ -50,24 +50,24 @@ int main(int argc, char **argv) argv[i], strerror(errno)); continue; } - + if (ioctl(fd, HDIO_GETGEO, &loc) < 0) { fprintf(stderr, _("Cannot get geometry of %s: %s"), argv[i], strerror(errno)); close(fd); continue; } - - + + if (ioctl(fd, BLKGETSIZE, &size) < 0) { fprintf(stderr, _("Cannot get size of %s: %s"), argv[i], strerror(errno)); close(fd); continue; } - + printf(_("%s: h=%3d s=%3d c=%4d start=%8d size=%8lu end=%8d\n"), - argv[i], + argv[i], loc.heads, (int)loc.sectors, loc.cylinders, (int)loc.start, size, (int) loc.start + size -1); close(fd); diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 50b033d5..a1fa57b7 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -213,7 +213,7 @@ static void remove_journal_device(ext2_filsys fs) break; } if (i >= nr_users) { - fputs(_("Filesystem's UUID not found on journal device.\n"), + fputs(_("Filesystem's UUID not found on journal device.\n"), stderr); commit_remove_journal = 1; goto no_valid_journal; @@ -246,7 +246,7 @@ no_valid_journal: /* Helper function for remove_journal_inode */ static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr, - int blockcnt EXT2FS_ATTR((unused)), + int blockcnt EXT2FS_ATTR((unused)), void *private EXT2FS_ATTR((unused))) { blk_t block; @@ -269,7 +269,7 @@ static void remove_journal_inode(ext2_filsys fs) struct ext2_inode inode; errcode_t retval; ino_t ino = fs->super->s_journal_inum; - + retval = ext2fs_read_inode(fs, ino, &inode); if (retval) { com_err(program_name, retval, @@ -542,7 +542,7 @@ static void parse_e2label_options(int argc, char ** argv) *io_options++ = 0; device_name = blkid_get_devname(NULL, argv[1], NULL); if (!device_name) { - com_err("e2label", 0, _("Unable to resolve '%s'"), + com_err("e2label", 0, _("Unable to resolve '%s'"), argv[1]); exit(1); } @@ -551,7 +551,7 @@ static void parse_e2label_options(int argc, char ** argv) open_flag |= EXT2_FLAG_RW; L_flag = 1; new_label = argv[2]; - } else + } else print_label++; } @@ -740,7 +740,7 @@ static void parse_tune2fs_options(int argc, char **argv) mntopts_cmd = optarg; open_flag = EXT2_FLAG_RW; break; - + case 'O': if (features_cmd) { com_err (program_name, 0, @@ -827,7 +827,7 @@ static void parse_tune2fs_options(int argc, char **argv) *io_options++ = 0; device_name = blkid_get_devname(NULL, argv[optind], NULL); if (!device_name) { - com_err("tune2fs", 0, _("Unable to resolve '%s'"), + com_err("tune2fs", 0, _("Unable to resolve '%s'"), argv[optind]); exit(1); } @@ -844,7 +844,7 @@ void do_findfs(int argc, char **argv) } dev = blkid_get_devname(NULL, argv[1], NULL); if (!dev) { - com_err("findfs", 0, _("Unable to resolve '%s'"), + com_err("findfs", 0, _("Unable to resolve '%s'"), argv[1]); exit(1); } @@ -915,7 +915,7 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) continue; } stripe_width_set = 1; - } else + } else r_usage++; } if (r_usage) { @@ -932,7 +932,7 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts) exit(1); } free(buf); -} +} static int get_move_bitmap(ext2_filsys fs, int new_ino_blks_per_grp, ext2fs_block_bitmap bmap) @@ -1414,7 +1414,7 @@ int main (int argc, char ** argv) parse_e2label_options(argc, argv); else parse_tune2fs_options(argc, argv); - + #ifdef CONFIG_TESTIO_DEBUG io_ptr = test_io_manager; test_io_backing_manager = unix_io_manager; @@ -1423,7 +1423,7 @@ int main (int argc, char ** argv) #endif retry_open: - retval = ext2fs_open2(device_name, io_options, open_flag, + retval = ext2fs_open2(device_name, io_options, open_flag, 0, 0, io_ptr, &fs); if (retval) { com_err (program_name, retval, _("while trying to open %s"), @@ -1562,7 +1562,7 @@ retry_open: } if (L_flag) { if (strlen(new_label) > sizeof(sb->s_volume_name)) - fputs(_("Warning: label too long, truncating.\n"), + fputs(_("Warning: label too long, truncating.\n"), stderr); memset(sb->s_volume_name, 0, sizeof(sb->s_volume_name)); strncpy(sb->s_volume_name, new_label, @@ -1583,7 +1583,7 @@ retry_open: parse_extended_opts(fs, extended_cmd); if (journal_size || journal_device) add_journal(fs); - + if (U_flag) { if ((strcasecmp(new_UUID, "null") == 0) || (strcasecmp(new_UUID, "clear") == 0)) { diff --git a/misc/util.c b/misc/util.c index 8185d207..837d60fc 100644 --- a/misc/util.c +++ b/misc/util.c @@ -1,6 +1,6 @@ /* * util.c --- helper functions used by tune2fs and mke2fs - * + * * Copyright 1995, 1996, 1997, 1998, 1999, 2000 by Theodore Ts'o. * * %Begin-Header% @@ -81,14 +81,14 @@ void check_plausibility(const char *device) int val; #ifdef HAVE_OPEN64 struct stat64 s; - + val = stat64(device, &s); #else struct stat s; - + val = stat(device, &s); #endif - + if(val == -1) { fprintf(stderr, _("Could not stat %s --- %s\n"), device, error_message(errno)); @@ -194,7 +194,7 @@ void parse_journal_opts(const char *opts) if (p) { *p = 0; next = p+1; - } + } arg = strchr(token, '='); if (arg) { *arg = 0; @@ -238,13 +238,13 @@ void parse_journal_opts(const char *opts) exit(1); } free(buf); -} +} /* * Determine the number of journal blocks to use, either via * user-specified # of megabytes, or via some intelligently selected * defaults. - * + * * Find a reasonable journal file size (in blocks) given the number of blocks * in the filesystem. For very small filesystems, it is not reasonable to * have a journal that fills more than half of the filesystem. @@ -258,7 +258,7 @@ unsigned int figure_journal_size(int size, ext2_filsys fs) fputs(_("\nFilesystem too small for a journal\n"), stderr); return 0; } - + if (size > 0) { j_blocks = size * 1024 / (fs->blocksize / 1024); if (j_blocks < 1024 || j_blocks > 10240000) { diff --git a/misc/util.h b/misc/util.h index 0df2aacf..e0c99f6c 100644 --- a/misc/util.h +++ b/misc/util.h @@ -1,7 +1,7 @@ /* * util.h --- header file defining prototypes for helper functions * used by tune2fs and mke2fs - * + * * Copyright 2000 by Theodore Ts'o. * * %Begin-Header% diff --git a/misc/uuidd.c b/misc/uuidd.c index 1af8c863..3a855bcf 100644 --- a/misc/uuidd.c +++ b/misc/uuidd.c @@ -477,7 +477,7 @@ int main(int argc, char **argv) if (setregid(gid, gid) < 0) die("setregid"); #endif - + #ifdef HAVE_SETRESUID if (setresuid(uid, uid, uid) < 0) die("setresuid"); diff --git a/misc/uuidgen.c b/misc/uuidgen.c index 5e7eef3e..7385a5c4 100644 --- a/misc/uuidgen.c +++ b/misc/uuidgen.c @@ -58,7 +58,7 @@ main (int argc, char *argv[]) default: usage(argv[0]); } - + switch (do_type) { case DO_TYPE_TIME: uuid_generate_time(uu); @@ -70,7 +70,7 @@ main (int argc, char *argv[]) uuid_generate(uu); break; } - + uuid_unparse(uu, str); printf("%s\n", str); diff --git a/resize/extent.c b/resize/extent.c index ca2c68cd..2ed7591d 100644 --- a/resize/extent.c +++ b/resize/extent.c @@ -9,7 +9,7 @@ * PowerQuest, Inc. * * Copyright (C) 1999, 2000 by Theosore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -34,11 +34,11 @@ struct _ext2_extent { /* * Create an extent table */ -errcode_t ext2fs_create_extent_table(ext2_extent *ret_extent, int size) +errcode_t ext2fs_create_extent_table(ext2_extent *ret_extent, int size) { ext2_extent extent; errcode_t retval; - + retval = ext2fs_get_mem(sizeof(struct _ext2_extent), &extent); if (retval) return retval; @@ -86,9 +86,9 @@ errcode_t ext2fs_add_extent_entry(ext2_extent extent, __u32 old_loc, __u32 new_l if (extent->num >= extent->size) { newsize = extent->size + 100; - retval = ext2fs_resize_mem(sizeof(struct ext2_extent_entry) * - extent->size, - sizeof(struct ext2_extent_entry) * + retval = ext2fs_resize_mem(sizeof(struct ext2_extent_entry) * + extent->size, + sizeof(struct ext2_extent_entry) * newsize, &extent->list); if (retval) return retval; @@ -128,12 +128,12 @@ static EXT2_QSORT_TYPE extent_cmp(const void *a, const void *b) { const struct ext2_extent_entry *db_a; const struct ext2_extent_entry *db_b; - + db_a = (const struct ext2_extent_entry *) a; db_b = (const struct ext2_extent_entry *) b; - + return (db_a->old_loc - db_b->old_loc); -} +} /* * Given an inode map and inode number, look up the old inode number @@ -167,7 +167,7 @@ __u32 ext2fs_extent_translate(ext2_extent extent, __u32 old_loc) range = 0; else if (old_loc > highval) range = 1; - else + else range = ((float) (old_loc - lowval)) / (highval - lowval); mid = low + ((int) (range * (high-low))); @@ -192,7 +192,7 @@ void ext2fs_extent_dump(ext2_extent extent, FILE *out) { int i; struct ext2_extent_entry *ent; - + fputs(_("# Extent dump:\n"), out); fprintf(out, _("#\tNum=%d, Size=%d, Cursor=%d, Sorted=%d\n"), extent->num, extent->size, extent->cursor, extent->sorted); @@ -209,7 +209,7 @@ errcode_t ext2fs_iterate_extent(ext2_extent extent, __u32 *old_loc, __u32 *new_loc, int *size) { struct ext2_extent_entry *ent; - + if (!old_loc) { extent->cursor = 0; return 0; @@ -229,7 +229,7 @@ errcode_t ext2fs_iterate_extent(ext2_extent extent, __u32 *old_loc, *size = ent->size; return 0; } - - - - + + + + diff --git a/resize/main.c b/resize/main.c index 1cb0b208..aeac24bc 100644 --- a/resize/main.c +++ b/resize/main.c @@ -5,7 +5,7 @@ * PowerQuest, Inc. * * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 by Theodore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -108,11 +108,11 @@ static void determine_fs_stride(ext2_filsys fs) has_sb = ext2fs_bg_has_super(fs, group); if (group == 0 || has_sb != prev_has_sb) goto next; - b_stride = fs->group_desc[group].bg_block_bitmap - - fs->group_desc[group-1].bg_block_bitmap - + b_stride = fs->group_desc[group].bg_block_bitmap - + fs->group_desc[group-1].bg_block_bitmap - fs->super->s_blocks_per_group; - i_stride = fs->group_desc[group].bg_inode_bitmap - - fs->group_desc[group-1].bg_inode_bitmap - + i_stride = fs->group_desc[group].bg_inode_bitmap - + fs->group_desc[group-1].bg_inode_bitmap - fs->super->s_blocks_per_group; if (b_stride != i_stride || b_stride < 0) @@ -121,7 +121,7 @@ static void determine_fs_stride(ext2_filsys fs) /* printf("group %d has stride %d\n", group, b_stride); */ sum += b_stride; num++; - + next: prev_has_sb = has_sb; } @@ -223,7 +223,7 @@ int main (int argc, char ** argv) new_size_str = argv[optind++]; if (optind < argc) usage(program_name); - + io_options = strchr(device_name, '?'); if (io_options) *io_options++ = 0; @@ -238,7 +238,7 @@ int main (int argc, char ** argv) if (!mtpt) return ENOMEM; mtpt[len-1] = 0; - retval = ext2fs_check_mount_point(device_name, &mount_flags, + retval = ext2fs_check_mount_point(device_name, &mount_flags, mtpt, len); if (retval) { com_err("ext2fs_check_mount_point", retval, @@ -269,16 +269,16 @@ int main (int argc, char ** argv) ret = fstat(fd, &st_buf); #endif if (ret < 0) { - com_err("open", errno, + com_err("open", errno, _("while getting stat information for %s"), device_name); exit(1); } - + if (flush) { retval = ext2fs_sync_device(fd, 1); if (retval) { - com_err(argv[0], retval, + com_err(argv[0], retval, _("while trying to flush %s"), device_name); exit(1); @@ -293,12 +293,12 @@ int main (int argc, char ** argv) if (flags & RESIZE_DEBUG_IO) { io_ptr = test_io_manager; test_io_backing_manager = unix_io_manager; - } else + } else io_ptr = unix_io_manager; if (!(mount_flags & EXT2_MF_MOUNTED)) io_flags = EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE; - retval = ext2fs_open2(device_name, io_options, io_flags, + retval = ext2fs_open2(device_name, io_options, io_flags, 0, 0, io_ptr, &fs); if (retval) { com_err (program_name, retval, _("while trying to open %s"), @@ -335,7 +335,7 @@ int main (int argc, char ** argv) device_name); exit(1); } - + if (print_min_size) { printf(_("Estimated minimum size of the filesystem: %u\n"), calculate_minimum_resize_size(fs)); @@ -369,7 +369,7 @@ int main (int argc, char ** argv) if (force_min_size) new_size = calculate_minimum_resize_size(fs); else if (new_size_str) { - new_size = parse_num_blocks(new_size_str, + new_size = parse_num_blocks(new_size_str, fs->super->s_log_block_size); } else { new_size = max_size; @@ -380,7 +380,7 @@ int main (int argc, char ** argv) if (use_stride >= 0) { if (use_stride >= (int) fs->super->s_blocks_per_group) { - com_err(program_name, 0, + com_err(program_name, 0, _("Invalid stride length")); exit(1); } @@ -388,14 +388,14 @@ int main (int argc, char ** argv) ext2fs_mark_super_dirty(fs); } else determine_fs_stride(fs); - + /* * If we are resizing a plain file, and it's not big enough, * automatically extend it in a sparse fashion by writing the * last requested block. */ new_file_size = ((__u64) new_size) * fs->blocksize; - if ((__u64) new_file_size > + if ((__u64) new_file_size > (((__u64) 1) << (sizeof(st_buf.st_size)*8 - 1)) - 1) fd = -1; if ((new_file_size > st_buf.st_size) && @@ -422,7 +422,7 @@ int main (int argc, char ** argv) if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) || (fs->super->s_state & EXT2_ERROR_FS) || ((fs->super->s_state & EXT2_VALID_FS) == 0))) { - fprintf(stderr, + fprintf(stderr, _("Please run 'e2fsck -f %s' first.\n\n"), device_name); exit(1); diff --git a/resize/online.c b/resize/online.c index 5d596045..f4d24ce7 100644 --- a/resize/online.c +++ b/resize/online.c @@ -1,8 +1,8 @@ /* * online.c --- Do on-line resizing of the ext3 filesystem * - * Copyright (C) 2006 by Theodore Ts'o - * + * Copyright (C) 2006 by Theodore Ts'o + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -18,7 +18,7 @@ extern char *program_name; -errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, +errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, blk_t *new_size, int flags EXT2FS_ATTR((unused))) { #ifdef __linux__ @@ -44,7 +44,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, } /* - * If the number of descriptor blocks is going to increase, + * If the number of descriptor blocks is going to increase, * the on-line resizing inode must be present. */ new_desc_blocks = ext2fs_div_ceil( @@ -52,19 +52,19 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, fs->super->s_first_data_block, EXT2_BLOCKS_PER_GROUP(fs->super)), EXT2_DESC_PER_BLOCK(fs->super)); - printf("old desc_blocks = %lu, new_desc_blocks = %lu\n", + printf("old desc_blocks = %lu, new_desc_blocks = %lu\n", fs->desc_blocks, new_desc_blocks); - if (!(fs->super->s_feature_compat & + if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) && new_desc_blocks != fs->desc_blocks) { - com_err(program_name, 0, + com_err(program_name, 0, _("Filesystem does not support online resizing")); exit(1); } fd = open(mtpt, O_RDONLY); if (fd < 0) { - com_err(program_name, errno, + com_err(program_name, errno, _("while trying to open mountpoint %s"), mtpt); exit(1); } @@ -72,13 +72,13 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, size=sb->s_blocks_count; if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) { if (errno == EPERM) - com_err(program_name, 0, + com_err(program_name, 0, _("Permission denied to resize filesystem")); else if (errno == ENOTTY) - com_err(program_name, 0, + com_err(program_name, 0, _("Kernel does not support online resizing")); - else - com_err(program_name, errno, + else + com_err(program_name, errno, _("While checking for on-line resizing support")); exit(1); } @@ -100,13 +100,13 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, printf(_("Performing an on-line resize of %s to %u (%dk) blocks.\n"), fs->device_name, *new_size, fs->blocksize / 1024); - size = fs->group_desc_count * sb->s_blocks_per_group + + size = fs->group_desc_count * sb->s_blocks_per_group + sb->s_first_data_block; if (size > *new_size) size = *new_size; if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) { - com_err(program_name, errno, + com_err(program_name, errno, _("While trying to extend the last group")); exit(1); } @@ -117,7 +117,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, overhead = (int) (2 + new_fs->inode_blocks_per_group); if (ext2fs_bg_has_super(new_fs, new_fs->group_desc_count - 1)) - overhead += 1 + new_fs->desc_blocks + + overhead += 1 + new_fs->desc_blocks + new_fs->super->s_reserved_gdt_blocks; input.group = i; @@ -127,7 +127,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, input.blocks_count = sb->s_blocks_per_group; if (i == new_fs->group_desc_count-1) { input.blocks_count = new_fs->super->s_blocks_count - - sb->s_first_data_block - + sb->s_first_data_block - (i * sb->s_blocks_per_group); } input.reserved_blocks = (blk_t) (percent * input.blocks_count @@ -136,16 +136,16 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, #if 0 printf("new block bitmap is at 0x%04x\n", input.block_bitmap); printf("new inode bitmap is at 0x%04x\n", input.inode_bitmap); - printf("new inode table is at 0x%04x-0x%04x\n", + printf("new inode table is at 0x%04x-0x%04x\n", input.inode_table, input.inode_table + new_fs->inode_blocks_per_group-1); printf("new group has %u blocks\n", input.blocks_count); - printf("new group will reserve %d blocks\n", + printf("new group will reserve %d blocks\n", input.reserved_blocks); - printf("new group has %d free blocks\n", + printf("new group has %d free blocks\n", new_fs->group_desc[i].bg_free_blocks_count); printf("new group has %d free inodes (%d blocks)\n", - new_fs->group_desc[i].bg_free_inodes_count, + new_fs->group_desc[i].bg_free_inodes_count, new_fs->inode_blocks_per_group); printf("Adding group #%d\n", input.group); #endif @@ -165,8 +165,8 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, input64.unused = input.unused; if (ioctl(fd, EXT4_IOC_GROUP_ADD, &input64) < 0) { - com_err(program_name, errno, - _("While trying to add group #%d"), + com_err(program_name, errno, + _("While trying to add group #%d"), input.group); exit(1); } diff --git a/resize/resize2fs.c b/resize/resize2fs.c index cb8d5659..f392867f 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -5,7 +5,7 @@ * PowerQuest, Inc. * * Copyright (C) 1999, 2000 by Theosore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -82,7 +82,7 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags, retval = ext2fs_read_bitmaps(fs); if (retval) return retval; - + /* * Create the data structure */ @@ -123,7 +123,7 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags, rfs->new_fs->super->s_free_blocks_count, rfs->needed_blocks); #endif - + retval = block_mover(rfs); if (retval) goto errout; @@ -143,23 +143,23 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags, retval = ext2fs_calculate_summary_stats(rfs->new_fs); if (retval) goto errout; - + retval = fix_resize_inode(rfs->new_fs); if (retval) goto errout; - rfs->new_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; + rfs->new_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; retval = ext2fs_close(rfs->new_fs); if (retval) goto errout; rfs->flags = flags; - + ext2fs_free(rfs->old_fs); if (rfs->itable_buf) ext2fs_free_mem(&rfs->itable_buf); ext2fs_free_mem(&rfs); - + return 0; errout: @@ -198,7 +198,7 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs) if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else - old_desc_blocks = fs->desc_blocks + + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) { @@ -258,7 +258,7 @@ retry: EXT2_BLOCKS_PER_GROUP(fs->super)); if (fs->group_desc_count == 0) return EXT2_ET_TOOSMALL; - fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count, + fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count, EXT2_DESC_PER_BLOCK(fs->super)); /* @@ -270,7 +270,7 @@ retry: overhead = (int) (2 + fs->inode_blocks_per_group); if (ext2fs_bg_has_super(fs, fs->group_desc_count - 1)) - overhead += 1 + fs->desc_blocks + + overhead += 1 + fs->desc_blocks + fs->super->s_reserved_gdt_blocks; /* @@ -324,7 +324,7 @@ retry: fs->super->s_inodes_count, fs->inode_map); if (retval) goto errout; - + real_end = ((EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count)) - 1 + fs->super->s_first_data_block; @@ -343,8 +343,8 @@ retry: &fs->group_desc); if (retval) goto errout; - if (fs->desc_blocks > old_fs->desc_blocks) - memset((char *) fs->group_desc + + if (fs->desc_blocks > old_fs->desc_blocks) + memset((char *) fs->group_desc + (old_fs->desc_blocks * fs->blocksize), 0, (fs->desc_blocks - old_fs->desc_blocks) * fs->blocksize); @@ -356,12 +356,12 @@ retry: * s_reserved_gdt_blocks if possible to avoid needing to move * the inode table either now or in the future. */ - if ((fs->super->s_feature_compat & + if ((fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) && (old_fs->desc_blocks != fs->desc_blocks)) { int new; - new = ((int) fs->super->s_reserved_gdt_blocks) + + new = ((int) fs->super->s_reserved_gdt_blocks) + (old_fs->desc_blocks - fs->desc_blocks); if (new < 0) new = 0; @@ -422,7 +422,7 @@ retry: if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else - old_desc_blocks = fs->desc_blocks + + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; for (i = old_fs->group_desc_count; i < fs->group_desc_count; i++) { @@ -472,9 +472,9 @@ retry: ext2fs_block_alloc_stats(fs, group_block + has_super, +1); } - + adjblocks += 2 + fs->inode_blocks_per_group; - + numblocks -= adjblocks; fs->super->s_free_blocks_count -= adjblocks; fs->super->s_free_inodes_count += @@ -508,7 +508,7 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk_t new_size) blk_t group_block; unsigned long i; unsigned long max_group; - + fs = rfs->new_fs; ext2fs_mark_super_dirty(fs); ext2fs_mark_bb_dirty(fs); @@ -623,11 +623,11 @@ static errcode_t mark_table_blocks(ext2_filsys fs, if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else - old_desc_blocks = fs->desc_blocks + + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; for (i = 0; i < fs->group_desc_count; i++) { ext2fs_reserve_super_and_bgd(fs, i, bmap); - + /* * Mark the blocks used for the inode table */ @@ -635,15 +635,15 @@ static errcode_t mark_table_blocks(ext2_filsys fs, j < (unsigned int) fs->inode_blocks_per_group; j++, b++) ext2fs_mark_block_bitmap(bmap, b); - + /* - * Mark block used for the block bitmap + * Mark block used for the block bitmap */ ext2fs_mark_block_bitmap(bmap, fs->group_desc[i].bg_block_bitmap); /* - * Mark block used for the inode bitmap + * Mark block used for the inode bitmap */ ext2fs_mark_block_bitmap(bmap, fs->group_desc[i].bg_inode_bitmap); @@ -661,7 +661,7 @@ static void mark_fs_metablock(ext2_resize_t rfs, int group, blk_t blk) { ext2_filsys fs = rfs->new_fs; - + ext2fs_mark_block_bitmap(rfs->reserve_blocks, blk); ext2fs_block_alloc_stats(fs, blk, +1); @@ -715,7 +715,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) old_fs = rfs->old_fs; if (old_fs->super->s_blocks_count > fs->super->s_blocks_count) fs = rfs->old_fs; - + retval = ext2fs_allocate_block_bitmap(fs, _("reserved blocks"), &rfs->reserve_blocks); if (retval) @@ -726,17 +726,17 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) if (retval) return retval; - retval = ext2fs_allocate_block_bitmap(fs, _("meta-data blocks"), + retval = ext2fs_allocate_block_bitmap(fs, _("meta-data blocks"), &meta_bmap); if (retval) return retval; - + retval = mark_table_blocks(old_fs, meta_bmap); if (retval) return retval; fs = rfs->new_fs; - + /* * If we're shrinking the filesystem, we need to move all of * the blocks that don't fit any more @@ -762,7 +762,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) } ext2fs_mark_block_bitmap(rfs->reserve_blocks, blk); } - + if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) { old_blocks = old_fs->super->s_first_meta_bg; new_blocks = fs->super->s_first_meta_bg; @@ -770,7 +770,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) old_blocks = old_fs->desc_blocks + old_fs->super->s_reserved_gdt_blocks; new_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; } - + if (old_blocks == new_blocks) { retval = 0; goto errout; @@ -803,7 +803,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) } /* * If we're increasing the number of descriptor blocks, life - * gets interesting.... + * gets interesting.... */ meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super); for (i = 0; i < max_groups; i++) { @@ -818,7 +818,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) if (has_super) { for (blk = group_blk+1; blk < group_blk + 1 + new_blocks; blk++) - mark_fs_metablock(rfs, meta_bmap, + mark_fs_metablock(rfs, meta_bmap, i, blk); } } else { @@ -895,7 +895,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) /* * Mark the new inode table as in use in the new block - * allocation bitmap, and move any blocks that might + * allocation bitmap, and move any blocks that might * be necessary. */ for (blk = fs->group_desc[i].bg_inode_table, j=0; @@ -906,7 +906,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) ext2fs_mark_block_bitmap(rfs->move_blocks, blk); } - + /* * Make sure the old inode table is reserved in the * block reservation bitmap. @@ -914,7 +914,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) for (blk = rfs->old_fs->group_desc[i].bg_inode_table, j=0; j < fs->inode_blocks_per_group ; j++, blk++) ext2fs_mark_block_bitmap(rfs->reserve_blocks, blk); - + next_group: group_blk += rfs->new_fs->super->s_blocks_per_group; } @@ -923,7 +923,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) errout: if (meta_bmap) ext2fs_free_block_bitmap(meta_bmap); - + return retval; } @@ -959,7 +959,7 @@ static void init_block_alloc(ext2_resize_t rfs) static blk_t get_new_block(ext2_resize_t rfs) { ext2_filsys fs = rfs->new_fs; - + while (1) { if (rfs->new_blk >= fs->super->s_blocks_count) { if (rfs->alloc_state == DESPERATION) @@ -969,7 +969,7 @@ static blk_t get_new_block(ext2_resize_t rfs) if (rfs->flags & RESIZE_DEBUG_BMOVE) printf("Going into desperation mode " "for block allocations\n"); -#endif +#endif rfs->alloc_state = DESPERATION; rfs->new_blk = fs->super->s_first_data_block; continue; @@ -1019,7 +1019,7 @@ static errcode_t block_mover(ext2_resize_t rfs) int to_move, moved; ext2_badblocks_list badblock_list = 0; int bb_modified = 0; - + fs->get_alloc_block = resize2fs_get_alloc_block; old_fs->get_alloc_block = resize2fs_get_alloc_block; @@ -1066,7 +1066,7 @@ static errcode_t block_mover(ext2_resize_t rfs) ext2fs_add_extent_entry(rfs->bmap, blk, new_blk); to_move++; } - + if (to_move == 0) { if (rfs->bmap) { ext2fs_free_extent_table(rfs->bmap); @@ -1153,7 +1153,7 @@ struct process_block_struct { }; static int process_block(ext2_filsys fs, blk_t *block_nr, - e2_blkcnt_t blockcnt, + e2_blkcnt_t blockcnt, blk_t ref_block EXT2FS_ATTR((unused)), int ref_offset EXT2FS_ATTR((unused)), void *priv_data) { @@ -1172,7 +1172,7 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, pb->changed = 1; #ifdef RESIZE2FS_DEBUG if (pb->rfs->flags & RESIZE_DEBUG_BMOVE) - printf("ino=%u, blockcnt=%lld, %u->%u\n", + printf("ino=%u, blockcnt=%lld, %u->%u\n", pb->ino, blockcnt, block, new_block); #endif block = new_block; @@ -1192,7 +1192,7 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, /* * Progress callback */ -static errcode_t progress_callback(ext2_filsys fs, +static errcode_t progress_callback(ext2_filsys fs, ext2_inode_scan scan EXT2FS_ATTR((unused)), dgrp_t group, void * priv_data) { @@ -1213,7 +1213,7 @@ static errcode_t progress_callback(ext2_filsys fs, if (retval) return retval; } - + return 0; } @@ -1228,7 +1228,7 @@ static errcode_t inode_scan_and_fix(ext2_resize_t rfs) ext2_ino_t start_to_move; blk_t orig_size, new_block; int inode_size; - + if ((rfs->old_fs->group_desc_count <= rfs->new_fs->group_desc_count) && !rfs->bmap) @@ -1255,7 +1255,7 @@ static errcode_t inode_scan_and_fix(ext2_resize_t rfs) start_to_move = (rfs->new_fs->group_desc_count * rfs->new_fs->super->s_inodes_per_group); - + if (rfs->progress) { retval = (rfs->progress)(rfs, E2_RSZ_INODE_SCAN_PASS, 0, rfs->old_fs->group_desc_count); @@ -1290,16 +1290,16 @@ static errcode_t inode_scan_and_fix(ext2_resize_t rfs) pb.changed = 0; if (inode->i_file_acl && rfs->bmap) { - new_block = ext2fs_extent_translate(rfs->bmap, + new_block = ext2fs_extent_translate(rfs->bmap, inode->i_file_acl); if (new_block) { inode->i_file_acl = new_block; - retval = ext2fs_write_inode_full(rfs->old_fs, + retval = ext2fs_write_inode_full(rfs->old_fs, ino, inode, inode_size); if (retval) goto errout; } } - + if (ext2fs_inode_has_valid_blocks(inode) && (rfs->bmap || pb.is_dir)) { pb.ino = ino; @@ -1379,11 +1379,11 @@ struct istruct { int num; }; -static int check_and_change_inodes(ext2_ino_t dir, +static int check_and_change_inodes(ext2_ino_t dir, int entry EXT2FS_ATTR((unused)), struct ext2_dir_entry *dirent, int offset, int blocksize EXT2FS_ATTR((unused)), - char *buf EXT2FS_ATTR((unused)), + char *buf EXT2FS_ATTR((unused)), void *priv_data) { struct istruct *is = (struct istruct *) priv_data; @@ -1432,10 +1432,10 @@ static errcode_t inode_ref_fix(ext2_resize_t rfs) { errcode_t retval; struct istruct is; - + if (!rfs->imap) return 0; - + /* * Now, we iterate over all of the directories to update the * inode references @@ -1451,7 +1451,7 @@ static errcode_t inode_ref_fix(ext2_resize_t rfs) if (retval) goto errout; } - + retval = ext2fs_dblist_dir_iterate(rfs->old_fs->dblist, DIRENT_FLAG_INCLUDE_EMPTY, 0, check_and_change_inodes, &is); @@ -1539,20 +1539,20 @@ static errcode_t move_itables(ext2_resize_t rfs) old_blk = rfs->old_fs->group_desc[i].bg_inode_table; new_blk = fs->group_desc[i].bg_inode_table; diff = new_blk - old_blk; - + #ifdef RESIZE2FS_DEBUG - if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE) + if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE) printf("Itable move group %d block %u->%u (diff %d)\n", i, old_blk, new_blk, diff); #endif - + if (!diff) continue; retval = io_channel_read_blk(fs->io, old_blk, fs->inode_blocks_per_group, rfs->itable_buf); - if (retval) + if (retval) goto errout; /* * The end of the inode table segment often contains @@ -1566,7 +1566,7 @@ static errcode_t move_itables(ext2_resize_t rfs) break; n = n >> EXT2_BLOCK_SIZE_BITS(fs->super); #ifdef RESIZE2FS_DEBUG - if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE) + if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE) printf("%d blocks of zeros...\n", n); #endif num = fs->inode_blocks_per_group; @@ -1609,17 +1609,17 @@ static errcode_t move_itables(ext2_resize_t rfs) mark_table_blocks(fs, fs->block_map); ext2fs_flush(fs); #ifdef RESIZE2FS_DEBUG - if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE) + if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE) printf("Inode table move finished.\n"); #endif return 0; - + errout: return retval; } /* - * Fix the resize inode + * Fix the resize inode */ static errcode_t fix_resize_inode(ext2_filsys fs) { @@ -1628,7 +1628,7 @@ static errcode_t fix_resize_inode(ext2_filsys fs) char * block_buf; blk_t blk; - if (!(fs->super->s_feature_compat & + if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) return 0; @@ -1639,7 +1639,7 @@ static errcode_t fix_resize_inode(ext2_filsys fs) if (retval) goto errout; if (fs->super->s_reserved_gdt_blocks == 0) { - fs->super->s_feature_compat &= + fs->super->s_feature_compat &= ~EXT2_FEATURE_COMPAT_RESIZE_INODE; ext2fs_mark_super_dirty(fs); @@ -1658,12 +1658,12 @@ static errcode_t fix_resize_inode(ext2_filsys fs) if (retval) goto errout; if (!inode.i_block[EXT2_DIND_BLOCK]) { - /* + /* * Avoid zeroing out block #0; that's rude. This * should never happen anyway since the filesystem * should be fsck'ed and we assume it is consistent. */ - fprintf(stderr, + fprintf(stderr, _("Should never happen: resize inode corrupt!\n")); exit(1); } @@ -1673,7 +1673,7 @@ static errcode_t fix_resize_inode(ext2_filsys fs) retval = io_channel_write_blk(fs->io, inode.i_block[EXT2_DIND_BLOCK], 1, block_buf); if (retval) goto errout; - + retval = ext2fs_create_resize_inode(fs); if (retval) goto errout; @@ -1750,7 +1750,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs) } } fs->super->s_free_blocks_count = total_free; - + /* * Next, calculate the inode statistics */ diff --git a/resize/resize2fs.h b/resize/resize2fs.h index 49b77d83..ed25b065 100644 --- a/resize/resize2fs.h +++ b/resize/resize2fs.h @@ -5,7 +5,7 @@ * PowerQuest, Inc. * * Copyright (C) 1999, 2000 by Theosore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -127,7 +127,7 @@ extern errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags, int pass, unsigned long cur, unsigned long max)); -extern errcode_t adjust_fs_info(ext2_filsys fs, ext2_filsys old_fs, +extern errcode_t adjust_fs_info(ext2_filsys fs, ext2_filsys old_fs, blk_t new_size); extern blk_t calculate_minimum_resize_size(ext2_filsys fs); @@ -144,7 +144,7 @@ extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u32 *old_loc, __u32 *new_loc, int *size); /* online.c */ -extern errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, +extern errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, blk_t *new_size, int flags); /* sim_progress.c */ diff --git a/resize/sim_progress.c b/resize/sim_progress.c index 400e364b..a575633b 100644 --- a/resize/sim_progress.c +++ b/resize/sim_progress.c @@ -5,7 +5,7 @@ * PowerQuest, Inc. * * Copyright (C) 1999, 2000 by Theosore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -58,7 +58,7 @@ void ext2fs_progress_update(ext2_sim_progmeter prog, __u32 current) num = level - old_level; if (num == 0) return; - + if (num > 0) { for (i=0; i < num; i++) putc('X', prog->f); @@ -100,7 +100,7 @@ errcode_t ext2fs_progress_init(ext2_sim_progmeter *ret_prog, prog->current = 0; prog->shown = 0; prog->f = stdout; - + *ret_prog = prog; return ext2fs_progress_display(prog); diff --git a/resize/test_extent.c b/resize/test_extent.c index 6a3f49dd..887b4760 100644 --- a/resize/test_extent.c +++ b/resize/test_extent.c @@ -5,7 +5,7 @@ * PowerQuest, Inc. * * Copyright (C) 1999, 2000 by Theosore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -25,7 +25,7 @@ void do_test(FILE *in, FILE *out) errcode_t retval; ext2_extent extent = 0; const char *no_table = "# No extent table\n"; - + while (!feof(in)) { if (!fgets(buf, sizeof(buf), in)) break; @@ -55,7 +55,7 @@ void do_test(FILE *in, FILE *out) *cp++ = '\0'; arg1 = cp; num1 = strtoul(arg1, 0, 0); - + cp = strchr(cp, ' '); } if (cp) { @@ -63,7 +63,7 @@ void do_test(FILE *in, FILE *out) arg2 = cp; num2 = strtoul(arg2, 0, 0); } - + if (!strcmp(cmd, "create")) { retval = ext2fs_create_extent_table(&extent, num1); if (retval) { @@ -77,7 +77,7 @@ void do_test(FILE *in, FILE *out) if (!extent) { fputs(no_table, out); continue; - } + } if (!strcmp(cmd, "free")) { ext2fs_free_extent_table(extent); extent = 0; @@ -105,7 +105,7 @@ void do_test(FILE *in, FILE *out) fprintf(out, "# %u -> %u (%d)\n", num1, num2, size); } - } else + } else fputs("# Syntax error\n", out); } } diff --git a/tests/progs/random_exercise.c b/tests/progs/random_exercise.c index 8f6fb2da..0be389fb 100644 --- a/tests/progs/random_exercise.c +++ b/tests/progs/random_exercise.c @@ -4,7 +4,7 @@ * directory, while holding some files open while they are being * deleted. This exercises the orphan list code, as well as * creating lots of fodder for the ext3 journal. - * + * * Copyright (C) 2000 Theodore Ts'o. * * %Begin-Header% @@ -74,7 +74,7 @@ void create_random_file() int fd; int isdir = 0; int size; - + mktemp(template); isdir = random() & 1; if (isdir) { @@ -84,7 +84,7 @@ void create_random_file() printf("Created temp directory %s, fd = %d\n", template, fd); } else { - size = random() & (DATA_SIZE-1); + size = random() & (DATA_SIZE-1); fd = open(template, O_CREAT|O_RDWR, 0600); write(fd, data_buffer, size); printf("Created temp file %s, fd = %d, size=%d\n", @@ -116,7 +116,7 @@ void truncate_file(int fd) void unlink_file(int fd) { char *filename = state_array[fd].name; - + printf("Deleting %s, fd = %d, ino = %u\n", filename, fd, get_inode_num(fd)); @@ -130,10 +130,10 @@ void unlink_file(int fd) void close_file(int fd) { char *filename = state_array[fd].name; - + printf("Closing %s, fd = %d, ino = %u\n", filename, fd, get_inode_num(fd)); - + close(fd); state_array[fd].state = STATE_CLEAR; } @@ -146,7 +146,7 @@ main(int argc, char **argv) memset(data_buffer, 0, sizeof(data_buffer)); sprintf(data_buffer, "This is a test file created by the " "random_exerciser program\n"); - + for (i=0; i < 100000; i++) { fd = get_random_fd(); switch (state_array[fd].state) { diff --git a/tests/progs/test_icount.c b/tests/progs/test_icount.c index faffcf8a..bb4073e4 100644 --- a/tests/progs/test_icount.c +++ b/tests/progs/test_icount.c @@ -1,6 +1,6 @@ /* * test_icount.c - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% @@ -51,7 +51,7 @@ static int parse_inode(const char *request, const char *desc, const char *str, ext2_ino_t *ino) { char *tmp; - + *ino = strtoul(str, &tmp, 0); if (*tmp) { com_err(request, 0, "Bad %s - %s", desc, str); @@ -105,7 +105,7 @@ void do_fetch(int argc, char **argv) errcode_t retval; ext2_ino_t ino; __u16 count; - + if (argc < 2) { printf(usage, argv[0]); return; @@ -128,7 +128,7 @@ void do_increment(int argc, char **argv) errcode_t retval; ext2_ino_t ino; __u16 count; - + if (argc < 2) { printf(usage, argv[0]); return; @@ -152,7 +152,7 @@ void do_decrement(int argc, char **argv) errcode_t retval; ext2_ino_t ino; __u16 count; - + if (argc < 2) { printf(usage, argv[0]); return; @@ -176,7 +176,7 @@ void do_store(int argc, char **argv) errcode_t retval; ext2_ino_t ino; ext2_ino_t count; - + if (argc < 3) { printf(usage, argv[0]); return; @@ -302,7 +302,7 @@ int main(int argc, char **argv) int exit_status = 0; char *cmd_file = 0; struct ext2_super_block param; - + initialize_ext2_error_table(); /* diff --git a/tests/progs/test_rel.c b/tests/progs/test_rel.c index 86a9b0da..e6997b65 100644 --- a/tests/progs/test_rel.c +++ b/tests/progs/test_rel.c @@ -1,6 +1,6 @@ /* * test_rel.c - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% @@ -39,7 +39,7 @@ static int parse_inode(const char *request, const char *desc, const char *str, ext2_ino_t *ino) { char *tmp; - + *ino = strtoul(str, &tmp, 0); if (*tmp) { com_err(request, 0, "Bad %s - %s", desc, str); @@ -55,7 +55,7 @@ static int parse_block(const char *request, const char *desc, const char *str, blk_t *blk) { char *tmp; - + *blk = strtoul(str, &tmp, 0); if (*tmp) { com_err(request, 0, "Bad %s - %s", desc, str); @@ -106,7 +106,7 @@ static void display_irel_entry(ext2_ino_t old, struct ext2_inode_reference ref; errcode_t retval; int first = 1; - + printf("Old= %lu, New= %lu, Original=%lu, Max_refs=%u\n", old, ent->new, ent->orig, ent->max_refs); if (!do_refs) @@ -145,7 +145,7 @@ void do_brel_ma_create(int argc, char **argv) const char *usage = "Usage: %s name max_blocks\n"; errcode_t retval; blk_t max_blk; - + if (argc < 3) { printf(usage, argv[0]); return; @@ -175,7 +175,7 @@ void do_brel_put(int argc, char **argv) errcode_t retval; struct ext2_block_relocate_entry ent; blk_t old, new, offset=0, owner=0; - + if (check_brel(argv[0])) return; @@ -294,7 +294,7 @@ void do_brel_dump(int argc, char **argv) } if (blk == 0) break; - + display_brel_entry(blk, &ent); } return; @@ -352,7 +352,7 @@ void do_irel_ma_create(int argc, char **argv) const char *usage = "Usage: %s name max_inode\n"; errcode_t retval; ext2_ino_t max_ino; - + if (argc < 3) { printf(usage, argv[0]); return; @@ -386,7 +386,7 @@ void do_irel_put(int argc, char **argv) if (check_irel(argv[0])) return; - + if (argc < 4) { printf(usage, argv[0]); return; @@ -422,7 +422,7 @@ void do_irel_get(int argc, char **argv) if (check_irel(argv[0])) return; - + if (argc < 2) { printf(usage, argv[0]); return; @@ -448,7 +448,7 @@ void do_irel_get_by_orig(int argc, char **argv) if (check_irel(argv[0])) return; - + if (argc < 2) { printf(usage, argv[0]); return; @@ -471,7 +471,7 @@ void do_irel_start_iter(int argc, char **argv) if (check_irel(argv[0])) return; - + retval = ext2fs_irel_start_iter(irel); if (retval) { com_err(argv[0], retval, "while calling ext2fs_irel_start_iter"); @@ -525,7 +525,7 @@ void do_irel_dump(int argc, char **argv) } if (ino == 0) break; - + display_irel_entry(ino, &ent, 1); } return; @@ -538,11 +538,11 @@ void do_irel_add_ref(int argc, char **argv) blk_t block, offset; ext2_ino_t ino; struct ext2_inode_reference ref; - + if (check_irel(argv[0])) return; - + if (argc < 4) { printf(usage, argv[0]); return; @@ -576,7 +576,7 @@ void do_irel_start_iter_ref(int argc, char **argv) if (check_irel(argv[0])) return; - + if (argc < 2) { printf(usage, argv[0]); return; @@ -599,7 +599,7 @@ void do_irel_next_ref(int argc, char **argv) if (check_irel(argv[0])) return; - + retval = ext2fs_irel_next_ref(irel, &ref); if (retval) { com_err(argv[0], retval, "while calling ext2fs_irel_next_ref"); @@ -617,7 +617,7 @@ void do_irel_move(int argc, char **argv) if (check_irel(argv[0])) return; - + if (argc < 3) { printf(usage, argv[0]); return; @@ -643,7 +643,7 @@ void do_irel_delete(int argc, char **argv) if (check_irel(argv[0])) return; - + if (argc < 2) { printf(usage, argv[0]); return; @@ -717,7 +717,7 @@ void main(int argc, char **argv) char *request = 0; int exit_status = 0; char *cmd_file = 0; - + initialize_ext2_error_table(); while ((c = getopt (argc, argv, "wR:f:")) != EOF) { diff --git a/tests/progs/test_rel.h b/tests/progs/test_rel.h index be864c9c..47c4d098 100644 --- a/tests/progs/test_rel.h +++ b/tests/progs/test_rel.h @@ -1,6 +1,6 @@ /* * test_rel.h - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% diff --git a/util/copy_sparse.c b/util/copy_sparse.c index aece6be2..cbab273e 100644 --- a/util/copy_sparse.c +++ b/util/copy_sparse.c @@ -1,7 +1,7 @@ /* * copy_sparse.c -- copy a very large sparse files efficiently * (requires root privileges) - * + * * Copyright 2003, 2004 by Theodore Ts'o. * * %Begin-Header% @@ -70,7 +70,7 @@ static int full_read(int fd, char *buf, size_t count) while (count > 0) { got = read(fd, buf, count); if (got == -1) { - if ((errno == EINTR) || (errno == EAGAIN)) + if ((errno == EINTR) || (errno == EAGAIN)) continue; return total ? total : -1; } @@ -97,7 +97,7 @@ static void copy_sparse_file(const char *src, const char *dest) if (verbose) printf("Copying sparse file from %s to %s\n", src, dest); - + if (strcmp(src, "-")) { if (stat64(src, &fileinfo) < 0) { perror("stat"); @@ -125,13 +125,13 @@ static void copy_sparse_file(const char *src, const char *dest) printf("Blocksize of file %s is %ld\n", src, bs); numblocks = (fileinfo.st_size + (bs-1)) / bs; if (verbose) - printf("File size of %s is %lld (%ld blocks)\n", src, + printf("File size of %s is %lld (%ld blocks)\n", src, (long long) fileinfo.st_size, numblocks); } else { fd = 0; bs = 1024; } - + ofd = open(dest, O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0777); if (ofd < 0) { perror(dest); @@ -143,7 +143,7 @@ static void copy_sparse_file(const char *src, const char *dest) fprintf(stderr, "Couldn't allocate buffer"); exit(1); } - + for (lb = 0; !fd || lb < numblocks; lb++) { if (fd) { block = get_bmap(fd, lb); @@ -170,7 +170,7 @@ static void copy_sparse_file(const char *src, const char *dest) break; if (got == bs) { - for (i=0; i < bs; i++) + for (i=0; i < bs; i++) if (buf[i]) break; if (i == bs) { diff --git a/util/subst.c b/util/subst.c index fadf3287..0015a9c4 100644 --- a/util/subst.c +++ b/util/subst.c @@ -2,7 +2,7 @@ * subst.c --- substitution program * * Subst is used as a quicky program to do @ substitutions - * + * */ #include <stdio.h> @@ -36,7 +36,7 @@ static int add_subst(char *name, char *value) { struct subst_entry *ent = 0; int retval; - + retval = ENOMEM; ent = (struct subst_entry *) malloc(sizeof(struct subst_entry)); if (!ent) @@ -91,7 +91,7 @@ static char *get_subst_symbol(const char *begin, size_t len, char prefix) return NULL; memcpy(start, begin, len); start[len] = 0; - + /* * The substitution variable must all be in the of [0-9A-Za-z_]. * If it isn't, this must be an invalid symbol name. @@ -154,7 +154,7 @@ static void substitute_line(char *line) } ent = fetch_subst_entry(replace_name); if (!ent) { - fprintf(stderr, "Unfound expansion: '%s'\n", + fprintf(stderr, "Unfound expansion: '%s'\n", replace_name); ptr = end_ptr + 1; continue; @@ -167,7 +167,7 @@ static void substitute_line(char *line) replace_string(ptr, end_ptr, ent->value); if ((ent->value[0] == '@') && (strlen(replace_name) == strlen(ent->value)-2) && - !strncmp(replace_name, ent->value+1, + !strncmp(replace_name, ent->value+1, strlen(ent->value)-2)) /* avoid an infinite loop */ ptr += strlen(ent->value); @@ -193,7 +193,7 @@ static void substitute_line(char *line) if (!replace_name) { ptr = name_ptr; continue; - } + } ent = fetch_subst_entry(replace_name); if (!ent) { ptr = end_ptr + 1; @@ -313,7 +313,7 @@ int main(int argc, char **argv) int adjust_timestamp = 0; struct stat stbuf; struct utimbuf ut; - + while ((c = getopt (argc, argv, "f:tv")) != EOF) { switch (c) { case 'f': @@ -332,7 +332,7 @@ int main(int argc, char **argv) verbose++; break; default: - fprintf(stderr, "%s: [-f config-file] [file]\n", + fprintf(stderr, "%s: [-f config-file] [file]\n", argv[0]); break; } @@ -346,7 +346,7 @@ int main(int argc, char **argv) optind++; } else in = stdin; - + if (optind < argc) { outfn = argv[optind]; newfn = (char *) malloc(strlen(outfn)+20); @@ -365,7 +365,7 @@ int main(int argc, char **argv) out = stdout; outfn = 0; } - + while (!feof(in)) { if (fgets(line, sizeof(line), in) == NULL) break; @@ -1,7 +1,7 @@ /* * version.h --- controls the version number printed by the e2fs * programs. - * + * * Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, * 2004, 2005, 2006, 2007, 2008 by Theodore Ts'o. This file may be * redistributed under the GNU Public License. |