summaryrefslogtreecommitdiff
path: root/fsck_minix.c
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 /fsck_minix.c
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.
Diffstat (limited to 'fsck_minix.c')
-rw-r--r--fsck_minix.c42
1 files changed, 20 insertions, 22 deletions
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();