annotate src/impl/fs_impl.cbc @ 306:5ea0b8b12aaf

tweak
author menikon
date Fri, 31 Jan 2020 18:48:54 +0900
parents a101eb88b1cd
children 4cf83e6ce534
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;
306
menikon
parents: 305
diff changeset
38 fs_impl->lockinode1 = C_lockinode1;
menikon
parents: 305
diff changeset
39 fs_impl->lockinode_sleepcheck = C_lockinode_sleepcheck;
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
40 fs->iunlock = C_iunlockfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
41 fs->iput = C_iputfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
42 fs->iunlockput = C_iunlockputfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
43 fs->stati = C_statifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
44 fs->readi = C_readifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
45 fs->writei = C_writeifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
46 fs->namecmp = C_namecmpfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
47 fs->dirlookup = C_dirlookupfs_impl;
296
menikon
parents: 295
diff changeset
48 fs->dirlink = C_dirlinkfs_impl;
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
49 fs->namei = C_nameifs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
50 fs->nameiparent = C_nameiparentfs_impl;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
51 return fs;
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
52 }
298
2e71e7776062 fix generate_stub
anatofuz
parents: 296
diff changeset
53
299
e825c247ab24 build success
menikon
parents: 298
diff changeset
54 typedef struct superblock superblock;
296
menikon
parents: 295
diff changeset
55 __code readsbfs_impl(struct fs_impl* fs, uint dev, struct superblock* sb, __code next(...)) { //:skip
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
56
301
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
57 struct buf* bp;
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
58
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
59 bp = bread(dev, 1);
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
60 memmove(sb, bp->data, sizeof(*sb));
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
61 brelse(bp);
7ec574dfe64f fix readsb
menikon
parents: 299
diff changeset
62
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
63 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
64 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
65
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
66 struct {
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
67 struct spinlock lock;
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
68 struct inode inode[NINODE];
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
69 } icache;
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
70
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
71 __code iinitfs_impl(struct fs_impl* fs, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
72
302
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
73 initlock(&icache.lock, "icache");
bc2f3d24faa9 add fs_impl_private
menikon
parents: 301
diff changeset
74
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
75 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
76 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
77
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
78 __code iallocfs_impl(struct fs_impl* fs, uint dev, short type, __code next(...)) {
305
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
79 goto allocinode(fs, dev, sb, next(...));
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
80 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
81
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
82 __code iupdatefs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
83
305
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
84 struct buf *bp;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
85 struct dinode *dip;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
86
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
87 bp = bread(ip->dev, IBLOCK(ip->inum));
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
88
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
89 dip = (struct dinode*) bp->data + ip->inum % IPB;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
90 dip->type = ip->type;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
91 dip->major = ip->major;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
92 dip->minor = ip->minor;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
93 dip->nlink = ip->nlink;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
94 dip->size = ip->size;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
95
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
96 memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
97 log_write(bp);
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
98 brelse(bp);
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
99
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
100
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
101 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
102 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
103
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
104 __code idupfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
105
305
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
106 acquire(&icache.lock);
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
107 ip->ref++;
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
108 release(&icache.lock);
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
109
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
110 goto next(ip, ...);
a101eb88b1cd ~add lockinode CodeGear
menikon
parents: 303
diff changeset
111
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
112 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
113
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
114 __code ilockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
115
306
menikon
parents: 305
diff changeset
116 goto lockinode1(fs, ip, bp, dip, next(...));
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
117 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
118
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
119 __code iunlockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
120
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
121 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
122 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
123
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
124 __code iputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
125
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
126 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
127 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
128
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
129 __code iunlockputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
130
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
131 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
132 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
133
299
e825c247ab24 build success
menikon
parents: 298
diff changeset
134 typedef struct stat stat;
296
menikon
parents: 295
diff changeset
135 __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
136
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
137 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
138 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
139
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
140 __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
141
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
142 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
143 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
144
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
145 __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
146
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
147 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
148 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
149
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
150 __code namecmpfs_impl(struct fs_impl* fs, const char* s, const char* t, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
151
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
152 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
153 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
154
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
155 __code dirlookupfs_impl(struct inode* dp, char* name, uint* poff, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
156
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
157 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
158 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
159
296
menikon
parents: 295
diff changeset
160 __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
161
296
menikon
parents: 295
diff changeset
162 goto next(...);
294
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
163 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
164
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
165 __code nameifs_impl(struct fs_impl* fs, char* path, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
166
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
167 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
168 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
169
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
170 __code nameiparentfs_impl(struct fs_impl* fs, char* path, char* name, __code next(...)) {
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
171
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
172 goto next(...);
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
173 }
08a367c3124a add FileSystem files
menikon
parents:
diff changeset
174