Bug fixes master
authorRobert Pengelly <robertapengelly@hotmail.com>
Sat, 30 Aug 2025 04:57:29 +0000 (05:57 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Sat, 30 Aug 2025 04:57:29 +0000 (05:57 +0100)
common.c
mcopy.c
mkfs.c
mmd.c
super.h

index 20a7a3e7d7d4f5289b62d68ed40c53612c16e85b..6229a3d0e7cfaa4b69ab3e5becdcbb18713717fc 100644 (file)
--- a/common.c
+++ b/common.c
@@ -255,10 +255,10 @@ void incr_size (FILE *fp, int n, unsigned long count) {
     
     off = (n - 1) % INODES_PER_BLOCK;
     
-    size = ((unsigned long) inode[off].i_size[0]) | (((unsigned long) inode[off].i_size[1]) << 8);
+    size  = ((unsigned long) inode[off].i_size[0]) | (((unsigned long) inode[off].i_size[1]) << 8) | (((unsigned long) inode[off].i_size[2]) << 16) | (((unsigned long) inode[off].i_size[3]) << 24);
     size += count;
     
-    write_to_byte_array (inode[off].i_size, size, 2);
+    write_to_byte_array (inode[off].i_size, size, 4);
     put_block (fp, b, inode);
 
 }
diff --git a/mcopy.c b/mcopy.c
index 0fec895fda200230a7ccf11ee4894963a1e1908f..e79ece748ccc21c857db11396cf0f1b5873ce264 100644 (file)
--- a/mcopy.c
+++ b/mcopy.c
@@ -466,7 +466,7 @@ static void copy_file (FILE *fp, unsigned long parent, char *fn) {
         ct = bytes;
     }
     
-    ino = alloc_inode (ofp, mode_con (mode), 2, 1);
+    ino = alloc_inode (ofp, mode_con (mode), 0, 0);
     enter_dir (ofp, parent, basename, ino);
     
     incr_size (ofp, parent, 16L);
diff --git a/mkfs.c b/mkfs.c
index 8613126033d8a8203f9c2137f3be6bf6b84f3ea1..85e0a405645037b3ed98ff687f707810448faf4d 100644 (file)
--- a/mkfs.c
+++ b/mkfs.c
@@ -372,9 +372,10 @@ static void super (unsigned long zones, unsigned long inodes) {
     write_to_byte_array (sup->s_log_zone_size, zone_shift, 2);
     write_to_byte_array (sup->s_magic, SUPER_MAGIC, 2);
     
-    zo = 7L + NR_INDIRECTS + (NR_INDIRECTS * NR_INDIRECTS);
-    write_to_byte_array (sup->s_max_size, zo, 4);
+    zo = 7L + NR_INDIRECTS + (long) NR_INDIRECTS * NR_INDIRECTS;
+    write_to_byte_array (sup->s_max_size, zo * BLOCK_SIZE, 4);
     
+    write_to_byte_array (sup->s_state, 1, 2);
     seekto (ofp, 2);
     
     if (fwrite (buf, BLOCK_SIZE, 1, ofp) != 1) {
@@ -599,7 +600,7 @@ int main (int argc, char **argv) {
     
     super (nzones, ninodes);
     
-    rootdir (alloc_inode (ofp, 040777, 2, 2));
+    rootdir (alloc_inode (ofp, 040755, 2, 2));
     return EXIT_SUCCESS;
 
 }
diff --git a/mmd.c b/mmd.c
index d3500e09071826125335eab0d468b6baf1247e23..b38efb4cee55f7682a8e2954b4a2c9387804166f 100644 (file)
--- a/mmd.c
+++ b/mmd.c
@@ -412,7 +412,7 @@ static void walk_dir (char *dirname) {
     
     }
     
-    ino = alloc_inode (ofp, mode_con ("d--755"), 2, 1);
+    ino = alloc_inode (ofp, mode_con ("d--755"), 0, 0);
     enter_dir (ofp, parent_ino, p1, ino);
     
     incr_size (ofp, parent_ino, 16L);
diff --git a/super.h b/super.h
index 147327839dceb22a82cae9929b03e669daa01130..d46c33da090144b8fb406ac6e0291003389d1506 100644 (file)
--- a/super.h
+++ b/super.h
@@ -17,6 +17,9 @@ struct super_block {
     
     unsigned char s_max_size[4];
     unsigned char s_magic[2];
+    
+    unsigned char s_state[2];
+    unsigned char s_zones[4];
 
 };