# HG changeset patch # User menikon # Date 1580372085 -32400 # Node ID bc2f3d24faa9bb630a17a7aa8ea973180c0c3da9 # Parent 7ec574dfe64fee954468f0cbeb807d5bdb724a23 add fs_impl_private diff -r 7ec574dfe64f -r bc2f3d24faa9 src/CMakeLists.txt --- a/src/CMakeLists.txt Thu Jan 30 14:53:02 2020 +0900 +++ b/src/CMakeLists.txt Thu Jan 30 17:14:45 2020 +0900 @@ -129,7 +129,7 @@ string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.cbc fs.c log.c main.c memide.c pipe.cbc proc.cbc spinlock.cbc start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c SingleLinkedStack.cbc entry.S impl/vm_impl.cbc impl/vm_impl_private.cbc -impl/fs_impl.cbc +impl/fs_impl.cbc impl/fs_impl_private.cbc ) # sys_read_impl.cbc diff -r 7ec574dfe64f -r bc2f3d24faa9 src/gearsTools/lib/Gears/Context/Template/XV6.pm --- a/src/gearsTools/lib/Gears/Context/Template/XV6.pm Thu Jan 30 14:53:02 2020 +0900 +++ b/src/gearsTools/lib/Gears/Context/Template/XV6.pm Thu Jan 30 17:14:45 2020 +0900 @@ -166,6 +166,8 @@ typedef uint32 pde_t; typedef struct stat stat; typedef struct superblock superblock; +typedef struct buf buf; +typedef struct dinode dinode; EOFEOF print $out $str; } diff -r 7ec574dfe64f -r bc2f3d24faa9 src/impl/fs_impl.cbc --- a/src/impl/fs_impl.cbc Thu Jan 30 14:53:02 2020 +0900 +++ b/src/impl/fs_impl.cbc Thu Jan 30 17:14:45 2020 +0900 @@ -1,7 +1,13 @@ -#include "../../context.h" +#include "types.h" #include "defs.h" +#include "param.h" +#include "stat.h" +#include "mmu.h" +#include "proc.h" +#include "spinlock.h" +#include "buf.h" #include "fs.h" -#include "buf.h" +#include "file.h" #interface "fs.dg" // ---- @@ -22,6 +28,8 @@ fs->readsb = C_readsbfs_impl; fs->iinit = C_iinitfs_impl; fs->ialloc = C_iallocfs_impl; + fs_impl->allocinode = C_allocinode; + fs_impl->allocinode_loop = C_allocinode_loop; fs->iupdate = C_iupdatefs_impl; fs->idup = C_idupfs_impl; fs->ilock = C_ilockfs_impl; @@ -51,14 +59,20 @@ goto next(...); } +struct { + struct spinlock lock; + struct inode inode[NINODE]; +} icache; + __code iinitfs_impl(struct fs_impl* fs, __code next(...)) { + initlock(&icache.lock, "icache"); + goto next(...); } __code iallocfs_impl(struct fs_impl* fs, uint dev, short type, __code next(...)) { - - goto next(...); + goto allocinode(fs, dev, type, next(...)); } __code iupdatefs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { diff -r 7ec574dfe64f -r bc2f3d24faa9 src/impl/fs_impl.h --- a/src/impl/fs_impl.h Thu Jan 30 14:53:02 2020 +0900 +++ b/src/impl/fs_impl.h Thu Jan 30 17:14:45 2020 +0900 @@ -1,7 +1,13 @@ -typedef struct fs_impl impl fs{ +typedef struct fs_impl impl fs{ union Data* fs_impl; - + struct superblock* sb; + uint dev; + short type; + struct buf* bp; + struct dinode* dip; + int inum; - - + __code allocinode(Type* fs_impl, uint dev, short type, __code next(...)); + __code allocinode_loop(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)); + __code next(...); } fs_impl; diff -r 7ec574dfe64f -r bc2f3d24faa9 src/impl/fs_impl_private.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/fs_impl_private.cbc Thu Jan 30 17:14:45 2020 +0900 @@ -0,0 +1,31 @@ +#include "types.h" +#include "defs.h" +#include "param.h" +#include "stat.h" +#include "mmu.h" +#include "proc.h" +#include "spinlock.h" +#include "buf.h" +#include "fs.h" +#include "file.h" +#interface "fs_impl.h" + +/* +fs_impl* createfs_impl2(); +*/ + +__code allocinode(struct fs_impl* fs_impl, uint dev, struct superblock* sb, __code next(...)){ //:skip + + readsb(dev, sb); + + goto allocinode_loop(fs_impl, inum, dev, sb, bp, dip, next(...)); + +} + +typedef struct buf buf; +typedef struct dinode dinode; +__code allocinode_loop(struct fs_impl* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)){ //:skip + + goto next(...); + +}