comparison src/console.c @ 26:a146855e16eb

bugfix
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 17 Jan 2019 19:43:22 +0900
parents 36bd61f5c847
children 1a64b5645cdd
comparison
equal deleted inserted replaced
25:a5ccbc210ff8 26:a146855e16eb
216 } 216 }
217 217
218 __code cbc_consoleread (struct inode *ip, char *dst, int n, __code(*next)(int ret)) 218 __code cbc_consoleread (struct inode *ip, char *dst, int n, __code(*next)(int ret))
219 { 219 {
220 uint target; 220 uint target;
221 int c;
222 221
223 iunlock(ip); 222 iunlock(ip);
224 223
225 target = n; 224 target = n;
226 acquire(&input.lock); 225 acquire(&input.lock);
232 ilock(ip); 231 ilock(ip);
233 goto next(-1); 232 goto next(-1);
234 } 233 }
235 234
236 proc->cbc_arg.cbc_console_arg.n = n; 235 proc->cbc_arg.cbc_console_arg.n = n;
236 proc->cbc_arg.cbc_console_arg.target = target;
237 proc->cbc_arg.cbc_console_arg.dst = dst; 237 proc->cbc_arg.cbc_console_arg.dst = dst;
238 proc->cbc_arg.cbc_console_arg.ip = ip; 238 proc->cbc_arg.cbc_console_arg.ip = ip;
239 proc->cbc_arg.cbc_console_arg.next = next; 239 proc->cbc_arg.cbc_console_arg.next = next;
240 goto cbc_sleep(&input.r, &input.lock, cbc_consoleread1); 240 goto cbc_sleep(&input.r, &input.lock, cbc_consoleread1);
241 } 241 }
242 }
242 } 243 }
243 244
244 __code cbc_consoleread1 (__code(*next)(int ret)) 245 __code cbc_consoleread1 (__code(*next)(int ret))
245 { 246 {
246 int cont = 1; 247 int cont = 1;
247 proc->cbc_arg.cbc_console_arg.n = n; 248 int n = proc->cbc_arg.cbc_console_arg.n;
248 proc->cbc_arg.cbc_console_arg.dst = dst; 249 int target = proc->cbc_arg.cbc_console_arg.target;
249 proc->cbc_arg.cbc_console_arg.ip = ip; 250 char* dst = proc->cbc_arg.cbc_console_arg.dst;
251 struct inode *ip = proc->cbc_arg.cbc_console_arg.ip;
250 252
251 c = input.buf[input.r++ % INPUT_BUF]; 253 int c = input.buf[input.r++ % INPUT_BUF];
252 254
253 if (c == C('D')) { // EOF 255 if (c == C('D')) { // EOF
254 if (n < target) { 256 if (n < target) {
255 // Save ^D for next time, to make sure 257 // Save ^D for next time, to make sure
256 // caller gets a 0-byte result. 258 // caller gets a 0-byte result.