aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mkfs_minix.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/mkfs_minix.c')
-rw-r--r--util-linux/mkfs_minix.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index de9dde32b..35c0ccf5c 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -109,16 +109,22 @@ struct globals {
109 unsigned long req_nr_inodes; 109 unsigned long req_nr_inodes;
110 unsigned currently_testing; 110 unsigned currently_testing;
111 111
112
113 char root_block[BLOCK_SIZE]; 112 char root_block[BLOCK_SIZE];
114 char super_block_buffer[BLOCK_SIZE]; 113 char super_block_buffer[BLOCK_SIZE];
115 char boot_block_buffer[512]; 114 char boot_block_buffer[512];
116 unsigned short good_blocks_table[MAX_GOOD_BLOCKS]; 115 unsigned short good_blocks_table[MAX_GOOD_BLOCKS];
117 /* check_blocks(): buffer[] was the biggest static in entire bbox */ 116 /* check_blocks(): buffer[] was the biggest static in entire bbox */
118 char check_blocks_buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS]; 117 char check_blocks_buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS];
119};
120 118
119 unsigned short ind_block1[BLOCK_SIZE >> 1];
120 unsigned short dind_block1[BLOCK_SIZE >> 1];
121 unsigned long ind_block2[BLOCK_SIZE >> 2];
122 unsigned long dind_block2[BLOCK_SIZE >> 2];
123};
121#define G (*ptr_to_globals) 124#define G (*ptr_to_globals)
125#define INIT_G() do { \
126 PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
127} while (0)
122 128
123static ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n) 129static ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n)
124{ 130{
@@ -306,8 +312,12 @@ static void make_bad_inode(void)
306 struct minix1_inode *inode = &INODE_BUF1[MINIX_BAD_INO]; 312 struct minix1_inode *inode = &INODE_BUF1[MINIX_BAD_INO];
307 int i, j, zone; 313 int i, j, zone;
308 int ind = 0, dind = 0; 314 int ind = 0, dind = 0;
315 /* moved to globals to reduce stack usage
309 unsigned short ind_block[BLOCK_SIZE >> 1]; 316 unsigned short ind_block[BLOCK_SIZE >> 1];
310 unsigned short dind_block[BLOCK_SIZE >> 1]; 317 unsigned short dind_block[BLOCK_SIZE >> 1];
318 */
319#define ind_block (G.ind_block1)
320#define dind_block (G.dind_block1)
311 321
312#define NEXT_BAD (zone = next(zone)) 322#define NEXT_BAD (zone = next(zone))
313 323
@@ -351,6 +361,8 @@ static void make_bad_inode(void)
351 write_block(ind, (char *) ind_block); 361 write_block(ind, (char *) ind_block);
352 if (dind) 362 if (dind)
353 write_block(dind, (char *) dind_block); 363 write_block(dind, (char *) dind_block);
364#undef ind_block
365#undef dind_block
354} 366}
355 367
356#if ENABLE_FEATURE_MINIX2 368#if ENABLE_FEATURE_MINIX2
@@ -359,8 +371,12 @@ static void make_bad_inode2(void)
359 struct minix2_inode *inode = &INODE_BUF2[MINIX_BAD_INO]; 371 struct minix2_inode *inode = &INODE_BUF2[MINIX_BAD_INO];
360 int i, j, zone; 372 int i, j, zone;
361 int ind = 0, dind = 0; 373 int ind = 0, dind = 0;
374 /* moved to globals to reduce stack usage
362 unsigned long ind_block[BLOCK_SIZE >> 2]; 375 unsigned long ind_block[BLOCK_SIZE >> 2];
363 unsigned long dind_block[BLOCK_SIZE >> 2]; 376 unsigned long dind_block[BLOCK_SIZE >> 2];
377 */
378#define ind_block (G.ind_block2)
379#define dind_block (G.dind_block2)
364 380
365 if (!G.badblocks) 381 if (!G.badblocks)
366 return; 382 return;
@@ -401,6 +417,8 @@ static void make_bad_inode2(void)
401 write_block(ind, (char *) ind_block); 417 write_block(ind, (char *) ind_block);
402 if (dind) 418 if (dind)
403 write_block(dind, (char *) dind_block); 419 write_block(dind, (char *) dind_block);
420#undef ind_block
421#undef dind_block
404} 422}
405#else 423#else
406void make_bad_inode2(void); 424void make_bad_inode2(void);
@@ -613,7 +631,7 @@ int mkfs_minix_main(int argc, char **argv)
613 char *str_i, *str_n; 631 char *str_i, *str_n;
614 char *listfile = NULL; 632 char *listfile = NULL;
615 633
616 PTR_TO_GLOBALS = xzalloc(sizeof(G)); 634 INIT_G();
617/* default (changed to 30, per Linus's suggestion, Sun Nov 21 08:05:07 1993) */ 635/* default (changed to 30, per Linus's suggestion, Sun Nov 21 08:05:07 1993) */
618 G.namelen = 30; 636 G.namelen = 30;
619 G.dirsize = 32; 637 G.dirsize = 32;