diff --git a/modules/src/system/break.c b/modules/src/system/break.c index 90013c842..328b0dc32 100644 --- a/modules/src/system/break.c +++ b/modules/src/system/break.c @@ -13,7 +13,7 @@ sys_break(incr) int incr; { char *sbrk(); - char *brk = sbrk(incr); + register char *brk = sbrk(incr); if (brk == (char *) 0 || brk == (char *)-1) return ILL_BREAK; diff --git a/modules/src/system/open.c b/modules/src/system/open.c index a1720e68f..51dd2c59f 100644 --- a/modules/src/system/open.c +++ b/modules/src/system/open.c @@ -14,42 +14,36 @@ sys_open(path, flag, filep) int flag; File **filep; { - register fd; + register int fd; register File *fp; - int open_mode; long lseek(); + if ((fp = _get_entry()) == (File *)0) + return 0; switch (flag) { case OP_READ: - open_mode = 0; + if ((fd = open(path, 0)) < 0) + return 0; break; - case OP_WRITE: case OP_APPEND: - open_mode = 1; + if ((fd = open(path, 1)) < 0) { + if (access(path, 0) == 0) + return 0; + } + else { + if (lseek(fd, 0L, 2) < 0L) { + close(fd); + return 0; + } + } + /* Fall through */ + case OP_WRITE: + if ((fd = creat(path, 0644)) < 0) + return 0; break; default: return 0; } - if ((fp = _get_entry()) == (File *)0) - return 0; - if (flag == OP_WRITE) { - if ((fd = creat(path, 0644)) < 0) - return 0; - } - else /* OP_READ or OP_APPEND */ - if ((fd = open(path, open_mode)) < 0) { - if (flag == OP_READ || access(path, 0) == 0) - return 0; - /* now: flag == OP_APPEND */ - if ((fd = creat(path, 0644)) < 0) - return 0; - } - else { - if (flag == OP_APPEND && (lseek(fd, 0L, 2) < 0L)) { - close(fd); - return 0; - } - } fp->o_flags = flag; fp->o_fd = fd; *filep = fp;