diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-13 05:52:03 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-13 05:52:03 +0200 |
commit | 6683745bf78917562af843ecd17c4f3d04313a77 (patch) | |
tree | bab05cbca36db48f787a6405a2bfbd4dfbc102a7 | |
parent | c541a8955d20080c7a5e0c13e15bef8740eb3565 (diff) | |
download | busybox-w32-6683745bf78917562af843ecd17c4f3d04313a77.tar.gz busybox-w32-6683745bf78917562af843ecd17c4f3d04313a77.tar.bz2 busybox-w32-6683745bf78917562af843ecd17c4f3d04313a77.zip |
fsck: remove a few statics
function old new delta
kill_all_if_got_signal - 60 +60
notitle 1 - -1
doall 1 - -1
cancel_requested 1 - -1
num_devices 4 - -4
devices 4 - -4
signal_cancel 8 - -8
fsck_main 1893 1870 -23
kill_all_if_cancel_requested 60 - -60
------------------------------------------------------------------------------
(add/remove: 1/7 grow/shrink: 0/1 up/down: 60/-102) Total: -42 bytes
text data bss dec hex filename
824205 458 6956 831619 cb083 busybox_old
824174 458 6948 831580 cb05c busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | e2fsprogs/fsck.c | 93 |
1 files changed, 42 insertions, 51 deletions
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index 3c6cafbd3..c4d0b03ef 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c | |||
@@ -103,9 +103,7 @@ static const char really_wanted[] ALIGN1 = | |||
103 | 103 | ||
104 | #define BASE_MD "/dev/md" | 104 | #define BASE_MD "/dev/md" |
105 | 105 | ||
106 | static char **devices; | ||
107 | static char **args; | 106 | static char **args; |
108 | static int num_devices; | ||
109 | static int num_args; | 107 | static int num_args; |
110 | static int verbose; | 108 | static int verbose; |
111 | 109 | ||
@@ -116,13 +114,10 @@ static char **fs_type_list; | |||
116 | static uint8_t *fs_type_flag; | 114 | static uint8_t *fs_type_flag; |
117 | static smallint fs_type_negated; | 115 | static smallint fs_type_negated; |
118 | 116 | ||
119 | static volatile smallint cancel_requested; | ||
120 | static smallint doall; | ||
121 | static smallint noexecute; | 117 | static smallint noexecute; |
122 | static smallint serialize; | 118 | static smallint serialize; |
123 | static smallint skip_root; | 119 | static smallint skip_root; |
124 | /* static smallint like_mount; */ | 120 | /* static smallint like_mount; */ |
125 | static smallint notitle; | ||
126 | static smallint parallel_root; | 121 | static smallint parallel_root; |
127 | static smallint force_all_parallel; | 122 | static smallint force_all_parallel; |
128 | 123 | ||
@@ -353,13 +348,13 @@ static int progress_active(void) | |||
353 | /* | 348 | /* |
354 | * Send a signal to all outstanding fsck child processes | 349 | * Send a signal to all outstanding fsck child processes |
355 | */ | 350 | */ |
356 | static void kill_all_if_cancel_requested(void) | 351 | static void kill_all_if_got_signal(void) |
357 | { | 352 | { |
358 | static smallint kill_sent; | 353 | static smallint kill_sent; |
359 | 354 | ||
360 | struct fsck_instance *inst; | 355 | struct fsck_instance *inst; |
361 | 356 | ||
362 | if (!cancel_requested || kill_sent) | 357 | if (!bb_got_signal || kill_sent) |
363 | return; | 358 | return; |
364 | 359 | ||
365 | for (inst = instance_list; inst; inst = inst->next) { | 360 | for (inst = instance_list; inst; inst = inst->next) { |
@@ -388,7 +383,7 @@ static int wait_one(int flags) | |||
388 | 383 | ||
389 | while (1) { | 384 | while (1) { |
390 | pid = waitpid(-1, &status, flags); | 385 | pid = waitpid(-1, &status, flags); |
391 | kill_all_if_cancel_requested(); | 386 | kill_all_if_got_signal(); |
392 | if (pid == 0) /* flags == WNOHANG and no children exited */ | 387 | if (pid == 0) /* flags == WNOHANG and no children exited */ |
393 | return -1; | 388 | return -1; |
394 | if (pid < 0) { | 389 | if (pid < 0) { |
@@ -788,7 +783,7 @@ static int check_all(void) | |||
788 | pass_done = 1; | 783 | pass_done = 1; |
789 | 784 | ||
790 | for (fs = filesys_info; fs; fs = fs->next) { | 785 | for (fs = filesys_info; fs; fs = fs->next) { |
791 | if (cancel_requested) | 786 | if (bb_got_signal) |
792 | break; | 787 | break; |
793 | if (fs->flags & FLAG_DONE) | 788 | if (fs->flags & FLAG_DONE) |
794 | continue; | 789 | continue; |
@@ -828,7 +823,7 @@ static int check_all(void) | |||
828 | break; | 823 | break; |
829 | } | 824 | } |
830 | } | 825 | } |
831 | if (cancel_requested) | 826 | if (bb_got_signal) |
832 | break; | 827 | break; |
833 | if (verbose > 1) | 828 | if (verbose > 1) |
834 | printf("--waiting-- (pass %d)\n", passno); | 829 | printf("--waiting-- (pass %d)\n", passno); |
@@ -841,7 +836,7 @@ static int check_all(void) | |||
841 | } else | 836 | } else |
842 | not_done_yet = 1; | 837 | not_done_yet = 1; |
843 | } | 838 | } |
844 | kill_all_if_cancel_requested(); | 839 | kill_all_if_got_signal(); |
845 | status |= wait_many(FLAG_WAIT_ATLEAST_ONE); | 840 | status |= wait_many(FLAG_WAIT_ATLEAST_ONE); |
846 | return status; | 841 | return status; |
847 | } | 842 | } |
@@ -904,22 +899,39 @@ static void compile_fs_type(char *fs_type) | |||
904 | } | 899 | } |
905 | } | 900 | } |
906 | 901 | ||
907 | static void parse_args(char **argv) | 902 | int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
903 | int fsck_main(int argc UNUSED_PARAM, char **argv) | ||
908 | { | 904 | { |
909 | int i, j; | 905 | int i, status; |
910 | char *arg, *tmp; | 906 | /*int interactive;*/ |
911 | char *options; | 907 | struct fs_info *fs; |
912 | int optpos; | 908 | const char *fstab; |
913 | int opts_for_fsck = 0; | 909 | char *tmp; |
910 | char **devices; | ||
911 | int num_devices; | ||
912 | smallint opts_for_fsck; | ||
913 | smallint doall; | ||
914 | smallint notitle; | ||
914 | 915 | ||
915 | /* in bss, so already zeroed | 916 | /* we want wait() to be interruptible */ |
917 | signal_no_SA_RESTART_empty_mask(SIGINT, record_signo); | ||
918 | signal_no_SA_RESTART_empty_mask(SIGTERM, record_signo); | ||
919 | |||
920 | setbuf(stdout, NULL); | ||
921 | |||
922 | opts_for_fsck = doall = notitle = 0; | ||
923 | devices = NULL; | ||
916 | num_devices = 0; | 924 | num_devices = 0; |
925 | /* in bss, so already zeroed | ||
926 | args = NULL; | ||
917 | num_args = 0; | 927 | num_args = 0; |
918 | instance_list = NULL; | 928 | instance_list = NULL; |
919 | */ | 929 | */ |
920 | 930 | while (*++argv) { | |
921 | for (i = 1; argv[i]; i++) { | 931 | int j; |
922 | arg = argv[i]; | 932 | int optpos; |
933 | char *options; | ||
934 | char *arg = *argv; | ||
923 | 935 | ||
924 | /* "/dev/blk" or "/path" or "UUID=xxx" or "LABEL=xxx" */ | 936 | /* "/dev/blk" or "/path" or "UUID=xxx" or "LABEL=xxx" */ |
925 | if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) { | 937 | if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) { |
@@ -927,13 +939,13 @@ static void parse_args(char **argv) | |||
927 | // "/path", "UUID=xxx" or "LABEL=xxx" into block device name | 939 | // "/path", "UUID=xxx" or "LABEL=xxx" into block device name |
928 | // ("UUID=xxx"/"LABEL=xxx" can probably shifted to fsck.auto duties) | 940 | // ("UUID=xxx"/"LABEL=xxx" can probably shifted to fsck.auto duties) |
929 | devices = xrealloc_vector(devices, 2, num_devices); | 941 | devices = xrealloc_vector(devices, 2, num_devices); |
930 | devices[num_devices++] = xstrdup(arg); | 942 | devices[num_devices++] = arg; |
931 | continue; | 943 | continue; |
932 | } | 944 | } |
933 | 945 | ||
934 | if (arg[0] != '-' || opts_for_fsck) { | 946 | if (arg[0] != '-' || opts_for_fsck) { |
935 | args = xrealloc_vector(args, 2, num_args); | 947 | args = xrealloc_vector(args, 2, num_args); |
936 | args[num_args++] = xstrdup(arg); | 948 | args[num_args++] = arg; |
937 | continue; | 949 | continue; |
938 | } | 950 | } |
939 | 951 | ||
@@ -957,8 +969,9 @@ static void parse_args(char **argv) | |||
957 | goto next_arg; | 969 | goto next_arg; |
958 | } | 970 | } |
959 | /* -C n */ | 971 | /* -C n */ |
960 | if (!argv[++i]) bb_show_usage(); | 972 | if (!*++argv) |
961 | progress_fd = xatoi_u(argv[i]); | 973 | bb_show_usage(); |
974 | progress_fd = xatoi_u(*argv); | ||
962 | goto next_arg; | 975 | goto next_arg; |
963 | #endif | 976 | #endif |
964 | case 'V': | 977 | case 'V': |
@@ -987,8 +1000,8 @@ static void parse_args(char **argv) | |||
987 | bb_show_usage(); | 1000 | bb_show_usage(); |
988 | if (arg[++j]) | 1001 | if (arg[++j]) |
989 | tmp = &arg[j]; | 1002 | tmp = &arg[j]; |
990 | else if (argv[++i]) | 1003 | else if (*++argv) |
991 | tmp = argv[i]; | 1004 | tmp = *argv; |
992 | else | 1005 | else |
993 | bb_show_usage(); | 1006 | bb_show_usage(); |
994 | fstype = xstrdup(tmp); | 1007 | fstype = xstrdup(tmp); |
@@ -1018,28 +1031,6 @@ static void parse_args(char **argv) | |||
1018 | tmp = getenv("FSCK_MAX_INST"); | 1031 | tmp = getenv("FSCK_MAX_INST"); |
1019 | if (tmp) | 1032 | if (tmp) |
1020 | max_running = xatoi(tmp); | 1033 | max_running = xatoi(tmp); |
1021 | } | ||
1022 | |||
1023 | static void signal_cancel(int sig UNUSED_PARAM) | ||
1024 | { | ||
1025 | cancel_requested = 1; | ||
1026 | } | ||
1027 | |||
1028 | int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
1029 | int fsck_main(int argc UNUSED_PARAM, char **argv) | ||
1030 | { | ||
1031 | int i, status; | ||
1032 | /*int interactive;*/ | ||
1033 | const char *fstab; | ||
1034 | struct fs_info *fs; | ||
1035 | |||
1036 | /* we want wait() to be interruptible */ | ||
1037 | signal_no_SA_RESTART_empty_mask(SIGINT, signal_cancel); | ||
1038 | signal_no_SA_RESTART_empty_mask(SIGTERM, signal_cancel); | ||
1039 | |||
1040 | setbuf(stdout, NULL); | ||
1041 | |||
1042 | parse_args(argv); | ||
1043 | 1034 | ||
1044 | if (!notitle) | 1035 | if (!notitle) |
1045 | puts("fsck (busybox "BB_VER", "BB_BT")"); | 1036 | puts("fsck (busybox "BB_VER", "BB_BT")"); |
@@ -1060,8 +1051,8 @@ int fsck_main(int argc UNUSED_PARAM, char **argv) | |||
1060 | 1051 | ||
1061 | status = 0; | 1052 | status = 0; |
1062 | for (i = 0; i < num_devices; i++) { | 1053 | for (i = 0; i < num_devices; i++) { |
1063 | if (cancel_requested) { | 1054 | if (bb_got_signal) { |
1064 | kill_all_if_cancel_requested(); | 1055 | kill_all_if_got_signal(); |
1065 | break; | 1056 | break; |
1066 | } | 1057 | } |
1067 | 1058 | ||