X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=e2fsprogs%2Fold_e2fsprogs%2Fe2fsck.c;h=c715d3e9ae226d9cbc454575118496ec7e28b02d;hb=2ec91aead52d6ea6a42420005119ebb281a76cdc;hp=4887a57d723b4fc9e1dd7b8361b01ab467e7594f;hpb=605b20e277c558eb284595aacbcd3c21168894d3;p=oweals%2Fbusybox.git diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index 4887a57d7..c715d3e9a 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c @@ -192,10 +192,10 @@ struct buffer_head { #define K_DEV_FS 1 #define K_DEV_JOURNAL 2 -#define lock_buffer(bh) do {} while(0) -#define unlock_buffer(bh) do {} while(0) +#define lock_buffer(bh) do {} while (0) +#define unlock_buffer(bh) do {} while (0) #define buffer_req(bh) 1 -#define do_readahead(journal, start) do {} while(0) +#define do_readahead(journal, start) do {} while (0) static e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ @@ -1886,7 +1886,7 @@ static void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb, int i; /* Leave a valid existing V1 superblock signature alone. - * Anything unrecognisable we overwrite with a new V2 + * Anything unrecognizable we overwrite with a new V2 * signature. */ if (jsb->s_header.h_magic != htonl(JFS_MAGIC_NUMBER) || @@ -2270,7 +2270,7 @@ static void e2fsck_move_ext3_journal(e2fsck_t ctx) ext2fs_mark_super_dirty(fs); fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; inode.i_links_count = 0; - inode.i_dtime = time(0); + inode.i_dtime = time(NULL); if ((retval = ext2fs_write_inode(fs, ino, &inode)) != 0) goto err_out; @@ -3381,7 +3381,7 @@ static void e2fsck_pass1(e2fsck_t ctx) */ if (!LINUX_S_ISDIR(inode->i_mode)) { if (fix_problem(ctx, PR_1_ROOT_NO_DIR, &pctx)) { - inode->i_dtime = time(0); + inode->i_dtime = time(NULL); inode->i_links_count = 0; ext2fs_icount_store(ctx->inode_link_info, ino, 0); @@ -3475,7 +3475,7 @@ static void e2fsck_pass1(e2fsck_t ctx) inode->i_dtime < ctx->fs->super->s_inodes_count) { if (fix_problem(ctx, PR_1_LOW_DTIME, &pctx)) { inode->i_dtime = inode->i_links_count ? - 0 : time(0); + 0 : time(NULL); e2fsck_write_inode(ctx, ino, inode, "pass1"); } @@ -3489,7 +3489,7 @@ static void e2fsck_pass1(e2fsck_t ctx) if (!inode->i_dtime && inode->i_mode) { if (fix_problem(ctx, PR_1_ZERO_DTIME, &pctx)) { - inode->i_dtime = time(0); + inode->i_dtime = time(NULL); e2fsck_write_inode(ctx, ino, inode, "pass1"); } @@ -3659,7 +3659,7 @@ static void e2fsck_pass1(e2fsck_t ctx) } e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode, "recreate inode"); - inode->i_mtime = time(0); + inode->i_mtime = time(NULL); e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode, "recreate inode"); fs->block_map = save_bmap; @@ -4169,7 +4169,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, if (pb.clear) { inode->i_links_count = 0; ext2fs_icount_store(ctx->inode_link_info, ino, 0); - inode->i_dtime = time(0); + inode->i_dtime = time(NULL); dirty_inode++; ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino); ext2fs_unmark_inode_bitmap(ctx->inode_reg_map, ino); @@ -4202,7 +4202,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) { inode->i_links_count = 0; ext2fs_icount_store(ctx->inode_link_info, ino, 0); - inode->i_dtime = time(0); + inode->i_dtime = time(NULL); dirty_inode++; ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino); ext2fs_unmark_inode_bitmap(ctx->inode_reg_map, ino); @@ -5147,7 +5147,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino, /* Inode may have changed by block_iterate, so reread it */ e2fsck_read_inode(ctx, ino, &inode, "delete_file"); inode.i_links_count = 0; - inode.i_dtime = time(0); + inode.i_dtime = time(NULL); if (inode.i_file_acl && (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR)) { count = 1; @@ -6393,7 +6393,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf) ext2fs_icount_store(ctx->inode_link_info, ino, 0); e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode"); inode.i_links_count = 0; - inode.i_dtime = time(0); + inode.i_dtime = time(NULL); e2fsck_write_inode(ctx, ino, &inode, "deallocate_inode"); clear_problem_context(&pctx); pctx.ino = ino; @@ -6890,7 +6890,7 @@ static void check_root(e2fsck_t ctx) memset(&inode, 0, sizeof(inode)); inode.i_mode = 040755; inode.i_size = fs->blocksize; - inode.i_atime = inode.i_ctime = inode.i_mtime = time(0); + inode.i_atime = inode.i_ctime = inode.i_mtime = time(NULL); inode.i_links_count = 2; inode.i_blocks = fs->blocksize / 512; inode.i_block[0] = blk; @@ -7138,7 +7138,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix) memset(&inode, 0, sizeof(inode)); inode.i_mode = 040700; inode.i_size = fs->blocksize; - inode.i_atime = inode.i_ctime = inode.i_mtime = time(0); + inode.i_atime = inode.i_ctime = inode.i_mtime = time(NULL); inode.i_links_count = 2; inode.i_blocks = fs->blocksize / 512; inode.i_block[0] = blk; @@ -7492,7 +7492,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i) if (fix_problem(ctx, PR_4_ZERO_LEN_INODE, &pctx)) { ext2fs_icount_store(ctx->inode_link_info, i, 0); inode.i_links_count = 0; - inode.i_dtime = time(0); + inode.i_dtime = time(NULL); e2fsck_write_inode(ctx, i, &inode, "disconnect_inode"); /* @@ -9400,7 +9400,7 @@ static const struct e2fsck_problem problem_table[] = { /* Cannot proceed without a root inode. */ { PR_3_NO_ROOT_INODE_ABORT, - N_("Cannot proceed without a @r.\n"), + N_("can't proceed without a @r.\n"), PROMPT_NONE, PR_FATAL }, /* Internal error: couldn't find dir_info */ @@ -10014,7 +10014,7 @@ static int do_one_pass(journal_t *journal, * all of the sequence number checks. What are we going * to do with it? That depends on the pass... */ - switch(blocktype) { + switch (blocktype) { case JFS_DESCRIPTOR_BLOCK: /* If it is a valid descriptor block, replay it * in pass REPLAY; otherwise, just skip over the @@ -11158,7 +11158,7 @@ int journal_init_revoke(journal_t *journal, int hash_size) shift = 0; tmp = hash_size; - while((tmp >>= 1UL) != 0UL) + while ((tmp >>= 1UL) != 0UL) shift++; journal->j_revoke->hash_shift = shift; @@ -11558,7 +11558,7 @@ static int release_orphan_inodes(e2fsck_t ctx) if (!inode.i_links_count) { ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(inode.i_mode)); - inode.i_dtime = time(0); + inode.i_dtime = time(NULL); } else { inode.i_dtime = 0; } @@ -12251,7 +12251,7 @@ static int read_a_char(void) int r; int fail = 0; - while(1) { + while (1) { if (e2fsck_global_ctx && (e2fsck_global_ctx->flags & E2F_FLAG_CANCEL)) { return 3; @@ -12281,7 +12281,7 @@ static int ask_yn(const char * string, int def) tmp.c_lflag &= ~(ICANON | ECHO); tmp.c_cc[VMIN] = 1; tmp.c_cc[VTIME] = 0; - tcsetattr (0, TCSANOW, &tmp); + tcsetattr_stdin_TCSANOW(&tmp); #endif if (def == 1) @@ -12297,7 +12297,7 @@ static int ask_yn(const char * string, int def) break; if (c == 3) { #ifdef HAVE_TERMIOS_H - tcsetattr (0, TCSANOW, &termios); + tcsetattr_stdin_TCSANOW(&termios); #endif if (e2fsck_global_ctx && e2fsck_global_ctx->flags & E2F_FLAG_SETJMP_OK) { @@ -12323,7 +12323,7 @@ static int ask_yn(const char * string, int def) else puts ("no\n"); #ifdef HAVE_TERMIOS_H - tcsetattr (0, TCSANOW, &termios); + tcsetattr_stdin_TCSANOW(&termios); #endif return def; } @@ -12632,7 +12632,7 @@ static void check_mount(e2fsck_t ctx) retval = ext2fs_check_if_mounted(ctx->filesystem_name, &ctx->mount_flags); if (retval) { - bb_error_msg(_("while determining whether %s is mounted."), + bb_error_msg(_("while determining whether %s is mounted"), ctx->filesystem_name); return; } @@ -12653,7 +12653,7 @@ static void check_mount(e2fsck_t ctx) printf(_("%s is mounted. "), ctx->filesystem_name); if (!ctx->interactive) - bb_error_msg_and_die(_("Cannot continue, aborting.")); + bb_error_msg_and_die(_("can't continue, aborting")); printf(_("\n\n\007\007\007\007WARNING!!! " "Running e2fsck on a mounted filesystem may cause\n" "SEVERE filesystem damage.\007\007\007\n\n")); @@ -12672,7 +12672,7 @@ static int is_on_batt(void) unsigned int acflag; struct dirent* de; - f = fopen("/proc/apm", "r"); + f = fopen_for_read("/proc/apm"); if (f) { if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4) acflag = 1; @@ -12686,7 +12686,7 @@ static int is_on_batt(void) continue; snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state", de->d_name); - f = fopen(fname, "r"); + f = fopen_for_read(fname); if (!f) continue; if (fscanf(f, "%s %s", tmp2, tmp) != 2) @@ -12714,7 +12714,7 @@ static void check_if_skip(e2fsck_t ctx) unsigned int reason_arg = 0; long next_check; int batt = is_on_batt(); - time_t now = time(0); + time_t now = time(NULL); if ((ctx->options & E2F_OPT_FORCE) || cflag || swapfs) return; @@ -12892,7 +12892,7 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass, if (ctx->progress_fd) { sprintf(buf, "%d %lu %lu\n", pass, cur, max); - write(ctx->progress_fd, buf, strlen(buf)); + xwrite_str(ctx->progress_fd, buf); } else { percent = calc_percent(&e2fsck_tbl, pass, cur, max); e2fsck_simple_progress(ctx, ctx->device_name, @@ -13060,7 +13060,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: - bb_error_msg_and_die(_("Only one the options -p/-a, -n or -y may be specified.")); + bb_error_msg_and_die(_("only one the options -p/-a, -n or -y may be specified")); } ctx->options |= E2F_OPT_PREEN; break; @@ -13373,7 +13373,7 @@ restart: * happen, unless the hardware or * device driver is being bogus. */ - bb_error_msg(_("cannot set superblock flags on %s"), ctx->device_name); + bb_error_msg(_("can't set superblock flags on %s"), ctx->device_name); bb_error_msg_and_die(0); } retval = e2fsck_run_ext3_journal(ctx); @@ -13405,7 +13405,7 @@ restart: #ifdef ENABLE_COMPRESSION /* FIXME - do we support this at all? */ if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION) - bb_error_msg(_("Warning: compression support is experimental.")); + bb_error_msg(_("warning: compression support is experimental")); #endif #ifndef ENABLE_HTREE if (sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) {