]> Zhao Yanbai Git Server - minix.git/commitdiff
Basic fixes to make de start to read v3 filesystems. (Not complete.)
authorBen Gras <ben@minix3.org>
Thu, 30 Jun 2005 12:59:49 +0000 (12:59 +0000)
committerBen Gras <ben@minix3.org>
Thu, 30 Jun 2005 12:59:49 +0000 (12:59 +0000)
commands/de/de.h
commands/de/de_diskio.c
commands/de/de_recover.c
commands/de/de_stdout.c

index f6c75951e59d40e7fffa826f9d57bdde3d578f56..550587d613b8ed33fe7451889afe6c40958f0489 100755 (executable)
@@ -63,6 +63,7 @@
 /****************************************************************/
 #undef printf
 #include <stdio.h>
+#include <dirent.h>
 
 /*  General constants  */
 
@@ -223,6 +224,7 @@ typedef  struct  de_state           /*  State of disk ed.   */
   unsigned inode_size;                 /*  Size of disk inode  */
   unsigned nr_indirects;               /*  # indirect blocks   */
   unsigned zone_num_size;              /*  Size of disk z num  */
+  int block_size;                      /*  FS block size       */
 
   /* Other derived numbers */  
   
@@ -242,7 +244,7 @@ typedef  struct  de_state           /*  State of disk ed.   */
   zone_t block;                                /*  Current block (1K)  */
   unsigned offset;                     /*  Offset within block */
 
-  char buffer[ K ];
+  char buffer[ MAX_BLOCK_SIZE ];
 
   /*  Display state  */
 
index 09e462ea6b093e459ded0a2a956c94444a1f2a23..fe53f974c2417f9a80a5829b4d0597d78bdef8fb 100755 (executable)
@@ -47,7 +47,7 @@ void Read_Disk( s, block_addr, buffer )
   if ( lseek( s->device_d, block_addr, SEEK_SET ) == -1 )
     Error( "Error seeking %s", s->device_name );
 
-  if ( read( s->device_d, buffer, K ) != K )
+  if ( read( s->device_d, buffer, s->block_size ) != s->block_size )
     Error( "Error reading %s", s->device_name );
   }
 
@@ -72,8 +72,9 @@ void Read_Block( s, buffer )
   char *buffer;
 
   {
-  off_t end_addr = (long) s->device_size * K - 1;
+  off_t end_addr;
   off_t block_addr;
+  end_addr = (long) s->device_size * s->block_size - 1;
 
   if ( s->address < 0 )
     s->address = 0L;
@@ -120,7 +121,8 @@ void Read_Super_Block( s )
   unsigned inodes_per_block;
   off_t size;
 
-  Read_Disk( s, (long) 1 * K, s->buffer );
+  s->block_size = K;
+  Read_Disk( s, (long) SUPER_BLOCK_BYTES, s->buffer );
 
   s->magic = super->s_magic;
   if ( s->magic == SUPER_MAGIC )
@@ -133,14 +135,19 @@ void Read_Super_Block( s )
     s->zone_num_size = V1_ZONE_NUM_SIZE;
     s->zones = super->s_nzones;
     s->ndzones = V1_NR_DZONES;
+    s->block_size = STATIC_BLOCK_SIZE;
     }
-  else if ( s->magic == SUPER_V2 )
+  else if ( s->magic == SUPER_V2 || s->magic == SUPER_V3)
     {
+    if(s->magic == SUPER_V3)
+       s->block_size = super->s_block_size;
+    else
+       s->block_size = STATIC_BLOCK_SIZE;
     s->is_fs = TRUE;
     s->v1 = FALSE;
     s->inode_size = V2_INODE_SIZE;
-    inodes_per_block = V2_INODES_PER_BLOCK(STATIC_BLOCK_SIZE);
-    s->nr_indirects = V2_INDIRECTS(STATIC_BLOCK_SIZE);
+    inodes_per_block = V2_INODES_PER_BLOCK(s->block_size);
+    s->nr_indirects = V2_INDIRECTS(s->block_size);
     s->zone_num_size = V2_ZONE_NUM_SIZE;
     s->zones = super->s_zones;
     s->ndzones = V2_NR_DZONES;
@@ -159,7 +166,7 @@ void Read_Super_Block( s )
     }
 
   s->inodes = super->s_ninodes;
-  s->inode_maps = bitmapsize( (bit_t) s->inodes + 1 , STATIC_BLOCK_SIZE);
+  s->inode_maps = bitmapsize( (bit_t) s->inodes + 1 , s->block_size);
   if ( s->inode_maps != super->s_imap_blocks )
     {
     if ( s->inode_maps > super->s_imap_blocks )
@@ -169,7 +176,7 @@ void Read_Super_Block( s )
     s->inode_maps = super->s_imap_blocks;
     }
 
-  s->zone_maps = bitmapsize( (bit_t) s->zones , STATIC_BLOCK_SIZE);
+  s->zone_maps = bitmapsize( (bit_t) s->zones , s->block_size);
   if ( s->zone_maps != super->s_zmap_blocks )
     {
     if ( s->zone_maps > super->s_zmap_blocks )
index 96ae94c41af8813ca2cd2c147cbc37cef7de79e9..fb56dc7eda9f33ae008a68fe2bcaad383b0a15e4 100755 (executable)
@@ -453,7 +453,7 @@ int Indirect( s, block, file_size, dblind )
   union
     {
     zone1_t ind1[ V1_INDIRECTS ];
-    zone_t  ind2[ V2_INDIRECTS(STATIC_BLOCK_SIZE) ];
+    zone_t  ind2[ V2_INDIRECTS(MAX_BLOCK_SIZE) ];
     } indirect;
   int  i;
   zone_t zone;
index 9bd0acec93523a99103a3b1efab3ac96821f3407..350f5c489f8062ad80c6b7e245624d64f267db57 100755 (executable)
@@ -383,6 +383,8 @@ void Draw_Strings( s )
                        break;
     case SUPER_V2_REV :        printf( "V2-bytes-swapped file system (?)  ");
                        break;
+    case SUPER_V3 :    printf( "V3 file system  ");
+                       break;
     default :          printf( "not a Minix file system  ");
                        break;
     }