]> Zhao Yanbai Git Server - kernel.git/commitdiff
fix bug in ext2_read_inode
authorAceVest <zhaoyanbai@126.com>
Thu, 10 Jul 2014 16:55:19 +0000 (00:55 +0800)
committerAceVest <zhaoyanbai@126.com>
Thu, 10 Jul 2014 16:55:19 +0000 (00:55 +0800)
Makefile
drivers/ide.c
fs/ext2.c
kernel/clock.c
scripts/init.sh

index b7b354268113ca9eeae9b72509038a2211552f3e..0cfd1a54b8b434395fc49a8efcfb7a92ef9f2493 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,8 @@ install:
        sync
        md5sum /boot/KERNEL.BIN
        md5sum KERNEL.BIN
-
+       mkdir -p /kernel/bin/
+       cp bin/hello /kernel/bin/
+       cp bin/shell /kernel/bin/
 cp:
        ./scripts/copy.sh
index 2dee6256b601d629b63cefc2668196348ebde69e..b16639ea2d9eb5f3766e87de48bd74fdf90fa0af 100644 (file)
@@ -137,6 +137,7 @@ void ide_do_read(u64_t lba, u32_t scnt, char *buf)
         task->state = TASK_WAIT;
         irq_save(flags);
         finish = r->finish;
+        printd("%s pid %d finish %u read_scnt %u scnt %u\n", __func__, sysc_getpid(), r->finish, r->read_scnt, r->scnt);
         irq_restore(flags);
 
         if(finish)
index ffd6ef4c2b94f01c5b19c4cbeae44c244ca189d2..d8b6fc0a1efa65f600f36df09cb2e38f9cd373ef 100644 (file)
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -18,13 +18,16 @@ struct {
 
 extern void blk_rw(dev_t dev, u64_t offset, u32_t scnt, char *buf);
 
-#define BLKRW(blkid, blkcnt, buf) do { blk_rw(system.root_dev, (blkid)*EXT2_BLOCK_SIZE, (blkcnt)*EXT2_BLOCK_SIZE, buf); } while(0)
+#define BLKRW(blkid, blkcnt, buf) do { blk_rw(system.root_dev, 1ULL*(blkid)*EXT2_BLOCK_SIZE, (blkcnt)*EXT2_BLOCK_SIZE, buf); } while(0)
 
 kmem_cache_t *ext2_block_cache;
 kmem_cache_t *ext2_inode_cache;
 
 ext2_inode_t ext2_root_inode;
 
+static ext2_inode_t boot_inode;
+static ext2_inode_t krnl_inode;
+
 void *ext2_alloc_block()
 {
     return (void *) kmem_cache_alloc(ext2_block_cache, 0);
@@ -32,6 +35,7 @@ void *ext2_alloc_block()
 
 void *ext2_free_block(void *blk)
 {
+    return;
     kmem_cache_free(ext2_block_cache, blk);
 }
 
@@ -41,6 +45,7 @@ void *ext2_alloc_inode()
 }
 
 #define ext2_gd(n) ((ext2_gd_t*)(EXT2_GD) + (n))
+unsigned int sys_clock();
 void ext2_read_inode(unsigned int ino, ext2_inode_t *inode)
 {
     void *blk = ext2_alloc_block();
@@ -59,11 +64,11 @@ void ext2_read_inode(unsigned int ino, ext2_inode_t *inode)
     blkid += ext2_gd(gn)->bg_inode_table;
     inoff *= EXT2_INODE_SIZE;
 
-    printk("group %u %u blkid %u blkoff %u\n", gn, gi, blkid, inoff);
+    printd("group %u %u blkid %u blkoff %u clock %u\n", gn, gi, blkid, inoff, sys_clock());
 
     BLKRW(blkid, 1, blk);
 
-    memcpy(inode, blk+inoff, EXT2_INODE_SIZE);
+    memcpy(inode, blk+inoff, sizeof(ext2_inode_t));
 
     ext2_free_block(blk);
 }
@@ -98,6 +103,7 @@ unsigned int ext2_search_indir(const char *name, const ext2_inode_t *inode)
     return ino;
 }
 
+
 void ext2_setup_fs()
 {
     memset(&ext2_fs, 0, sizeof(ext2_fs));
@@ -151,8 +157,6 @@ void ext2_setup_fs()
     printk("root inode size %u \n", ext2_root_inode.i_size);
     printk("root blocks %u \n", ext2_root_inode.i_blocks);
 
-    static ext2_inode_t boot_inode;
-    static ext2_inode_t krnl_inode;
 
     ext2_read_inode(ext2_search_indir("boot", &ext2_root_inode), &boot_inode);
     ext2_read_inode(ext2_search_indir("Kernel", &boot_inode), &krnl_inode);
index b5d1c046cb1b3f2c478c9f23515ec159562034e7..884e49e04058d76ff2f4ba9ab6732523a14de1ba 100644 (file)
@@ -24,6 +24,6 @@ void clk_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
 {
     jiffies++;
 
-    printd("^");
+    //printd("^");
     printl(MPL_CLOCK, "clock:%d", jiffies);
 }
index 01cb172b538cc5d9fd618a132896199bd9ddaa11..e21441378644fcbb6824283c16e31e17c86858f5 100755 (executable)
@@ -33,7 +33,7 @@ PART=${lodev}p1
 
 sleep 1
 
-mkfs.ext2 $PART
+mke2fs -b 4096 $PART
 
 sleep 1
 
@@ -55,8 +55,6 @@ cp grub.cfg ${MNT}/boot/grub2/
 cp ../KERNEL.BIN ${MNT}/boot/Kernel
 
 mkdir -p ${MNT}/bin/
-cp ../bin/hw ${MNT}/bin/
-cp ../bin/sh ${MNT}/bin/
 
 sleep 1