mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- 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
This commit is contained in:
@@ -40,6 +40,10 @@
|
|||||||
|
|
||||||
- Switched over the last use of DeviceProc() to GetDeviceProc(), etc.
|
- 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)
|
c.lib 1.185 (2.1.2005)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* :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
|
dos.library V40 and below: a "NIL:" file handle will crash the
|
||||||
ExamineFH() function. */
|
caller of the ChangeMode() 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. */
|
|
||||||
static LONG
|
static LONG
|
||||||
safe_change_mode(LONG type,BPTR file_handle,LONG mode)
|
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;
|
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];
|
fd = __fd[fd_slot_number];
|
||||||
|
|
||||||
__initialize_fd(fd,(HOOKFUNC)__fd_hook_entry,handle,0);
|
__initialize_fd(fd,(HOOKFUNC)__fd_hook_entry,handle,0);
|
||||||
|
|||||||
Reference in New Issue
Block a user