From 037d5ffb26ebf5c6e7625d261677403be805a076 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Thu, 30 Jun 2005 12:59:49 +0000 Subject: [PATCH] Basic fixes to make de start to read v3 filesystems. (Not complete.) --- commands/de/de.h | 4 +++- commands/de/de_diskio.c | 23 +++++++++++++++-------- commands/de/de_recover.c | 2 +- commands/de/de_stdout.c | 2 ++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/commands/de/de.h b/commands/de/de.h index f6c75951e..550587d61 100755 --- a/commands/de/de.h +++ b/commands/de/de.h @@ -63,6 +63,7 @@ /****************************************************************/ #undef printf #include +#include /* 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 */ diff --git a/commands/de/de_diskio.c b/commands/de/de_diskio.c index 09e462ea6..fe53f974c 100755 --- a/commands/de/de_diskio.c +++ b/commands/de/de_diskio.c @@ -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 ) diff --git a/commands/de/de_recover.c b/commands/de/de_recover.c index 96ae94c41..fb56dc7ed 100755 --- a/commands/de/de_recover.c +++ b/commands/de/de_recover.c @@ -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; diff --git a/commands/de/de_stdout.c b/commands/de/de_stdout.c index 9bd0acec9..350f5c489 100755 --- a/commands/de/de_stdout.c +++ b/commands/de/de_stdout.c @@ -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; } -- 2.44.0