#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! */
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) ||
* This function will move the journal inode from a visible file in
* the filesystem directory hierarchy to the reserved inode if necessary.
*/
-static const char * const journal_names[] = {
+static const char *const journal_names[] = {
".journal", "journal", ".journal.dat", "journal.dat", 0 };
static void e2fsck_move_ext3_journal(e2fsck_t ctx)
ext2_filsys fs = ctx->fs;
ext2_ino_t ino;
errcode_t retval;
- const char * const * cpp;
+ const char *const * cpp;
int group, mount_flags;
clear_problem_context(&pctx);
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;
* abbreviation of the form '@<i>' is expanded by looking up the index
* letter <i> in the table below.
*/
-static const char * const abbrevs[] = {
+static const char *const abbrevs[] = {
N_("aextended attribute"),
N_("Aerror allocating"),
N_("bblock"),
* Give more user friendly names to the "special" inodes.
*/
#define num_special_inodes 11
-static const char * const special_inode_name[] =
+static const char *const special_inode_name[] =
{
N_("<The NULL inode>"), /* 0 */
N_("<The bad blocks inode>"), /* 1 */
ch -= 128;
}
if ((ch < 32) || (ch == 0x7f)) {
- fputc('^', stdout);
+ bb_putchar('^');
ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */
}
- fputc(ch, stdout);
+ bb_putchar(ch);
}
}
struct problem_context *pctx,
int *first)
{
- const char * const *cpp;
+ const char *const *cpp;
const char *str;
/* Search for the abbreviation */
str = _(*cpp) + 1;
if (*first && islower(*str)) {
*first = 0;
- fputc(toupper(*str++), stdout);
+ bb_putchar(toupper(*str++));
}
print_e2fsck_message(ctx, str, pctx, *first);
} else
switch (ch) {
case '%':
- fputc('%', stdout);
+ bb_putchar('%');
break;
case 'b':
printf("%u", ctx->blk);
printf("%u", ctx->ino2);
break;
case 'm':
- printf("%s", error_message(ctx->errcode));
+ fputs(error_message(ctx->errcode), stdout);
break;
case 'N':
printf("%"PRIi64, ctx->num);
printf("%d", get_backup_sb(NULL, fs, NULL, NULL));
break;
case 's':
- printf("%s", ctx->str ? ctx->str : "NULL");
+ fputs((ctx->str ? ctx->str : "NULL"), stdout);
break;
case 'X':
printf("0x%"PRIi64, ctx->num);
*/
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);
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");
}
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");
}
}
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;
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);
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);
else {
di = (struct dup_inode *) e2fsck_allocate_memory(ctx,
sizeof(struct dup_inode), "duplicate inode header");
- di->dir = (ino == EXT2_ROOT_INO) ? EXT2_ROOT_INO : 0 ;
+ di->dir = (ino == EXT2_ROOT_INO) ? EXT2_ROOT_INO : 0;
di->num_dupblocks = 0;
di->block_list = 0;
di->inode = *inode;
/* 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;
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;
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;
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;
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");
/*
* These are the prompts which are used to ask the user if they want
* to fix a problem.
*/
-static const char * const prompt[] = {
+static const char *const prompt[] = {
N_("(no prompt)"), /* 0 */
N_("Fix"), /* 1 */
N_("Clear"), /* 2 */
* These messages are printed when we are preen mode and we will be
* automatically fixing the problem.
*/
-static const char * const preen_msg[] = {
+static const char *const preen_msg[] = {
N_("(NONE)"), /* 0 */
N_("FIXED"), /* 1 */
N_("CLEARED"), /* 2 */
/* 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 */
* 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
shift = 0;
tmp = hash_size;
- while((tmp >>= 1UL) != 0UL)
+ while ((tmp >>= 1UL) != 0UL)
shift++;
journal->j_revoke->hash_shift = shift;
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;
}
int r;
int fail = 0;
- while(1) {
+ while (1) {
if (e2fsck_global_ctx &&
(e2fsck_global_ctx->flags & E2F_FLAG_CANCEL)) {
return 3;
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)
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) {
else
puts ("no\n");
#ifdef HAVE_TERMIOS_H
- tcsetattr (0, TCSANOW, &termios);
+ tcsetattr_stdin_TCSANOW(&termios);
#endif
return def;
}
sb = (struct ext2_super_block *) buf;
for (blocksize = EXT2_MIN_BLOCK_SIZE;
- blocksize <= EXT2_MAX_BLOCK_SIZE ; blocksize *= 2) {
+ blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) {
superblock = blocksize*8;
if (blocksize == 1024)
superblock++;
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;
}
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"));
cont = ask_yn(_("Do you really want to continue"), -1);
if (!cont) {
printf(_("check aborted.\n"));
- exit (0);
+ exit(0);
}
}
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;
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)
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;
else
printf(_(" (check in %ld mounts)"), next_check);
}
- fputc('\n', stdout);
+ bb_putchar('\n');
ext2fs_close(fs);
ctx->fs = NULL;
e2fsck_free_context(ctx);
bar + (sizeof(bar) - (i+1)),
spaces + (sizeof(spaces) - (dpywidth - i + 1)));
if (fixed_percent == 1000)
- fputc('|', stdout);
+ bb_putchar('|');
else
- fputc(spinner[ctx->progress_pos & 3], stdout);
+ bb_putchar(spinner[ctx->progress_pos & 3]);
printf(" %4.1f%% ", percent);
if (dpynum)
printf("%u\r", dpynum);
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,
}
-static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
+static errcode_t PRS(int argc, char **argv, e2fsck_t *ret_ctx)
{
int flush = 0;
int c, fd;
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;
static const char my_ver_string[] = E2FSPROGS_VERSION;
static const char my_ver_date[] = E2FSPROGS_DATE;
-int e2fsck_main (int argc, char *argv[]);
-int e2fsck_main (int argc, char *argv[])
+int e2fsck_main (int argc, char **argv);
+int e2fsck_main (int argc, char **argv)
{
errcode_t retval;
int exit_value = EXIT_OK;
* 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);
#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) {