annotate src/impl/fs_impl.cbc @ 303:5217253368ad

rewrite ialloc
author menikon
date Fri, 31 Jan 2020 16:17:06 +0900
parents bc2f3d24faa9
children a101eb88b1cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
1 #include "types.h"
301
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
2 #include "defs.h"
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
3 #include "param.h"
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
4 #include "stat.h"
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
5 #include "mmu.h"
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
6 #include "proc.h"
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
7 #include "spinlock.h"
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
8 #include "buf.h"
301
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
9 #include "fs.h"
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
10 #include "file.h"
295
menikon
parents: 294
diff changeset
11 #interface "fs.dg"
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
12
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
13 // ----
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
14 // typedef struct fs_impl<Impl, Isa> impl fs{
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
15 // union Data* fs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
16 //
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
17 //
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
18 //
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
19 //
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
20 // } fs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
21 // ----
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
22
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
23 fs* createfs_impl(struct Context* cbc_context) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
24 struct fs* fs = new fs();
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
25 struct fs_impl* fs_impl = new fs_impl();
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
26 fs->fs = (union Data*)fs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
27 fs_impl->fs_impl = NULL;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
28 fs->readsb = C_readsbfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
29 fs->iinit = C_iinitfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
30 fs->ialloc = C_iallocfs_impl;
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
31 fs_impl->allocinode = C_allocinode;
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
32 fs_impl->allocinode_loop = C_allocinode_loop;
303
5217253368ad rewrite ialloc
menikon
parents: 302
diff changeset
33 fs_impl->allocinode_loopcheck = C_allocinode_loopcheck;
5217253368ad rewrite ialloc
menikon
parents: 302
diff changeset
34 fs_impl->allocinode_noloop = C_allocinode_noloop;
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
35 fs->iupdate = C_iupdatefs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
36 fs->idup = C_idupfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
37 fs->ilock = C_ilockfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
38 fs->iunlock = C_iunlockfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
39 fs->iput = C_iputfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
40 fs->iunlockput = C_iunlockputfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
41 fs->stati = C_statifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
42 fs->readi = C_readifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
43 fs->writei = C_writeifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
44 fs->namecmp = C_namecmpfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
45 fs->dirlookup = C_dirlookupfs_impl;
296
menikon
parents: 295
diff changeset
46 fs->dirlink = C_dirlinkfs_impl;
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
47 fs->namei = C_nameifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
48 fs->nameiparent = C_nameiparentfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
49 return fs;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
50 }
298
2e71e7776062 fix generate_stub
anatofuz
parents: 296
diff changeset
51
299
e825c247ab24 build success
menikon
parents: 298
diff changeset
52 typedef struct superblock superblock;
296
menikon
parents: 295
diff changeset
53 __code readsbfs_impl(struct fs_impl* fs, uint dev, struct superblock* sb, __code next(...)) { //:skip
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
54
301
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
55 struct buf* bp;
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
56
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
57 bp = bread(dev, 1);
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
58 memmove(sb, bp->data, sizeof(*sb));
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
59 brelse(bp);
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
60
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
61 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
62 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
63
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
64 struct {
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
65 struct spinlock lock;
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
66 struct inode inode[NINODE];
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
67 } icache;
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
68
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
69 __code iinitfs_impl(struct fs_impl* fs, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
70
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
71 initlock(&icache.lock, "icache");
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
72
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
73 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
74 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
75
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
76 __code iallocfs_impl(struct fs_impl* fs, uint dev, short type, __code next(...)) {
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
77 goto allocinode(fs, dev, type, next(...));
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
78 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
79
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
80 __code iupdatefs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
81
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
82 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
83 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
84
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
85 __code idupfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
86
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
87 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
88 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
89
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
90 __code ilockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
91
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
92 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
93 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
94
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
95 __code iunlockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
96
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
97 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
98 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
99
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
100 __code iputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
101
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
102 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
103 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
104
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
105 __code iunlockputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
106
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
107 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
108 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
109
299
e825c247ab24 build success
menikon
parents: 298
diff changeset
110 typedef struct stat stat;
296
menikon
parents: 295
diff changeset
111 __code statifs_impl(struct fs_impl* fs , struct inode* ip, struct stat* st, __code next(...)) { //:skip
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
112
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
113 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
114 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
115
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
116 __code readifs_impl(struct fs_impl* fs, struct inode* ip, char* dst, uint off, uint n, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
117
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
118 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
119 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
120
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
121 __code writeifs_impl(struct fs_impl* fs, struct inode* ip, char* src, uint off, uint n, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
122
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
123 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
124 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
125
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
126 __code namecmpfs_impl(struct fs_impl* fs, const char* s, const char* t, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
127
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
128 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
129 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
130
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
131 __code dirlookupfs_impl(struct inode* dp, char* name, uint* poff, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
132
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
133 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
134 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
135
296
menikon
parents: 295
diff changeset
136 __code dirlinkfs_impl(struct fs_impl* fs, struct inode* dp, char* name, uint inum, __code next(...)) {
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
137
296
menikon
parents: 295
diff changeset
138 goto next(...);
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
139 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
140
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
141 __code nameifs_impl(struct fs_impl* fs, char* path, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
142
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
143 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
144 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
145
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
146 __code nameiparentfs_impl(struct fs_impl* fs, char* path, char* name, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
147
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
148 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
149 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
150