From: Chris Hanson Date: Thu, 8 Nov 1990 11:07:33 +0000 (+0000) Subject: * (fd_channel_type): Don't signal error if the system call fails, just X-Git-Tag: 20090517-FFI~11100 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=12acd1cc4277e4af0535422b6af64c93ca918e25;p=mit-scheme.git * (fd_channel_type): Don't signal error if the system call fails, just return unknown type. Add case for directory type. * (OS_open_load_file, OS_open_dump_file): Permit only files and FIFOs. --- diff --git a/v7/src/microcode/uxfile.c b/v7/src/microcode/uxfile.c index 5a55513cc..6cf9be8ec 100644 --- a/v7/src/microcode/uxfile.c +++ b/v7/src/microcode/uxfile.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfile.c,v 1.1 1990/06/20 19:37:09 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfile.c,v 1.2 1990/11/08 11:07:33 cph Exp $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -42,7 +42,8 @@ static enum channel_type DEFUN (fd_channel_type, (fd), int fd) { struct stat stat_buf; - STD_VOID_SYSTEM_CALL ("fstat", (UX_fstat (fd, (&stat_buf)))); + if ((UX_fstat (fd, (&stat_buf))) < 0) + return (channel_type_unknown); { mode_t type = ((stat_buf . st_mode) & S_IFMT); return @@ -51,6 +52,7 @@ DEFUN (fd_channel_type, (fd), int fd) #ifdef S_IFIFO : (type == S_IFIFO) ? channel_type_fifo #endif + : (type == S_IFDIR) ? channel_type_directory : channel_type_unknown); } } @@ -100,6 +102,17 @@ DEFUN (OS_open_append_file, (filename), CONST char * filename) #endif +static Tchannel +DEFUN (make_load_channel, (fd), int fd) +{ + enum channel_type type = (fd_channel_type (fd)); + if ((type == channel_type_terminal) + || (type == channel_type_directory) + || (type == channel_type_unknown)) + return (NO_CHANNEL); + MAKE_CHANNEL (fd, type, return); +} + Tchannel DEFUN (OS_open_load_file, (filename), CONST char * filename) { @@ -107,7 +120,7 @@ DEFUN (OS_open_load_file, (filename), CONST char * filename) { int fd = (UX_open (filename, O_RDONLY, MODE_REG)); if (fd >= 0) - MAKE_CHANNEL (fd, channel_type_file, return); + return (make_load_channel (fd)); if (errno != EINTR) return (NO_CHANNEL); } @@ -121,7 +134,7 @@ DEFUN (OS_open_dump_file, (filename), CONST char * filename) { int fd = (UX_open (filename, (O_WRONLY | O_CREAT | O_TRUNC), MODE_REG)); if (fd >= 0) - MAKE_CHANNEL (fd, channel_type_file, return); + return (make_load_channel (fd)); if (errno != EINTR) return (NO_CHANNEL); }