aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-10-12 16:22:19 +0000
committer"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-10-12 16:22:19 +0000
commitd20cfbd3034ad41c0d99e7578156389f385c7340 (patch)
treeb6fa54ac8c77c11156f4f214a0cda7ab3c318a45
parent6c35c7c97628cb81eb26c2a059b0dde2879d91aa (diff)
downloadbusybox-w32-d20cfbd3034ad41c0d99e7578156389f385c7340.tar.gz
busybox-w32-d20cfbd3034ad41c0d99e7578156389f385c7340.tar.bz2
busybox-w32-d20cfbd3034ad41c0d99e7578156389f385c7340.zip
create e2fs_set_sbin_path(), noticed by Tito, Thanks
-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 90aac6327..181ec7033 100644
--- a/e2fsprogs/Makefile.in
+++ b/e2fsprogs/Makefile.in
@@ -57,7 +57,7 @@ $(patsubst %,$(E2FSPROGS_DIR)/%, $(UUID_OBJS)):|$(E2FSPROGS_DIR)/uuid
57E2FSPROGS-y:= 57E2FSPROGS-y:=
58E2FSPROGS-$(CONFIG_CHATTR) += chattr.o $(E2P_OBJS) 58E2FSPROGS-$(CONFIG_CHATTR) += chattr.o $(E2P_OBJS)
59E2FSPROGS-$(CONFIG_E2FSCK) += e2fsck.o util.o $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS) 59E2FSPROGS-$(CONFIG_E2FSCK) += e2fsck.o util.o $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
60E2FSPROGS-$(CONFIG_FSCK) += fsck.o $(BLKID_OBJS) $(UUID_OBJS) 60E2FSPROGS-$(CONFIG_FSCK) += fsck.o util.o $(BLKID_OBJS) $(UUID_OBJS)
61E2FSPROGS-$(CONFIG_LSATTR) += lsattr.o $(E2P_OBJS) 61E2FSPROGS-$(CONFIG_LSATTR) += lsattr.o $(E2P_OBJS)
62E2FSPROGS-$(CONFIG_MKE2FS) += mke2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS) 62E2FSPROGS-$(CONFIG_MKE2FS) += mke2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS)
63E2FSPROGS-$(CONFIG_TUNE2FS) += tune2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS) 63E2FSPROGS-$(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 42ee8abc4..8b96b5068 100644
--- a/e2fsprogs/e2fsck.c
+++ b/e2fsprogs/e2fsck.c
@@ -79,18 +79,6 @@
79#endif 79#endif
80 80
81/* 81/*
82 * Exit codes used by fsck-type programs
83 */
84#define FSCK_OK 0 /* No errors */
85#define FSCK_NONDESTRUCT 1 /* File system errors corrected */
86#define FSCK_REBOOT 2 /* System should be rebooted */
87#define FSCK_UNCORRECTED 4 /* File system errors left uncorrected */
88#define FSCK_ERROR 8 /* Operational error */
89#define FSCK_USAGE 16 /* Usage or syntax error */
90#define FSCK_CANCELED 32 /* Aborted with a signal or ^C */
91#define FSCK_LIBRARY 128 /* Shared library error */
92
93/*
94 * The last ext2fs revision level that this version of e2fsck is able to 82 * The last ext2fs revision level that this version of e2fsck is able to
95 * support 83 * support
96 */ 84 */
@@ -14255,7 +14243,7 @@ void fatal_error(e2fsck_t ctx, const char *msg)
14255 ctx->flags |= E2F_FLAG_ABORT; 14243 ctx->flags |= E2F_FLAG_ABORT;
14256 if (ctx->flags & E2F_FLAG_SETJMP_OK) 14244 if (ctx->flags & E2F_FLAG_SETJMP_OK)
14257 longjmp(ctx->abort_loc, 1); 14245 longjmp(ctx->abort_loc, 1);
14258 exit(FSCK_ERROR); 14246 exit(EXIT_ERROR);
14259} 14247}
14260#endif 14248#endif
14261 14249
@@ -14461,7 +14449,7 @@ void preenhalt(e2fsck_t ctx)
14461 ext2fs_mark_super_dirty(fs); 14449 ext2fs_mark_super_dirty(fs);
14462 ext2fs_close(fs); 14450 ext2fs_close(fs);
14463 } 14451 }
14464 exit(FSCK_UNCORRECTED); 14452 exit(EXIT_UNCORRECTED);
14465} 14453}
14466 14454
14467#ifdef RESOURCE_TRACK 14455#ifdef RESOURCE_TRACK
@@ -14742,7 +14730,7 @@ static void usage(e2fsck_t ctx)
14742 " -L bad_blocks_file Set badblocks list\n" 14730 " -L bad_blocks_file Set badblocks list\n"
14743 )); 14731 ));
14744 14732
14745 exit(FSCK_USAGE); 14733 exit(EXIT_USAGE);
14746} 14734}
14747#endif 14735#endif
14748 14736
@@ -14881,7 +14869,7 @@ static int is_on_batt(void)
14881 14869
14882/* 14870/*
14883 * This routine checks to see if a filesystem can be skipped; if so, 14871 * This routine checks to see if a filesystem can be skipped; if so,
14884 * it will exit with E2FSCK_OK. Under some conditions it will print a 14872 * it will exit with EXIT_OK. Under some conditions it will print a
14885 * message explaining why a check is being forced. 14873 * message explaining why a check is being forced.
14886 */ 14874 */
14887static void check_if_skip(e2fsck_t ctx) 14875static void check_if_skip(e2fsck_t ctx)
@@ -14949,7 +14937,7 @@ static void check_if_skip(e2fsck_t ctx)
14949 ext2fs_close(fs); 14937 ext2fs_close(fs);
14950 ctx->fs = NULL; 14938 ctx->fs = NULL;
14951 e2fsck_free_context(ctx); 14939 e2fsck_free_context(ctx);
14952 exit(FSCK_OK); 14940 exit(EXIT_OK);
14953} 14941}
14954 14942
14955/* 14943/*
@@ -15079,8 +15067,6 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass,
15079 return 0; 15067 return 0;
15080} 15068}
15081 15069
15082#define PATH_SET "PATH=/sbin"
15083
15084static void reserve_stdio_fds(void) 15070static void reserve_stdio_fds(void)
15085{ 15071{
15086 int fd; 15072 int fd;
@@ -15379,14 +15365,14 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
15379 if (cflag || bad_blocks_file) { 15365 if (cflag || bad_blocks_file) {
15380 fprintf(stderr, _("Incompatible options not " 15366 fprintf(stderr, _("Incompatible options not "
15381 "allowed when byte-swapping.\n")); 15367 "allowed when byte-swapping.\n"));
15382 exit(FSCK_USAGE); 15368 exit(EXIT_USAGE);
15383 } 15369 }
15384 } 15370 }
15385#endif 15371#endif
15386 if (cflag && bad_blocks_file) { 15372 if (cflag && bad_blocks_file) {
15387 fprintf(stderr, _("The -c and the -l/-L options may " 15373 fprintf(stderr, _("The -c and the -l/-L options may "
15388 "not be both used at the same time.\n")); 15374 "not be both used at the same time.\n"));
15389 exit(FSCK_USAGE); 15375 exit(EXIT_USAGE);
15390 } 15376 }
15391 /* 15377 /*
15392 * Set up signal action 15378 * Set up signal action
@@ -15405,22 +15391,8 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
15405 sigaction(SIGUSR2, &sa, 0); 15391 sigaction(SIGUSR2, &sa, 0);
15406 15392
15407 /* Update our PATH to include /sbin if we need to run badblocks */ 15393 /* Update our PATH to include /sbin if we need to run badblocks */
15408 if (cflag) { 15394 if (cflag)
15409 char *oldpath = getenv("PATH"); 15395 e2fs_set_sbin_path();
15410 if (oldpath) {
15411 char *newpath;
15412
15413 newpath = (char *) malloc(sizeof (PATH_SET) + 1 +
15414 strlen (oldpath));
15415 if (!newpath)
15416 fatal_error(ctx, "Couldn't malloc() newpath");
15417 strcpy (newpath, PATH_SET);
15418 strcat (newpath, ":");
15419 strcat (newpath, oldpath);
15420 putenv (newpath);
15421 } else
15422 putenv (PATH_SET);
15423 }
15424#ifdef __CONFIG_JBD_DEBUG__E2FS 15396#ifdef __CONFIG_JBD_DEBUG__E2FS
15425 if (getenv("E2FSCK_JBD_DEBUG")) 15397 if (getenv("E2FSCK_JBD_DEBUG"))
15426 journal_enable_debug = atoi(getenv("E2FSCK_JBD_DEBUG")); 15398 journal_enable_debug = atoi(getenv("E2FSCK_JBD_DEBUG"));
@@ -15434,7 +15406,7 @@ static const char my_ver_date[] = E2FSPROGS_DATE;
15434int e2fsck_main (int argc, char *argv[]) 15406int e2fsck_main (int argc, char *argv[])
15435{ 15407{
15436 errcode_t retval; 15408 errcode_t retval;
15437 int exit_value = FSCK_OK; 15409 int exit_value = EXIT_OK;
15438 ext2_filsys fs = 0; 15410 ext2_filsys fs = 0;
15439 io_manager io_ptr; 15411 io_manager io_ptr;
15440 struct ext2_super_block *sb; 15412 struct ext2_super_block *sb;
@@ -15469,7 +15441,7 @@ int e2fsck_main (int argc, char *argv[])
15469 if (retval) { 15441 if (retval) {
15470 com_err("e2fsck", retval, 15442 com_err("e2fsck", retval,
15471 _("while trying to initialize program")); 15443 _("while trying to initialize program"));
15472 exit(FSCK_ERROR); 15444 exit(EXIT_ERROR);
15473 } 15445 }
15474 reserve_stdio_fds(); 15446 reserve_stdio_fds();
15475 15447
@@ -15484,7 +15456,7 @@ int e2fsck_main (int argc, char *argv[])
15484 if (show_version_only) { 15456 if (show_version_only) {
15485 fprintf(stderr, _("\tUsing %s, %s\n"), 15457 fprintf(stderr, _("\tUsing %s, %s\n"),
15486 error_message(EXT2_ET_BASE), lib_ver_date); 15458 error_message(EXT2_ET_BASE), lib_ver_date);
15487 exit(FSCK_OK); 15459 exit(EXIT_OK);
15488 } 15460 }
15489 15461
15490 check_mount(ctx); 15462 check_mount(ctx);
@@ -15756,30 +15728,30 @@ restart:
15756 mtrace_print("Cleanup"); 15728 mtrace_print("Cleanup");
15757#endif 15729#endif
15758 if (ext2fs_test_changed(fs)) { 15730 if (ext2fs_test_changed(fs)) {
15759 exit_value |= FSCK_NONDESTRUCT; 15731 exit_value |= EXIT_NONDESTRUCT;
15760 if (!(ctx->options & E2F_OPT_PREEN)) 15732 if (!(ctx->options & E2F_OPT_PREEN))
15761 printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"), 15733 printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
15762 ctx->device_name); 15734 ctx->device_name);
15763 if (ctx->mount_flags & EXT2_MF_ISROOT) { 15735 if (ctx->mount_flags & EXT2_MF_ISROOT) {
15764 printf(_("%s: ***** REBOOT LINUX *****\n"), 15736 printf(_("%s: ***** REBOOT LINUX *****\n"),
15765 ctx->device_name); 15737 ctx->device_name);
15766 exit_value |= FSCK_REBOOT; 15738 exit_value |= EXIT_DESTRUCT;
15767 } 15739 }
15768 } 15740 }
15769 if (!ext2fs_test_valid(fs)) { 15741 if (!ext2fs_test_valid(fs)) {
15770 printf(_("\n%s: ********** WARNING: Filesystem still has " 15742 printf(_("\n%s: ********** WARNING: Filesystem still has "
15771 "errors **********\n\n"), ctx->device_name); 15743 "errors **********\n\n"), ctx->device_name);
15772 exit_value |= FSCK_UNCORRECTED; 15744 exit_value |= EXIT_UNCORRECTED;
15773 exit_value &= ~FSCK_NONDESTRUCT; 15745 exit_value &= ~EXIT_NONDESTRUCT;
15774 } 15746 }
15775 if (exit_value & FSCK_CANCELED) 15747 if (exit_value & FSCK_CANCELED)
15776 exit_value &= ~FSCK_NONDESTRUCT; 15748 exit_value &= ~EXIT_NONDESTRUCT;
15777 else { 15749 else {
15778 show_stats(ctx); 15750 show_stats(ctx);
15779 if (!(ctx->options & E2F_OPT_READONLY)) { 15751 if (!(ctx->options & E2F_OPT_READONLY)) {
15780 if (ext2fs_test_valid(fs)) { 15752 if (ext2fs_test_valid(fs)) {
15781 if (!(sb->s_state & EXT2_VALID_FS)) 15753 if (!(sb->s_state & EXT2_VALID_FS))
15782 exit_value |= FSCK_NONDESTRUCT; 15754 exit_value |= EXIT_NONDESTRUCT;
15783 sb->s_state = EXT2_VALID_FS; 15755 sb->s_state = EXT2_VALID_FS;
15784 } else 15756 } else
15785 sb->s_state &= ~EXT2_VALID_FS; 15757 sb->s_state &= ~EXT2_VALID_FS;
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c
index 7799faec0..36eebf2c5 100644
--- a/e2fsprogs/fsck.c
+++ b/e2fsprogs/fsck.c
@@ -282,7 +282,6 @@ static int kill_sent;
282static char *fstype; 282static char *fstype;
283static struct fs_info *filesys_info, *filesys_last; 283static struct fs_info *filesys_info, *filesys_last;
284static struct fsck_instance *instance_list; 284static struct fsck_instance *instance_list;
285static const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
286static char *fsck_path; 285static char *fsck_path;
287static blkid_cache cache; 286static blkid_cache cache;
288 287
@@ -1349,7 +1348,6 @@ int fsck_main(int argc, char *argv[])
1349{ 1348{
1350 int i, status = 0; 1349 int i, status = 0;
1351 int interactive = 0; 1350 int interactive = 0;
1352 char *oldpath = getenv("PATH");
1353 const char *fstab; 1351 const char *fstab;
1354 struct fs_info *fs; 1352 struct fs_info *fs;
1355 1353
@@ -1367,12 +1365,7 @@ int fsck_main(int argc, char *argv[])
1367 fstab = _PATH_MNTTAB; 1365 fstab = _PATH_MNTTAB;
1368 load_fs_info(fstab); 1366 load_fs_info(fstab);
1369 1367
1370 /* Update our search path to include uncommon directories. */ 1368 e2fs_set_sbin_path();
1371 if (oldpath) {
1372 fsck_path = bb_xasprintf("%s:%s", fsck_prefix_path, oldpath);
1373 } else {
1374 fsck_path = string_copy(fsck_prefix_path);
1375 }
1376 1369
1377 if ((num_devices == 1) || (serialize)) 1370 if ((num_devices == 1) || (serialize))
1378 interactive = 1; 1371 interactive = 1;
diff --git a/e2fsprogs/fsck.h b/e2fsprogs/fsck.h
index 537b26619..bd22fbb24 100644
--- a/e2fsprogs/fsck.h
+++ b/e2fsprogs/fsck.h
@@ -10,4 +10,7 @@
10#define EXIT_UNCORRECTED 4 10#define EXIT_UNCORRECTED 4
11#define EXIT_ERROR 8 11#define EXIT_ERROR 8
12#define EXIT_USAGE 16 12#define EXIT_USAGE 16
13#define FSCK_CANCELED 32 /* Aborted with a signal or ^C */
13#define EXIT_LIBRARY 128 14#define EXIT_LIBRARY 128
15
16extern void e2fs_set_sbin_path(void);
diff --git a/e2fsprogs/mke2fs.c b/e2fsprogs/mke2fs.c
index ab50717e7..9c4f1c4d0 100644
--- a/e2fsprogs/mke2fs.c
+++ b/e2fsprogs/mke2fs.c
@@ -685,8 +685,6 @@ static int set_os(struct ext2_super_block *sb, char *os)
685 return 0; 685 return 0;
686} 686}
687 687
688#define PATH_SET "PATH=/sbin"
689
690static void parse_extended_opts(struct ext2_super_block *sb_param, 688static void parse_extended_opts(struct ext2_super_block *sb_param,
691 const char *opts) 689 const char *opts)
692{ 690{
@@ -801,17 +799,13 @@ static int PRS(int argc, char *argv[])
801 int show_version_only = 0; 799 int show_version_only = 0;
802 ext2_ino_t num_inodes = 0; 800 ext2_ino_t num_inodes = 0;
803 errcode_t retval; 801 errcode_t retval;
804 char * oldpath = getenv("PATH");
805 char * extended_opts = 0; 802 char * extended_opts = 0;
806 const char * fs_type = 0; 803 const char * fs_type = 0;
807 blk_t dev_size; 804 blk_t dev_size;
808 long sysval; 805 long sysval;
809 806
810 /* Update our PATH to include /sbin */ 807 /* Update our PATH to include /sbin */
811 if (oldpath) { 808 e2fs_set_sbin_path();
812 putenv (bb_xasprintf("%s:%s", PATH_SET, oldpath));
813 } else
814 putenv (PATH_SET);
815 809
816 tmp = getenv("MKE2FS_SYNC"); 810 tmp = getenv("MKE2FS_SYNC");
817 if (tmp) 811 if (tmp)
diff --git a/e2fsprogs/util.c b/e2fsprogs/util.c
index 58f9bbb88..e59b18c5a 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
253 if(!quiet) 253 if(!quiet)
254 puts("done"); 254 puts("done");
255} 255}
256
257void e2fs_set_sbin_path(void)
258{
259 char *oldpath = getenv("PATH");
260 /* Update our PATH to include /sbin */
261#define PATH_SET "/sbin"
262 if (oldpath)
263 putenv (bb_xasprintf("%s:%s", PATH_SET, oldpath));
264 else
265 putenv (PATH_SET);
266}
diff --git a/e2fsprogs/util.h b/e2fsprogs/util.h
index f6dc08ac1..4634b08dd 100644
--- a/e2fsprogs/util.h
+++ b/e2fsprogs/util.h
@@ -18,4 +18,4 @@ extern int figure_journal_size(int size, ext2_filsys fs);
18extern void print_check_message(ext2_filsys fs); 18extern void print_check_message(ext2_filsys fs);
19extern void make_journal_device(char *journal_device, ext2_filsys fs, int quiet, int force); 19extern void make_journal_device(char *journal_device, ext2_filsys fs, int quiet, int force);
20extern void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, int quiet); 20extern void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, int quiet);
21 21extern void e2fs_set_sbin_path(void);