@@ -311,8 +311,7 @@ uintptr_t syscall(regstate* regs) {
311
311
312
312
// It can be useful to log events using `log_printf`.
313
313
// Events logged this way are stored in the host's `log.txt` file.
314
- /* log_printf("proc %d: syscall %d at rip %p\n",
315
- current->pid, regs->reg_rax, regs->reg_rip); */
314
+ // log_printf("p%d: %s\n", current->pid, syscall_name(regs->reg_rax));
316
315
317
316
// Show the current cursor location and memory state.
318
317
console_show_cursor (cursorpos);
@@ -394,17 +393,14 @@ pid_t syscall_spawn(const char* command) {
394
393
char pipebuf[1 ];
395
394
size_t pipebuf_len = 0 ;
396
395
397
- // syscall_pipewrite(buf, sz)
398
- // Handles the SYSCALL_PIPEWRITE system call; see `sys_pipewrite`
399
- // in `u-lib.hh`.
400
-
401
396
ssize_t syscall_pipewrite (const char * buf, size_t sz) {
397
+ // See `sys_pipewrite` in `u-lib.cc` for specification.
402
398
if (sz == 0 ) {
403
399
// nothing to write
404
400
return 0 ;
405
401
} else if (pipebuf_len == 1 ) {
406
- // kernel buffer full, try again
407
- return - 1 ;
402
+ // kernel buffer full, process should try again
403
+ return E_AGAIN ;
408
404
} else {
409
405
// write one character
410
406
pipebuf[0 ] = buf[0 ];
@@ -413,17 +409,14 @@ ssize_t syscall_pipewrite(const char* buf, size_t sz) {
413
409
}
414
410
}
415
411
416
- // syscall_piperead(buf, sz)
417
- // Handles the SYSCALL_PIPEREAD system call; see `sys_piperead`
418
- // in `u-lib.hh`.
419
-
420
412
ssize_t syscall_piperead (char * buf, size_t sz) {
413
+ // See `sys_piperead` in `u-lib.cc` for specification.
421
414
if (sz == 0 ) {
422
415
// no room to read
423
416
return 0 ;
424
417
} else if (pipebuf_len == 0 ) {
425
- // kernel buffer empty, try again
426
- return - 1 ;
418
+ // kernel buffer empty, process should try again
419
+ return E_AGAIN ;
427
420
} else {
428
421
// read one character
429
422
buf[0 ] = pipebuf[0 ];
0 commit comments