aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2000-07-17 17:52:00 +0000
committerPavel Roskin <proski@gnu.org>2000-07-17 17:52:00 +0000
commitbc0aed79a8c7bb24c32a21533893fdad660b7292 (patch)
treea6f71ac9c1c3df98bbc1eb33d0f181664f2377ec
parent47d4926244f6a444f812675f4ecff401dba5f8f7 (diff)
downloadbusybox-w32-bc0aed79a8c7bb24c32a21533893fdad660b7292.tar.gz
busybox-w32-bc0aed79a8c7bb24c32a21533893fdad660b7292.tar.bz2
busybox-w32-bc0aed79a8c7bb24c32a21533893fdad660b7292.zip
It is now possible to select in busybox.def.h whether minixfs version 2
is to be supported.
-rw-r--r--busybox.def.h3
-rw-r--r--fsck_minix.c42
-rw-r--r--mkfs_minix.c24
-rw-r--r--util-linux/fsck_minix.c42
-rw-r--r--util-linux/mkfs_minix.c24
5 files changed, 63 insertions, 72 deletions
diff --git a/busybox.def.h b/busybox.def.h
index 854de1466..1db5f00c7 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -240,6 +240,9 @@
240// Support module version checking 240// Support module version checking
241//#define BB_FEATURE_INSMOD_VERSION_CHECKING 241//#define BB_FEATURE_INSMOD_VERSION_CHECKING
242// 242//
243// Support for Minix filesystem, version 2
244//#define BB_FEATURE_MINIX2
245//
243// 246//
244// Enable busybox --install [-s] 247// Enable busybox --install [-s]
245// to create links (or symlinks) for all the commands that are 248// to create links (or symlinks) for all the commands that are
diff --git a/fsck_minix.c b/fsck_minix.c
index 5807b9af5..c3c493fd2 100644
--- a/fsck_minix.c
+++ b/fsck_minix.c
@@ -196,10 +196,6 @@ struct minix_dir_entry {
196#define BLKGETSIZE _IO(0x12,96) /* return device size */ 196#define BLKGETSIZE _IO(0x12,96) /* return device size */
197#endif 197#endif
198 198
199#ifdef MINIX2_SUPER_MAGIC2
200#define HAVE_MINIX2 1
201#endif
202
203#ifndef __linux__ 199#ifndef __linux__
204#define volatile 200#define volatile
205#endif 201#endif
@@ -208,7 +204,7 @@ struct minix_dir_entry {
208 204
209#define UPPER(size,n) ((size+((n)-1))/(n)) 205#define UPPER(size,n) ((size+((n)-1))/(n))
210#define INODE_SIZE (sizeof(struct minix_inode)) 206#define INODE_SIZE (sizeof(struct minix_inode))
211#ifdef HAVE_MINIX2 207#ifdef BB_FEATURE_MINIX2
212#define INODE_SIZE2 (sizeof(struct minix2_inode)) 208#define INODE_SIZE2 (sizeof(struct minix2_inode))
213#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ 209#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \
214 : MINIX_INODES_PER_BLOCK)) 210 : MINIX_INODES_PER_BLOCK))
@@ -249,7 +245,7 @@ static char super_block_buffer[BLOCK_SIZE];
249 245
250#define Super (*(struct minix_super_block *)super_block_buffer) 246#define Super (*(struct minix_super_block *)super_block_buffer)
251#define INODES ((unsigned long)Super.s_ninodes) 247#define INODES ((unsigned long)Super.s_ninodes)
252#ifdef HAVE_MINIX2 248#ifdef BB_FEATURE_MINIX2
253#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones)) 249#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones))
254#else 250#else
255#define ZONES ((unsigned long)(Super.s_nzones)) 251#define ZONES ((unsigned long)(Super.s_nzones))
@@ -269,7 +265,9 @@ static unsigned char *inode_count = NULL;
269static unsigned char *zone_count = NULL; 265static unsigned char *zone_count = NULL;
270 266
271static void recursive_check(unsigned int ino); 267static void recursive_check(unsigned int ino);
268#ifdef BB_FEATURE_MINIX2
272static void recursive_check2(unsigned int ino); 269static void recursive_check2(unsigned int ino);
270#endif
273 271
274#define inode_in_use(x) (isset(inode_map,(x))) 272#define inode_in_use(x) (isset(inode_map,(x)))
275#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1)) 273#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
@@ -424,7 +422,7 @@ static int check_zone_nr(unsigned short *nr, int *corrected)
424 return 0; 422 return 0;
425} 423}
426 424
427#ifdef HAVE_MINIX2 425#ifdef BB_FEATURE_MINIX2
428static int check_zone_nr2(unsigned int *nr, int *corrected) 426static int check_zone_nr2(unsigned int *nr, int *corrected)
429{ 427{
430 if (!*nr) 428 if (!*nr)
@@ -531,7 +529,7 @@ static int map_block(struct minix_inode *inode, unsigned int blknr)
531 return result; 529 return result;
532} 530}
533 531
534#ifdef HAVE_MINIX2 532#ifdef BB_FEATURE_MINIX2
535static int map_block2(struct minix2_inode *inode, unsigned int blknr) 533static int map_block2(struct minix2_inode *inode, unsigned int blknr)
536{ 534{
537 unsigned int ind[BLOCK_SIZE >> 2]; 535 unsigned int ind[BLOCK_SIZE >> 2];
@@ -629,7 +627,7 @@ static void get_dirsize(void)
629 char blk[BLOCK_SIZE]; 627 char blk[BLOCK_SIZE];
630 int size; 628 int size;
631 629
632#if HAVE_MINIX2 630#ifdef BB_FEATURE_MINIX2
633 if (version2) 631 if (version2)
634 block = Inode2[ROOT_INO].i_zone[0]; 632 block = Inode2[ROOT_INO].i_zone[0];
635 else 633 else
@@ -660,7 +658,7 @@ static void read_superblock(void)
660 namelen = 30; 658 namelen = 30;
661 dirsize = 32; 659 dirsize = 32;
662 version2 = 0; 660 version2 = 0;
663#ifdef HAVE_MINIX2 661#ifdef BB_FEATURE_MINIX2
664 } else if (MAGIC == MINIX2_SUPER_MAGIC) { 662 } else if (MAGIC == MINIX2_SUPER_MAGIC) {
665 namelen = 14; 663 namelen = 14;
666 dirsize = 16; 664 dirsize = 16;
@@ -758,7 +756,7 @@ struct minix_inode *get_inode(unsigned int nr)
758 return inode; 756 return inode;
759} 757}
760 758
761#ifdef HAVE_MINIX2 759#ifdef BB_FEATURE_MINIX2
762struct minix2_inode *get_inode2(unsigned int nr) 760struct minix2_inode *get_inode2(unsigned int nr)
763{ 761{
764 struct minix2_inode *inode; 762 struct minix2_inode *inode;
@@ -814,7 +812,7 @@ static void check_root(void)
814 die("root inode isn't a directory"); 812 die("root inode isn't a directory");
815} 813}
816 814
817#ifdef HAVE_MINIX2 815#ifdef BB_FEATURE_MINIX2
818static void check_root2(void) 816static void check_root2(void)
819{ 817{
820 struct minix2_inode *inode = Inode2 + ROOT_INO; 818 struct minix2_inode *inode = Inode2 + ROOT_INO;
@@ -857,7 +855,7 @@ static int add_zone(unsigned short *znr, int *corrected)
857 return block; 855 return block;
858} 856}
859 857
860#ifdef HAVE_MINIX2 858#ifdef BB_FEATURE_MINIX2
861static int add_zone2(unsigned int *znr, int *corrected) 859static int add_zone2(unsigned int *znr, int *corrected)
862{ 860{
863 int result; 861 int result;
@@ -908,7 +906,7 @@ static void add_zone_ind(unsigned short *znr, int *corrected)
908 write_block(block, blk); 906 write_block(block, blk);
909} 907}
910 908
911#ifdef HAVE_MINIX2 909#ifdef BB_FEATURE_MINIX2
912static void add_zone_ind2(unsigned int *znr, int *corrected) 910static void add_zone_ind2(unsigned int *znr, int *corrected)
913{ 911{
914 static char blk[BLOCK_SIZE]; 912 static char blk[BLOCK_SIZE];
@@ -942,7 +940,7 @@ static void add_zone_dind(unsigned short *znr, int *corrected)
942 write_block(block, blk); 940 write_block(block, blk);
943} 941}
944 942
945#ifdef HAVE_MINIX2 943#ifdef BB_FEATURE_MINIX2
946static void add_zone_dind2(unsigned int *znr, int *corrected) 944static void add_zone_dind2(unsigned int *znr, int *corrected)
947{ 945{
948 static char blk[BLOCK_SIZE]; 946 static char blk[BLOCK_SIZE];
@@ -993,7 +991,7 @@ static void check_zones(unsigned int i)
993 add_zone_dind(8 + inode->i_zone, &changed); 991 add_zone_dind(8 + inode->i_zone, &changed);
994} 992}
995 993
996#ifdef HAVE_MINIX2 994#ifdef BB_FEATURE_MINIX2
997static void check_zones2(unsigned int i) 995static void check_zones2(unsigned int i)
998{ 996{
999 struct minix2_inode *inode; 997 struct minix2_inode *inode;
@@ -1078,7 +1076,7 @@ static void check_file(struct minix_inode *dir, unsigned int offset)
1078 return; 1076 return;
1079} 1077}
1080 1078
1081#ifdef HAVE_MINIX2 1079#ifdef BB_FEATURE_MINIX2
1082static void check_file2(struct minix2_inode *dir, unsigned int offset) 1080static void check_file2(struct minix2_inode *dir, unsigned int offset)
1083{ 1081{
1084 static char blk[BLOCK_SIZE]; 1082 static char blk[BLOCK_SIZE];
@@ -1159,7 +1157,7 @@ static void recursive_check(unsigned int ino)
1159 check_file(dir, offset); 1157 check_file(dir, offset);
1160} 1158}
1161 1159
1162#ifdef HAVE_MINIX2 1160#ifdef BB_FEATURE_MINIX2
1163static void recursive_check2(unsigned int ino) 1161static void recursive_check2(unsigned int ino)
1164{ 1162{
1165 struct minix2_inode *dir; 1163 struct minix2_inode *dir;
@@ -1237,7 +1235,7 @@ static void check_counts(void)
1237 } 1235 }
1238} 1236}
1239 1237
1240#ifdef HAVE_MINIX2 1238#ifdef BB_FEATURE_MINIX2
1241static void check_counts2(void) 1239static void check_counts2(void)
1242{ 1240{
1243 int i; 1241 int i;
@@ -1299,7 +1297,7 @@ static void check(void)
1299 check_counts(); 1297 check_counts();
1300} 1298}
1301 1299
1302#ifdef HAVE_MINIX2 1300#ifdef BB_FEATURE_MINIX2
1303static void check2(void) 1301static void check2(void)
1304{ 1302{
1305 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count)); 1303 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count));
@@ -1352,7 +1350,7 @@ extern int fsck_minix_main(int argc, char **argv)
1352 1350
1353 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) 1351 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
1354 die("bad inode size"); 1352 die("bad inode size");
1355#ifdef HAVE_MINIX2 1353#ifdef BB_FEATURE_MINIX2
1356 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) 1354 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
1357 die("bad v2 inode size"); 1355 die("bad v2 inode size");
1358#endif 1356#endif
@@ -1434,7 +1432,7 @@ extern int fsck_minix_main(int argc, char **argv)
1434 tcsetattr(0, TCSANOW, &tmp); 1432 tcsetattr(0, TCSANOW, &tmp);
1435 termios_set = 1; 1433 termios_set = 1;
1436 } 1434 }
1437#if HAVE_MINIX2 1435#ifdef BB_FEATURE_MINIX2
1438 if (version2) { 1436 if (version2) {
1439 check_root2(); 1437 check_root2();
1440 check2(); 1438 check2();
diff --git a/mkfs_minix.c b/mkfs_minix.c
index dec310d30..240dfded0 100644
--- a/mkfs_minix.c
+++ b/mkfs_minix.c
@@ -175,10 +175,6 @@ struct minix_dir_entry {
175#endif 175#endif
176 176
177 177
178#ifdef MINIX2_SUPER_MAGIC2
179#define HAVE_MINIX2 1
180#endif
181
182#ifndef __linux__ 178#ifndef __linux__
183#define volatile 179#define volatile
184#endif 180#endif
@@ -191,7 +187,7 @@ struct minix_dir_entry {
191 187
192#define UPPER(size,n) (((size)+((n)-1))/(n)) 188#define UPPER(size,n) (((size)+((n)-1))/(n))
193#define INODE_SIZE (sizeof(struct minix_inode)) 189#define INODE_SIZE (sizeof(struct minix_inode))
194#ifdef HAVE_MINIX2 190#ifdef BB_FEATURE_MINIX2
195#define INODE_SIZE2 (sizeof(struct minix2_inode)) 191#define INODE_SIZE2 (sizeof(struct minix2_inode))
196#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ 192#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \
197 : MINIX_INODES_PER_BLOCK)) 193 : MINIX_INODES_PER_BLOCK))
@@ -219,7 +215,7 @@ static char root_block[BLOCK_SIZE] = "\0";
219static char *inode_buffer = NULL; 215static char *inode_buffer = NULL;
220 216
221#define Inode (((struct minix_inode *) inode_buffer)-1) 217#define Inode (((struct minix_inode *) inode_buffer)-1)
222#ifdef HAVE_MINIX2 218#ifdef BB_FEATURE_MINIX2
223#define Inode2 (((struct minix2_inode *) inode_buffer)-1) 219#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
224#endif 220#endif
225static char super_block_buffer[BLOCK_SIZE]; 221static char super_block_buffer[BLOCK_SIZE];
@@ -227,7 +223,7 @@ static char boot_block_buffer[512];
227 223
228#define Super (*(struct minix_super_block *)super_block_buffer) 224#define Super (*(struct minix_super_block *)super_block_buffer)
229#define INODES ((unsigned long)Super.s_ninodes) 225#define INODES ((unsigned long)Super.s_ninodes)
230#ifdef HAVE_MINIX2 226#ifdef BB_FEATURE_MINIX2
231#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones)) 227#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones))
232#else 228#else
233#define ZONES ((unsigned long)(Super.s_nzones)) 229#define ZONES ((unsigned long)(Super.s_nzones))
@@ -463,7 +459,7 @@ static void make_bad_inode(void)
463 write_block(dind, (char *) dind_block); 459 write_block(dind, (char *) dind_block);
464} 460}
465 461
466#ifdef HAVE_MINIX2 462#ifdef BB_FEATURE_MINIX2
467static void make_bad_inode2(void) 463static void make_bad_inode2(void)
468{ 464{
469 struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; 465 struct minix2_inode *inode = &Inode2[MINIX_BAD_INO];
@@ -536,7 +532,7 @@ static void make_root_inode(void)
536 write_block(inode->i_zone[0], root_block); 532 write_block(inode->i_zone[0], root_block);
537} 533}
538 534
539#ifdef HAVE_MINIX2 535#ifdef BB_FEATURE_MINIX2
540static void make_root_inode2(void) 536static void make_root_inode2(void)
541{ 537{
542 struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; 538 struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO];
@@ -577,7 +573,7 @@ static void setup_tables(void)
577 else 573 else
578 inodes = req_nr_inodes; 574 inodes = req_nr_inodes;
579 /* Round up inode count to fill block size */ 575 /* Round up inode count to fill block size */
580#ifdef HAVE_MINIX2 576#ifdef BB_FEATURE_MINIX2
581 if (version2) 577 if (version2)
582 inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & 578 inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) &
583 ~(MINIX2_INODES_PER_BLOCK - 1)); 579 ~(MINIX2_INODES_PER_BLOCK - 1));
@@ -729,7 +725,7 @@ extern int mkfs_minix_main(int argc, char **argv)
729 725
730 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) 726 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
731 die("bad inode size"); 727 die("bad inode size");
732#ifdef HAVE_MINIX2 728#ifdef BB_FEATURE_MINIX2
733 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) 729 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
734 die("bad inode size"); 730 die("bad inode size");
735#endif 731#endif
@@ -794,7 +790,7 @@ extern int mkfs_minix_main(int argc, char **argv)
794 break; 790 break;
795 } 791 }
796 case 'v': 792 case 'v':
797#ifdef HAVE_MINIX2 793#ifdef BB_FEATURE_MINIX2
798 version2 = 1; 794 version2 = 1;
799#else 795#else
800 errorMsg("%s: not compiled with minix v2 support\n", 796 errorMsg("%s: not compiled with minix v2 support\n",
@@ -826,7 +822,7 @@ goodbye:
826 if (!device_name || BLOCKS < 10) { 822 if (!device_name || BLOCKS < 10) {
827 show_usage(); 823 show_usage();
828 } 824 }
829#ifdef HAVE_MINIX2 825#ifdef BB_FEATURE_MINIX2
830 if (version2) { 826 if (version2) {
831 if (namelen == 14) 827 if (namelen == 14)
832 magic = MINIX2_SUPER_MAGIC; 828 magic = MINIX2_SUPER_MAGIC;
@@ -860,7 +856,7 @@ goodbye:
860 check_blocks(); 856 check_blocks();
861 else if (listfile) 857 else if (listfile)
862 get_list_blocks(listfile); 858 get_list_blocks(listfile);
863#ifdef HAVE_MINIX2 859#ifdef BB_FEATURE_MINIX2
864 if (version2) { 860 if (version2) {
865 make_root_inode2(); 861 make_root_inode2();
866 make_bad_inode2(); 862 make_bad_inode2();
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 5807b9af5..c3c493fd2 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -196,10 +196,6 @@ struct minix_dir_entry {
196#define BLKGETSIZE _IO(0x12,96) /* return device size */ 196#define BLKGETSIZE _IO(0x12,96) /* return device size */
197#endif 197#endif
198 198
199#ifdef MINIX2_SUPER_MAGIC2
200#define HAVE_MINIX2 1
201#endif
202
203#ifndef __linux__ 199#ifndef __linux__
204#define volatile 200#define volatile
205#endif 201#endif
@@ -208,7 +204,7 @@ struct minix_dir_entry {
208 204
209#define UPPER(size,n) ((size+((n)-1))/(n)) 205#define UPPER(size,n) ((size+((n)-1))/(n))
210#define INODE_SIZE (sizeof(struct minix_inode)) 206#define INODE_SIZE (sizeof(struct minix_inode))
211#ifdef HAVE_MINIX2 207#ifdef BB_FEATURE_MINIX2
212#define INODE_SIZE2 (sizeof(struct minix2_inode)) 208#define INODE_SIZE2 (sizeof(struct minix2_inode))
213#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ 209#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \
214 : MINIX_INODES_PER_BLOCK)) 210 : MINIX_INODES_PER_BLOCK))
@@ -249,7 +245,7 @@ static char super_block_buffer[BLOCK_SIZE];
249 245
250#define Super (*(struct minix_super_block *)super_block_buffer) 246#define Super (*(struct minix_super_block *)super_block_buffer)
251#define INODES ((unsigned long)Super.s_ninodes) 247#define INODES ((unsigned long)Super.s_ninodes)
252#ifdef HAVE_MINIX2 248#ifdef BB_FEATURE_MINIX2
253#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones)) 249#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones))
254#else 250#else
255#define ZONES ((unsigned long)(Super.s_nzones)) 251#define ZONES ((unsigned long)(Super.s_nzones))
@@ -269,7 +265,9 @@ static unsigned char *inode_count = NULL;
269static unsigned char *zone_count = NULL; 265static unsigned char *zone_count = NULL;
270 266
271static void recursive_check(unsigned int ino); 267static void recursive_check(unsigned int ino);
268#ifdef BB_FEATURE_MINIX2
272static void recursive_check2(unsigned int ino); 269static void recursive_check2(unsigned int ino);
270#endif
273 271
274#define inode_in_use(x) (isset(inode_map,(x))) 272#define inode_in_use(x) (isset(inode_map,(x)))
275#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1)) 273#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
@@ -424,7 +422,7 @@ static int check_zone_nr(unsigned short *nr, int *corrected)
424 return 0; 422 return 0;
425} 423}
426 424
427#ifdef HAVE_MINIX2 425#ifdef BB_FEATURE_MINIX2
428static int check_zone_nr2(unsigned int *nr, int *corrected) 426static int check_zone_nr2(unsigned int *nr, int *corrected)
429{ 427{
430 if (!*nr) 428 if (!*nr)
@@ -531,7 +529,7 @@ static int map_block(struct minix_inode *inode, unsigned int blknr)
531 return result; 529 return result;
532} 530}
533 531
534#ifdef HAVE_MINIX2 532#ifdef BB_FEATURE_MINIX2
535static int map_block2(struct minix2_inode *inode, unsigned int blknr) 533static int map_block2(struct minix2_inode *inode, unsigned int blknr)
536{ 534{
537 unsigned int ind[BLOCK_SIZE >> 2]; 535 unsigned int ind[BLOCK_SIZE >> 2];
@@ -629,7 +627,7 @@ static void get_dirsize(void)
629 char blk[BLOCK_SIZE]; 627 char blk[BLOCK_SIZE];
630 int size; 628 int size;
631 629
632#if HAVE_MINIX2 630#ifdef BB_FEATURE_MINIX2
633 if (version2) 631 if (version2)
634 block = Inode2[ROOT_INO].i_zone[0]; 632 block = Inode2[ROOT_INO].i_zone[0];
635 else 633 else
@@ -660,7 +658,7 @@ static void read_superblock(void)
660 namelen = 30; 658 namelen = 30;
661 dirsize = 32; 659 dirsize = 32;
662 version2 = 0; 660 version2 = 0;
663#ifdef HAVE_MINIX2 661#ifdef BB_FEATURE_MINIX2
664 } else if (MAGIC == MINIX2_SUPER_MAGIC) { 662 } else if (MAGIC == MINIX2_SUPER_MAGIC) {
665 namelen = 14; 663 namelen = 14;
666 dirsize = 16; 664 dirsize = 16;
@@ -758,7 +756,7 @@ struct minix_inode *get_inode(unsigned int nr)
758 return inode; 756 return inode;
759} 757}
760 758
761#ifdef HAVE_MINIX2 759#ifdef BB_FEATURE_MINIX2
762struct minix2_inode *get_inode2(unsigned int nr) 760struct minix2_inode *get_inode2(unsigned int nr)
763{ 761{
764 struct minix2_inode *inode; 762 struct minix2_inode *inode;
@@ -814,7 +812,7 @@ static void check_root(void)
814 die("root inode isn't a directory"); 812 die("root inode isn't a directory");
815} 813}
816 814
817#ifdef HAVE_MINIX2 815#ifdef BB_FEATURE_MINIX2
818static void check_root2(void) 816static void check_root2(void)
819{ 817{
820 struct minix2_inode *inode = Inode2 + ROOT_INO; 818 struct minix2_inode *inode = Inode2 + ROOT_INO;
@@ -857,7 +855,7 @@ static int add_zone(unsigned short *znr, int *corrected)
857 return block; 855 return block;
858} 856}
859 857
860#ifdef HAVE_MINIX2 858#ifdef BB_FEATURE_MINIX2
861static int add_zone2(unsigned int *znr, int *corrected) 859static int add_zone2(unsigned int *znr, int *corrected)
862{ 860{
863 int result; 861 int result;
@@ -908,7 +906,7 @@ static void add_zone_ind(unsigned short *znr, int *corrected)
908 write_block(block, blk); 906 write_block(block, blk);
909} 907}
910 908
911#ifdef HAVE_MINIX2 909#ifdef BB_FEATURE_MINIX2
912static void add_zone_ind2(unsigned int *znr, int *corrected) 910static void add_zone_ind2(unsigned int *znr, int *corrected)
913{ 911{
914 static char blk[BLOCK_SIZE]; 912 static char blk[BLOCK_SIZE];
@@ -942,7 +940,7 @@ static void add_zone_dind(unsigned short *znr, int *corrected)
942 write_block(block, blk); 940 write_block(block, blk);
943} 941}
944 942
945#ifdef HAVE_MINIX2 943#ifdef BB_FEATURE_MINIX2
946static void add_zone_dind2(unsigned int *znr, int *corrected) 944static void add_zone_dind2(unsigned int *znr, int *corrected)
947{ 945{
948 static char blk[BLOCK_SIZE]; 946 static char blk[BLOCK_SIZE];
@@ -993,7 +991,7 @@ static void check_zones(unsigned int i)
993 add_zone_dind(8 + inode->i_zone, &changed); 991 add_zone_dind(8 + inode->i_zone, &changed);
994} 992}
995 993
996#ifdef HAVE_MINIX2 994#ifdef BB_FEATURE_MINIX2
997static void check_zones2(unsigned int i) 995static void check_zones2(unsigned int i)
998{ 996{
999 struct minix2_inode *inode; 997 struct minix2_inode *inode;
@@ -1078,7 +1076,7 @@ static void check_file(struct minix_inode *dir, unsigned int offset)
1078 return; 1076 return;
1079} 1077}
1080 1078
1081#ifdef HAVE_MINIX2 1079#ifdef BB_FEATURE_MINIX2
1082static void check_file2(struct minix2_inode *dir, unsigned int offset) 1080static void check_file2(struct minix2_inode *dir, unsigned int offset)
1083{ 1081{
1084 static char blk[BLOCK_SIZE]; 1082 static char blk[BLOCK_SIZE];
@@ -1159,7 +1157,7 @@ static void recursive_check(unsigned int ino)
1159 check_file(dir, offset); 1157 check_file(dir, offset);
1160} 1158}
1161 1159
1162#ifdef HAVE_MINIX2 1160#ifdef BB_FEATURE_MINIX2
1163static void recursive_check2(unsigned int ino) 1161static void recursive_check2(unsigned int ino)
1164{ 1162{
1165 struct minix2_inode *dir; 1163 struct minix2_inode *dir;
@@ -1237,7 +1235,7 @@ static void check_counts(void)
1237 } 1235 }
1238} 1236}
1239 1237
1240#ifdef HAVE_MINIX2 1238#ifdef BB_FEATURE_MINIX2
1241static void check_counts2(void) 1239static void check_counts2(void)
1242{ 1240{
1243 int i; 1241 int i;
@@ -1299,7 +1297,7 @@ static void check(void)
1299 check_counts(); 1297 check_counts();
1300} 1298}
1301 1299
1302#ifdef HAVE_MINIX2 1300#ifdef BB_FEATURE_MINIX2
1303static void check2(void) 1301static void check2(void)
1304{ 1302{
1305 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count)); 1303 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count));
@@ -1352,7 +1350,7 @@ extern int fsck_minix_main(int argc, char **argv)
1352 1350
1353 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) 1351 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
1354 die("bad inode size"); 1352 die("bad inode size");
1355#ifdef HAVE_MINIX2 1353#ifdef BB_FEATURE_MINIX2
1356 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) 1354 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
1357 die("bad v2 inode size"); 1355 die("bad v2 inode size");
1358#endif 1356#endif
@@ -1434,7 +1432,7 @@ extern int fsck_minix_main(int argc, char **argv)
1434 tcsetattr(0, TCSANOW, &tmp); 1432 tcsetattr(0, TCSANOW, &tmp);
1435 termios_set = 1; 1433 termios_set = 1;
1436 } 1434 }
1437#if HAVE_MINIX2 1435#ifdef BB_FEATURE_MINIX2
1438 if (version2) { 1436 if (version2) {
1439 check_root2(); 1437 check_root2();
1440 check2(); 1438 check2();
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index dec310d30..240dfded0 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -175,10 +175,6 @@ struct minix_dir_entry {
175#endif 175#endif
176 176
177 177
178#ifdef MINIX2_SUPER_MAGIC2
179#define HAVE_MINIX2 1
180#endif
181
182#ifndef __linux__ 178#ifndef __linux__
183#define volatile 179#define volatile
184#endif 180#endif
@@ -191,7 +187,7 @@ struct minix_dir_entry {
191 187
192#define UPPER(size,n) (((size)+((n)-1))/(n)) 188#define UPPER(size,n) (((size)+((n)-1))/(n))
193#define INODE_SIZE (sizeof(struct minix_inode)) 189#define INODE_SIZE (sizeof(struct minix_inode))
194#ifdef HAVE_MINIX2 190#ifdef BB_FEATURE_MINIX2
195#define INODE_SIZE2 (sizeof(struct minix2_inode)) 191#define INODE_SIZE2 (sizeof(struct minix2_inode))
196#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ 192#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \
197 : MINIX_INODES_PER_BLOCK)) 193 : MINIX_INODES_PER_BLOCK))
@@ -219,7 +215,7 @@ static char root_block[BLOCK_SIZE] = "\0";
219static char *inode_buffer = NULL; 215static char *inode_buffer = NULL;
220 216
221#define Inode (((struct minix_inode *) inode_buffer)-1) 217#define Inode (((struct minix_inode *) inode_buffer)-1)
222#ifdef HAVE_MINIX2 218#ifdef BB_FEATURE_MINIX2
223#define Inode2 (((struct minix2_inode *) inode_buffer)-1) 219#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
224#endif 220#endif
225static char super_block_buffer[BLOCK_SIZE]; 221static char super_block_buffer[BLOCK_SIZE];
@@ -227,7 +223,7 @@ static char boot_block_buffer[512];
227 223
228#define Super (*(struct minix_super_block *)super_block_buffer) 224#define Super (*(struct minix_super_block *)super_block_buffer)
229#define INODES ((unsigned long)Super.s_ninodes) 225#define INODES ((unsigned long)Super.s_ninodes)
230#ifdef HAVE_MINIX2 226#ifdef BB_FEATURE_MINIX2
231#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones)) 227#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones))
232#else 228#else
233#define ZONES ((unsigned long)(Super.s_nzones)) 229#define ZONES ((unsigned long)(Super.s_nzones))
@@ -463,7 +459,7 @@ static void make_bad_inode(void)
463 write_block(dind, (char *) dind_block); 459 write_block(dind, (char *) dind_block);
464} 460}
465 461
466#ifdef HAVE_MINIX2 462#ifdef BB_FEATURE_MINIX2
467static void make_bad_inode2(void) 463static void make_bad_inode2(void)
468{ 464{
469 struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; 465 struct minix2_inode *inode = &Inode2[MINIX_BAD_INO];
@@ -536,7 +532,7 @@ static void make_root_inode(void)
536 write_block(inode->i_zone[0], root_block); 532 write_block(inode->i_zone[0], root_block);
537} 533}
538 534
539#ifdef HAVE_MINIX2 535#ifdef BB_FEATURE_MINIX2
540static void make_root_inode2(void) 536static void make_root_inode2(void)
541{ 537{
542 struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; 538 struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO];
@@ -577,7 +573,7 @@ static void setup_tables(void)
577 else 573 else
578 inodes = req_nr_inodes; 574 inodes = req_nr_inodes;
579 /* Round up inode count to fill block size */ 575 /* Round up inode count to fill block size */
580#ifdef HAVE_MINIX2 576#ifdef BB_FEATURE_MINIX2
581 if (version2) 577 if (version2)
582 inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & 578 inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) &
583 ~(MINIX2_INODES_PER_BLOCK - 1)); 579 ~(MINIX2_INODES_PER_BLOCK - 1));
@@ -729,7 +725,7 @@ extern int mkfs_minix_main(int argc, char **argv)
729 725
730 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) 726 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
731 die("bad inode size"); 727 die("bad inode size");
732#ifdef HAVE_MINIX2 728#ifdef BB_FEATURE_MINIX2
733 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) 729 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
734 die("bad inode size"); 730 die("bad inode size");
735#endif 731#endif
@@ -794,7 +790,7 @@ extern int mkfs_minix_main(int argc, char **argv)
794 break; 790 break;
795 } 791 }
796 case 'v': 792 case 'v':
797#ifdef HAVE_MINIX2 793#ifdef BB_FEATURE_MINIX2
798 version2 = 1; 794 version2 = 1;
799#else 795#else
800 errorMsg("%s: not compiled with minix v2 support\n", 796 errorMsg("%s: not compiled with minix v2 support\n",
@@ -826,7 +822,7 @@ goodbye:
826 if (!device_name || BLOCKS < 10) { 822 if (!device_name || BLOCKS < 10) {
827 show_usage(); 823 show_usage();
828 } 824 }
829#ifdef HAVE_MINIX2 825#ifdef BB_FEATURE_MINIX2
830 if (version2) { 826 if (version2) {
831 if (namelen == 14) 827 if (namelen == 14)
832 magic = MINIX2_SUPER_MAGIC; 828 magic = MINIX2_SUPER_MAGIC;
@@ -860,7 +856,7 @@ goodbye:
860 check_blocks(); 856 check_blocks();
861 else if (listfile) 857 else if (listfile)
862 get_list_blocks(listfile); 858 get_list_blocks(listfile);
863#ifdef HAVE_MINIX2 859#ifdef BB_FEATURE_MINIX2
864 if (version2) { 860 if (version2) {
865 make_root_inode2(); 861 make_root_inode2();
866 make_bad_inode2(); 862 make_bad_inode2();