diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-13 22:31:28 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-13 22:31:28 +0000 |
commit | fad03bc3bb3ca5efcc94bcb561d0e541430600d8 (patch) | |
tree | 309f1a365acadc2af4b7c76813c5c333982970b7 /util-linux/fsck_minix.c | |
parent | 93ebd4f58dceab85f377e0251503af8d7c57e699 (diff) | |
download | busybox-w32-fad03bc3bb3ca5efcc94bcb561d0e541430600d8.tar.gz busybox-w32-fad03bc3bb3ca5efcc94bcb561d0e541430600d8.tar.bz2 busybox-w32-fad03bc3bb3ca5efcc94bcb561d0e541430600d8.zip |
fsck_minix: stop using large buffers in bss
Diffstat (limited to '')
-rw-r--r-- | util-linux/fsck_minix.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 1ed5472b0..cc73cdd5a 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c | |||
@@ -131,13 +131,19 @@ static int dirsize = 16; | |||
131 | static int namelen = 14; | 131 | static int namelen = 14; |
132 | 132 | ||
133 | static char *inode_buffer; | 133 | static char *inode_buffer; |
134 | //xzalloc? | 134 | |
135 | static char super_block_buffer[BLOCK_SIZE]; | 135 | static struct { |
136 | char super_block_buffer[BLOCK_SIZE]; | ||
137 | char add_zone_ind_blk[BLOCK_SIZE]; | ||
138 | char add_zone_dind_blk[BLOCK_SIZE]; | ||
139 | USE_FEATURE_MINIX2(char add_zone_tind_blk[BLOCK_SIZE];) | ||
140 | char check_file_blk[BLOCK_SIZE]; | ||
141 | } *blockbuf; | ||
136 | 142 | ||
137 | #define Inode1 (((struct minix1_inode *) inode_buffer)-1) | 143 | #define Inode1 (((struct minix1_inode *) inode_buffer)-1) |
138 | #define Inode2 (((struct minix2_inode *) inode_buffer)-1) | 144 | #define Inode2 (((struct minix2_inode *) inode_buffer)-1) |
139 | 145 | ||
140 | #define Super (*(struct minix_super_block *)super_block_buffer) | 146 | #define Super (*(struct minix_super_block *)(blockbuf->super_block_buffer)) |
141 | 147 | ||
142 | #if ENABLE_FEATURE_MINIX2 | 148 | #if ENABLE_FEATURE_MINIX2 |
143 | # define ZONES ((unsigned)(version2 ? Super.s_zones : Super.s_nzones)) | 149 | # define ZONES ((unsigned)(version2 ? Super.s_zones : Super.s_nzones)) |
@@ -544,7 +550,7 @@ static void write_super_block(void) | |||
544 | 550 | ||
545 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) | 551 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) |
546 | die("seek failed in write_super_block"); | 552 | die("seek failed in write_super_block"); |
547 | if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) | 553 | if (BLOCK_SIZE != write(IN, blockbuf->super_block_buffer, BLOCK_SIZE)) |
548 | die("cannot write super-block"); | 554 | die("cannot write super-block"); |
549 | } | 555 | } |
550 | 556 | ||
@@ -587,7 +593,7 @@ static void read_superblock(void) | |||
587 | { | 593 | { |
588 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) | 594 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) |
589 | die("seek failed"); | 595 | die("seek failed"); |
590 | if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) | 596 | if (BLOCK_SIZE != read(IN, blockbuf->super_block_buffer, BLOCK_SIZE)) |
591 | die("cannot read super block"); | 597 | die("cannot read super block"); |
592 | /* already initialized to: | 598 | /* already initialized to: |
593 | namelen = 14; | 599 | namelen = 14; |
@@ -827,7 +833,7 @@ static int add_zone2(uint32_t *znr, smallint *corrected) | |||
827 | 833 | ||
828 | static void add_zone_ind(uint16_t *znr, smallint *corrected) | 834 | static void add_zone_ind(uint16_t *znr, smallint *corrected) |
829 | { | 835 | { |
830 | static char blk[BLOCK_SIZE]; | 836 | #define blk (blockbuf->add_zone_ind_blk) |
831 | int i; | 837 | int i; |
832 | int block; | 838 | int block; |
833 | smallint chg_blk = 0; | 839 | smallint chg_blk = 0; |
@@ -840,12 +846,13 @@ static void add_zone_ind(uint16_t *znr, smallint *corrected) | |||
840 | add_zone(i + (uint16_t *) blk, &chg_blk); | 846 | add_zone(i + (uint16_t *) blk, &chg_blk); |
841 | if (chg_blk) | 847 | if (chg_blk) |
842 | write_block(block, blk); | 848 | write_block(block, blk); |
849 | #undef blk | ||
843 | } | 850 | } |
844 | 851 | ||
845 | #if ENABLE_FEATURE_MINIX2 | 852 | #if ENABLE_FEATURE_MINIX2 |
846 | static void add_zone_ind2(uint32_t *znr, smallint *corrected) | 853 | static void add_zone_ind2(uint32_t *znr, smallint *corrected) |
847 | { | 854 | { |
848 | static char blk[BLOCK_SIZE]; | 855 | #define blk (blockbuf->add_zone_ind_blk) |
849 | int i; | 856 | int i; |
850 | int block; | 857 | int block; |
851 | smallint chg_blk = 0; | 858 | smallint chg_blk = 0; |
@@ -858,12 +865,13 @@ static void add_zone_ind2(uint32_t *znr, smallint *corrected) | |||
858 | add_zone2(i + (uint32_t *) blk, &chg_blk); | 865 | add_zone2(i + (uint32_t *) blk, &chg_blk); |
859 | if (chg_blk) | 866 | if (chg_blk) |
860 | write_block(block, blk); | 867 | write_block(block, blk); |
868 | #undef blk | ||
861 | } | 869 | } |
862 | #endif | 870 | #endif |
863 | 871 | ||
864 | static void add_zone_dind(uint16_t *znr, smallint *corrected) | 872 | static void add_zone_dind(uint16_t *znr, smallint *corrected) |
865 | { | 873 | { |
866 | static char blk[BLOCK_SIZE]; | 874 | #define blk (blockbuf->add_zone_dind_blk) |
867 | int i; | 875 | int i; |
868 | int block; | 876 | int block; |
869 | smallint chg_blk = 0; | 877 | smallint chg_blk = 0; |
@@ -876,12 +884,13 @@ static void add_zone_dind(uint16_t *znr, smallint *corrected) | |||
876 | add_zone_ind(i + (uint16_t *) blk, &chg_blk); | 884 | add_zone_ind(i + (uint16_t *) blk, &chg_blk); |
877 | if (chg_blk) | 885 | if (chg_blk) |
878 | write_block(block, blk); | 886 | write_block(block, blk); |
887 | #undef blk | ||
879 | } | 888 | } |
880 | 889 | ||
881 | #if ENABLE_FEATURE_MINIX2 | 890 | #if ENABLE_FEATURE_MINIX2 |
882 | static void add_zone_dind2(uint32_t *znr, smallint *corrected) | 891 | static void add_zone_dind2(uint32_t *znr, smallint *corrected) |
883 | { | 892 | { |
884 | static char blk[BLOCK_SIZE]; | 893 | #define blk (blockbuf->add_zone_dind_blk) |
885 | int i; | 894 | int i; |
886 | int block; | 895 | int block; |
887 | smallint chg_blk = 0; | 896 | smallint chg_blk = 0; |
@@ -894,11 +903,12 @@ static void add_zone_dind2(uint32_t *znr, smallint *corrected) | |||
894 | add_zone_ind2(i + (uint32_t *) blk, &chg_blk); | 903 | add_zone_ind2(i + (uint32_t *) blk, &chg_blk); |
895 | if (chg_blk) | 904 | if (chg_blk) |
896 | write_block(block, blk); | 905 | write_block(block, blk); |
906 | #undef blk | ||
897 | } | 907 | } |
898 | 908 | ||
899 | static void add_zone_tind2(uint32_t *znr, smallint *corrected) | 909 | static void add_zone_tind2(uint32_t *znr, smallint *corrected) |
900 | { | 910 | { |
901 | static char blk[BLOCK_SIZE]; | 911 | #define blk (blockbuf->add_zone_tind_blk) |
902 | int i; | 912 | int i; |
903 | int block; | 913 | int block; |
904 | smallint chg_blk = 0; | 914 | smallint chg_blk = 0; |
@@ -911,6 +921,7 @@ static void add_zone_tind2(uint32_t *znr, smallint *corrected) | |||
911 | add_zone_dind2(i + (uint32_t *) blk, &chg_blk); | 921 | add_zone_dind2(i + (uint32_t *) blk, &chg_blk); |
912 | if (chg_blk) | 922 | if (chg_blk) |
913 | write_block(block, blk); | 923 | write_block(block, blk); |
924 | #undef blk | ||
914 | } | 925 | } |
915 | #endif | 926 | #endif |
916 | 927 | ||
@@ -954,7 +965,7 @@ static void check_zones2(unsigned i) | |||
954 | 965 | ||
955 | static void check_file(struct minix1_inode *dir, unsigned offset) | 966 | static void check_file(struct minix1_inode *dir, unsigned offset) |
956 | { | 967 | { |
957 | static char blk[BLOCK_SIZE]; | 968 | #define blk (blockbuf->check_file_blk) |
958 | struct minix1_inode *inode; | 969 | struct minix1_inode *inode; |
959 | int ino; | 970 | int ino; |
960 | char *name; | 971 | char *name; |
@@ -1000,12 +1011,13 @@ static void check_file(struct minix1_inode *dir, unsigned offset) | |||
1000 | if (inode && S_ISDIR(inode->i_mode)) | 1011 | if (inode && S_ISDIR(inode->i_mode)) |
1001 | recursive_check(ino); | 1012 | recursive_check(ino); |
1002 | pop_filename(); | 1013 | pop_filename(); |
1014 | #undef blk | ||
1003 | } | 1015 | } |
1004 | 1016 | ||
1005 | #if ENABLE_FEATURE_MINIX2 | 1017 | #if ENABLE_FEATURE_MINIX2 |
1006 | static void check_file2(struct minix2_inode *dir, unsigned offset) | 1018 | static void check_file2(struct minix2_inode *dir, unsigned offset) |
1007 | { | 1019 | { |
1008 | static char blk[BLOCK_SIZE]; | 1020 | #define blk (blockbuf->check_file_blk) |
1009 | struct minix2_inode *inode; | 1021 | struct minix2_inode *inode; |
1010 | int ino; | 1022 | int ino; |
1011 | char *name; | 1023 | char *name; |
@@ -1051,6 +1063,7 @@ static void check_file2(struct minix2_inode *dir, unsigned offset) | |||
1051 | if (inode && S_ISDIR(inode->i_mode)) | 1063 | if (inode && S_ISDIR(inode->i_mode)) |
1052 | recursive_check2(ino); | 1064 | recursive_check2(ino); |
1053 | pop_filename(); | 1065 | pop_filename(); |
1066 | #undef blk | ||
1054 | } | 1067 | } |
1055 | #endif | 1068 | #endif |
1056 | 1069 | ||
@@ -1230,6 +1243,7 @@ int fsck_minix_main(int argc, char **argv) | |||
1230 | int retcode = 0; | 1243 | int retcode = 0; |
1231 | 1244 | ||
1232 | xfunc_error_retval = 8; | 1245 | xfunc_error_retval = 8; |
1246 | blockbuf = xzalloc(sizeof(*blockbuf)); | ||
1233 | 1247 | ||
1234 | alloc_current_name(); | 1248 | alloc_current_name(); |
1235 | #if ENABLE_FEATURE_CLEAN_UP | 1249 | #if ENABLE_FEATURE_CLEAN_UP |