comparison src/file_read.cbc @ 146:fd166dda4361

tweak return value at file_read.cbc
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Dec 2019 14:15:27 +0900
parents f70c4ec3fb8a
children 06449f2ae0c7
comparison
equal deleted inserted replaced
145:6c81e02e323f 146:fd166dda4361
23 sys_read->next = C_nextFileRead; 23 sys_read->next = C_nextFileRead;
24 return sys_read; 24 return sys_read;
25 } 25 }
26 26
27 SysRead* createFileReadInstFromFile(struct Context* cbc_context, struct file* f,char* addr, int n) { 27 SysRead* createFileReadInstFromFile(struct Context* cbc_context, struct file* f,char* addr, int n) {
28 SysRead* self;
29 if (f->type == FD_PIPE) { 28 if (f->type == FD_PIPE) {
30 self = create_piperead(cbc_context, f->pipe, addr, n, next); 29 return create_piperead(cbc_context, f->pipe, addr, n, next);
31 } 30 }
32 31
33 if (f->type == FD_INODE) { 32 if (f->type == FD_INODE) {
34 ilock(f->ip); 33 ilock(f->ip);
35 self = create_readi(cbc_context, f->ip, addr, f->off, n, cbc_fileread1); 34 return create_readi(cbc_context, f->ip, addr, f->off, n, cbc_fileread1);
36 } 35 }
37 return self; 36 return NULL; //Error?
38 } 37 }
39 38
40 39
41 __code cbc_fileread1FileRead(struct FileRead* file_read, struct file* f,int r,__code next(r,...)) { 40 __code cbc_fileread1FileRead(struct FileRead* file_read, struct file* f,int r,__code next(r,...)) {
42 41
55 __code selectReadInstance(struct file* f) { 54 __code selectReadInstance(struct file* f) {
56 if (f->readable == 0) { 55 if (f->readable == 0) {
57 goto next(-1); 56 goto next(-1);
58 } 57 }
59 SysRead* read = createFileReadInstFromFile(proc->cbc_context, f); 58 SysRead* read = createFileReadInstFromFile(proc->cbc_context, f);
60 read->read(f,addr,n); 59 goto read->read(f,addr,n);
61 } 60 }
62 61
63 __code nextFileRead(...) { 62 __code nextFileRead(...) {
64 63
65 } 64 }