summaryrefslogtreecommitdiff
path: root/e2fsprogs
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs')
-rw-r--r--e2fsprogs/Makefile.in2
-rw-r--r--e2fsprogs/e2fsck.c64
-rw-r--r--e2fsprogs/fsck.c9
-rw-r--r--e2fsprogs/fsck.h3
-rw-r--r--e2fsprogs/mke2fs.c8
-rw-r--r--e2fsprogs/util.c11
-rw-r--r--e2fsprogs/util.h2
7 files changed, 36 insertions, 63 deletions
diff --git a/e2fsprogs/Makefile.in b/e2fsprogs/Makefile.in
index 90aac63..181ec70 100644
--- a/e2fsprogs/Makefile.in
+++ b/e2fsprogs/Makefile.in
@@ -57,7 +57,7 @@ $(patsubst %,$(E2FSPROGS_DIR)/%, $(UUID_OBJS)):|$(E2FSPROGS_DIR)/uuid
E2FSPROGS-y:=
E2FSPROGS-$(CONFIG_CHATTR) += chattr.o $(E2P_OBJS)
E2FSPROGS-$(CONFIG_E2FSCK) += e2fsck.o util.o $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
-E2FSPROGS-$(CONFIG_FSCK) += fsck.o $(BLKID_OBJS) $(UUID_OBJS)
+E2FSPROGS-$(CONFIG_FSCK) += fsck.o util.o $(BLKID_OBJS) $(UUID_OBJS)
E2FSPROGS-$(CONFIG_LSATTR) += lsattr.o $(E2P_OBJS)
E2FSPROGS-$(CONFIG_MKE2FS) += mke2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
E2FSPROGS-$(CONFIG_TUNE2FS) += tune2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c
index 42ee8ab..8b96b50 100644
--- a/e2fsprogs/e2fsck.c
+++ b/e2fsprogs/e2fsck.c
@@ -79,18 +79,6 @@
#endif
/*
- * Exit codes used by fsck-type programs
- */
-#define FSCK_OK 0 /* No errors */
-#define FSCK_NONDESTRUCT 1 /* File system errors corrected */
-#define FSCK_REBOOT 2 /* System should be rebooted */
-#define FSCK_UNCORRECTED 4 /* File system errors left uncorrected */
-#define FSCK_ERROR 8 /* Operational error */
-#define FSCK_USAGE 16 /* Usage or syntax error */
-#define FSCK_CANCELED 32 /* Aborted with a signal or ^C */
-#define FSCK_LIBRARY 128 /* Shared library error */
-
-/*
* The last ext2fs revision level that this version of e2fsck is able to
* support
*/
@@ -14255,7 +14243,7 @@ void fatal_error(e2fsck_t ctx, const char *msg)
ctx->flags |= E2F_FLAG_ABORT;
if (ctx->flags & E2F_FLAG_SETJMP_OK)
longjmp(ctx->abort_loc, 1);
- exit(FSCK_ERROR);
+ exit(EXIT_ERROR);
}
#endif
@@ -14461,7 +14449,7 @@ void preenhalt(e2fsck_t ctx)
ext2fs_mark_super_dirty(fs);
ext2fs_close(fs);
}
- exit(FSCK_UNCORRECTED);
+ exit(EXIT_UNCORRECTED);
}
#ifdef RESOURCE_TRACK
@@ -14742,7 +14730,7 @@ static void usage(e2fsck_t ctx)
" -L bad_blocks_file Set badblocks list\n"
));
- exit(FSCK_USAGE);
+ exit(EXIT_USAGE);
}
#endif
@@ -14881,7 +14869,7 @@ static int is_on_batt(void)
/*
* This routine checks to see if a filesystem can be skipped; if so,
- * it will exit with E2FSCK_OK. Under some conditions it will print a
+ * it will exit with EXIT_OK. Under some conditions it will print a
* message explaining why a check is being forced.
*/
static void check_if_skip(e2fsck_t ctx)
@@ -14949,7 +14937,7 @@ static void check_if_skip(e2fsck_t ctx)
ext2fs_close(fs);
ctx->fs = NULL;
e2fsck_free_context(ctx);
- exit(FSCK_OK);
+ exit(EXIT_OK);
}
/*
@@ -15079,8 +15067,6 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass,
return 0;
}
-#define PATH_SET "PATH=/sbin"
-
static void reserve_stdio_fds(void)
{
int fd;
@@ -15379,14 +15365,14 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
if (cflag || bad_blocks_file) {
fprintf(stderr, _("Incompatible options not "
"allowed when byte-swapping.\n"));
- exit(FSCK_USAGE);
+ exit(EXIT_USAGE);
}
}
#endif
if (cflag && bad_blocks_file) {
fprintf(stderr, _("The -c and the -l/-L options may "
"not be both used at the same time.\n"));
- exit(FSCK_USAGE);
+ exit(EXIT_USAGE);
}
/*
* Set up signal action
@@ -15405,22 +15391,8 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
sigaction(SIGUSR2, &sa, 0);
/* Update our PATH to include /sbin if we need to run badblocks */
- if (cflag) {
- char *oldpath = getenv("PATH");
- if (oldpath) {
- char *newpath;
-
- newpath = (char *) malloc(sizeof (PATH_SET) + 1 +
- strlen (oldpath));
- if (!newpath)
- fatal_error(ctx, "Couldn't malloc() newpath");
- strcpy (newpath, PATH_SET);
- strcat (newpath, ":");
- strcat (newpath, oldpath);
- putenv (newpath);
- } else
- putenv (PATH_SET);
- }
+ if (cflag)
+ e2fs_set_sbin_path();
#ifdef __CONFIG_JBD_DEBUG__E2FS
if (getenv("E2FSCK_JBD_DEBUG"))
journal_enable_debug = atoi(getenv("E2FSCK_JBD_DEBUG"));
@@ -15434,7 +15406,7 @@ static const char my_ver_date[] = E2FSPROGS_DATE;
int e2fsck_main (int argc, char *argv[])
{
errcode_t retval;
- int exit_value = FSCK_OK;
+ int exit_value = EXIT_OK;
ext2_filsys fs = 0;
io_manager io_ptr;
struct ext2_super_block *sb;
@@ -15469,7 +15441,7 @@ int e2fsck_main (int argc, char *argv[])
if (retval) {
com_err("e2fsck", retval,
_("while trying to initialize program"));
- exit(FSCK_ERROR);
+ exit(EXIT_ERROR);
}
reserve_stdio_fds();
@@ -15484,7 +15456,7 @@ int e2fsck_main (int argc, char *argv[])
if (show_version_only) {
fprintf(stderr, _("\tUsing %s, %s\n"),
error_message(EXT2_ET_BASE), lib_ver_date);
- exit(FSCK_OK);
+ exit(EXIT_OK);
}
check_mount(ctx);
@@ -15756,30 +15728,30 @@ restart:
mtrace_print("Cleanup");
#endif
if (ext2fs_test_changed(fs)) {
- exit_value |= FSCK_NONDESTRUCT;
+ exit_value |= EXIT_NONDESTRUCT;
if (!(ctx->options & E2F_OPT_PREEN))
printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
ctx->device_name);
if (ctx->mount_flags & EXT2_MF_ISROOT) {
printf(_("%s: ***** REBOOT LINUX *****\n"),
ctx->device_name);
- exit_value |= FSCK_REBOOT;
+ exit_value |= EXIT_DESTRUCT;
}
}
if (!ext2fs_test_valid(fs)) {
printf(_("\n%s: ********** WARNING: Filesystem still has "
"errors **********\n\n"), ctx->device_name);
- exit_value |= FSCK_UNCORRECTED;
- exit_value &= ~FSCK_NONDESTRUCT;
+ exit_value |= EXIT_UNCORRECTED;
+ exit_value &= ~EXIT_NONDESTRUCT;
}
if (exit_value & FSCK_CANCELED)
- exit_value &= ~FSCK_NONDESTRUCT;
+ exit_value &= ~EXIT_NONDESTRUCT;
else {
show_stats(ctx);
if (!(ctx->options & E2F_OPT_READONLY)) {
if (ext2fs_test_valid(fs)) {
if (!(sb->s_state & EXT2_VALID_FS))
- exit_value |= FSCK_NONDESTRUCT;
+ exit_value |= EXIT_NONDESTRUCT;
sb->s_state = EXT2_VALID_FS;
} else
sb->s_state &= ~EXT2_VALID_FS;
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c
index 7799fae..36eebf2 100644
--- a/e2fsprogs/fsck.c
+++ b/e2fsprogs/fsck.c
@@ -282,7 +282,6 @@ static int kill_sent;
static char *fstype;
static struct fs_info *filesys_info, *filesys_last;
static struct fsck_instance *instance_list;
-static const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
static char *fsck_path;
static blkid_cache cache;
@@ -1349,7 +1348,6 @@ int fsck_main(int argc, char *argv[])
{
int i, status = 0;
int interactive = 0;
- char *oldpath = getenv("PATH");
const char *fstab;
struct fs_info *fs;
@@ -1367,12 +1365,7 @@ int fsck_main(int argc, char *argv[])
fstab = _PATH_MNTTAB;
load_fs_info(fstab);
- /* Update our search path to include uncommon directories. */
- if (oldpath) {
- fsck_path = bb_xasprintf("%s:%s", fsck_prefix_path, oldpath);
- } else {
- fsck_path = string_copy(fsck_prefix_path);
- }
+ e2fs_set_sbin_path();
if ((num_devices == 1) || (serialize))
interactive = 1;
diff --git a/e2fsprogs/fsck.h b/e2fsprogs/fsck.h
index 537b266..bd22fbb 100644
--- a/e2fsprogs/fsck.h
+++ b/e2fsprogs/fsck.h
@@ -10,4 +10,7 @@
#define EXIT_UNCORRECTED 4
#define EXIT_ERROR 8
#define EXIT_USAGE 16
+#define FSCK_CANCELED 32 /* Aborted with a signal or ^C */
#define EXIT_LIBRARY 128
+
+extern void e2fs_set_sbin_path(void);
diff --git a/e2fsprogs/mke2fs.c b/e2fsprogs/mke2fs.c
index ab50717..9c4f1c4 100644
--- a/e2fsprogs/mke2fs.c
+++ b/e2fsprogs/mke2fs.c
@@ -685,8 +685,6 @@ static int set_os(struct ext2_super_block *sb, char *os)
return 0;
}
-#define PATH_SET "PATH=/sbin"
-
static void parse_extended_opts(struct ext2_super_block *sb_param,
const char *opts)
{
@@ -801,17 +799,13 @@ static int PRS(int argc, char *argv[])
int show_version_only = 0;
ext2_ino_t num_inodes = 0;
errcode_t retval;
- char * oldpath = getenv("PATH");
char * extended_opts = 0;
const char * fs_type = 0;
blk_t dev_size;
long sysval;
/* Update our PATH to include /sbin */
- if (oldpath) {
- putenv (bb_xasprintf("%s:%s", PATH_SET, oldpath));
- } else
- putenv (PATH_SET);
+ e2fs_set_sbin_path();
tmp = getenv("MKE2FS_SYNC");
if (tmp)
diff --git a/e2fsprogs/util.c b/e2fsprogs/util.c
index 58f9bbb..e59b18c 100644
--- a/e2fsprogs/util.c
+++ b/e2fsprogs/util.c
@@ -253,3 +253,14 @@ void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, in
if(!quiet)
puts("done");
}
+
+void e2fs_set_sbin_path(void)
+{
+ char *oldpath = getenv("PATH");
+ /* Update our PATH to include /sbin */
+#define PATH_SET "/sbin"
+ if (oldpath)
+ putenv (bb_xasprintf("%s:%s", PATH_SET, oldpath));
+ else
+ putenv (PATH_SET);
+}
diff --git a/e2fsprogs/util.h b/e2fsprogs/util.h
index f6dc08a..4634b08 100644
--- a/e2fsprogs/util.h
+++ b/e2fsprogs/util.h
@@ -18,4 +18,4 @@ extern int figure_journal_size(int size, ext2_filsys fs);
extern void print_check_message(ext2_filsys fs);
extern void make_journal_device(char *journal_device, ext2_filsys fs, int quiet, int force);
extern void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, int quiet);
-
+extern void e2fs_set_sbin_path(void);