180
|
1 #include "../context.h"
|
|
2 #interface "file.h"
|
|
3
|
|
4 // ----
|
|
5 // typedef struct none<Impl, Isa> impl file {
|
|
6 //
|
|
7 // } none;
|
|
8 // ----
|
|
9
|
|
10 file* createnone(struct Context* cbc_context) {
|
|
11 struct file* file = new file();
|
|
12 struct none* none = new none();
|
|
13 file->file = (union Data*)none;
|
|
14 file->remoe = 0;
|
|
15 file->off = 0;
|
|
16 file->st = NULL;
|
|
17 file->addr = NULL;
|
|
18 file->pipe = 0;
|
|
19 file->inode = 0;
|
|
20 file->n = 0;
|
|
21 file->fd = 0;
|
|
22 file->stat = C_statnone;
|
|
23 file->read = C_readnone;
|
|
24 file->write = C_writenone;
|
|
25 file->close = C_closenone;
|
|
26 return file;
|
|
27 }
|
|
28 __code statnone(struct none* file, struct stat* st, __code next(...)) {
|
|
29
|
|
30 goto next(...);
|
|
31 }
|
|
32
|
|
33 __code readnone(struct none* file, char* addr, __code next(...)) {
|
|
34
|
|
35 goto next(...);
|
|
36 }
|
|
37
|
|
38 __code writenone(struct none* file, char* addr, int n, __code next(...)) {
|
|
39
|
|
40 goto next(...);
|
|
41 }
|
|
42
|
|
43 __code closenone(struct none* file,int fd, __code next(...)) {
|
|
44
|
190
|
45 goto file->noneclose(file->file, next);
|
180
|
46 }
|
190
|
47
|
|
48 __code noneclose(struct none* none, struct file* file, __code next(...){
|
|
49 struct file ff;
|
|
50 acquire(*ftable.loc)
|
|
51
|
|
52 if (f->ref < 1) {
|
|
53 goto cbc_context->kernel_error->panic("file close");
|
|
54 }
|
|
55 goto pipe->cbc_noneclose2(f,ff,next);
|
|
56 }
|
|
57
|
|
58 __code noneclose2(struct none* none,struct file* file, struct file* ff,__code next(...)){
|
|
59 if (--f->ref > 0) {
|
|
60 release(&ftable.lock);
|
|
61 goto cbc_context->return();
|
|
62 }
|
|
63 goto pipe->cbc_pipeclose3(f,ff,next);
|
|
64 }
|