From: AceVest Date: Thu, 10 Jul 2014 16:55:19 +0000 (+0800) Subject: fix bug in ext2_read_inode X-Git-Tag: 0.3.0~24 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.pdf?a=commitdiff_plain;h=d0c5abb190e624784e0515902550a1ff3f412295;p=kernel.git fix bug in ext2_read_inode --- diff --git a/Makefile b/Makefile index b7b3542..0cfd1a5 100644 --- 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 diff --git a/drivers/ide.c b/drivers/ide.c index 2dee625..b16639e 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -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) diff --git a/fs/ext2.c b/fs/ext2.c index ffd6ef4..d8b6fc0 100644 --- 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); diff --git a/kernel/clock.c b/kernel/clock.c index b5d1c04..884e49e 100644 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -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); } diff --git a/scripts/init.sh b/scripts/init.sh index 01cb172..e214413 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -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