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