From 619b64e6f4365a12b890cb7a11ff28b570e8aa77 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Sun, 9 Jan 2005 16:07:27 +0000 Subject: [PATCH] - open() no longer examines a file after opening it in order to figure out whether read/write accesses are permitted. This decision is now for the file system to make. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14799 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/changes | 4 +++ library/fcntl_open.c | 66 ++------------------------------------------ 2 files changed, 7 insertions(+), 63 deletions(-) diff --git a/library/changes b/library/changes index e380727..02f4800 100644 --- a/library/changes +++ b/library/changes @@ -40,6 +40,10 @@ - Switched over the last use of DeviceProc() to GetDeviceProc(), etc. +- open() no longer examines a file after opening it in order to figure + out whether read/write accesses are permitted. This decision is now + for the file system to make. + c.lib 1.185 (2.1.2005) diff --git a/library/fcntl_open.c b/library/fcntl_open.c index b38c81e..5fe950e 100644 --- a/library/fcntl_open.c +++ b/library/fcntl_open.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_open.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $ + * $Id: fcntl_open.c,v 1.7 2005-01-09 16:07:27 obarthel Exp $ * * :ts=4 * @@ -53,39 +53,9 @@ /****************************************************************************/ -/* This is used in place of ExamineFH() in order to work around a bug in +/* This is used in place of ChangeMode() in order to work around a bug in dos.library V40 and below: a "NIL:" file handle will crash the - ExamineFH() function. */ -static LONG -safe_examine_file_handle(BPTR file_handle,struct FileInfoBlock *fib) -{ - LONG result = DOSFALSE; - - assert( fib != NULL ); - - #ifndef __amigaos4__ - { - struct FileHandle * fh = (struct FileHandle *)BADDR(file_handle); - - if(fh == NULL || fh->fh_Type == NULL) - { - SetIoErr(ERROR_OBJECT_WRONG_TYPE); - goto out; - } - } - #endif /* __amigaos4__ */ - - PROFILE_OFF(); - result = ExamineFH(file_handle,fib); - PROFILE_ON(); - - out: - - return(result); -} - -/* Same thing as above, but for ChangeMode(), which suffers from - the same problem. */ + caller of the ChangeMode() function. */ static LONG safe_change_mode(LONG type,BPTR file_handle,LONG mode) { @@ -356,36 +326,6 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) goto out; } - if(safe_examine_file_handle(handle,fib) != DOSFALSE) - { - BOOL operation_permitted = TRUE; - - /* Check if the file is readable. */ - if(FLAG_IS_SET(fib->fib_Protection,FIBF_READ)) - { - if(access_mode == O_RDONLY || - access_mode == O_RDWR) - { - operation_permitted = FALSE; - } - } - - /* Check if the file can be written to. */ - if(FLAG_IS_SET(fib->fib_Protection,FIBF_WRITE)) - { - if(access_mode == O_WRONLY) - operation_permitted = FALSE; - } - - if(NOT operation_permitted) - { - SHOWMSG("this object must not be opened"); - - errno = EACCES; - goto out; - } - } - fd = __fd[fd_slot_number]; __initialize_fd(fd,(HOOKFUNC)__fd_hook_entry,handle,0);