1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- __get_default_file() now dynamically fills in file handles for the

stdin/stdout/stderr streams if it's part of the thread-safe library.

- fpathconf() now checks if the file descriptor is really referring to a file.

- The termios hook entry code could file descriptor's embedded file handle
  rather than what the thread safe library had dynamically bound to the
  stdin/stdout/stderr streams.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15130 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2006-09-12 14:16:44 +00:00
parent ead90dee0d
commit f3dcdfe1ce
4 changed files with 84 additions and 6 deletions

View File

@ -1,3 +1,12 @@
- __get_default_file() now dynamically fills in file handles for the
stdin/stdout/stderr streams if it's part of the thread-safe library.
- fpathconf() now checks if the file descriptor is really referring to a file.
- The termios hook entry code could file descriptor's embedded file handle
rather than what the thread safe library had dynamically bound to the
stdin/stdout/stderr streams.
- execve() now finds commands in the current directory again, even if you
omit the leading "./" path name.

View File

@ -1,5 +1,5 @@
/*
* $Id: fcntl_get_default_file.c,v 1.5 2006-01-08 12:04:22 obarthel Exp $
* $Id: fcntl_get_default_file.c,v 1.6 2006-09-12 14:16:44 obarthel Exp $
*
* :ts=4
*
@ -44,8 +44,9 @@
int
__get_default_file(int file_descriptor,long * file_ptr)
{
struct fd * fd;
int result = ERROR;
struct fd * fd;
BPTR file;
assert( file_descriptor >= 0 && file_descriptor < __num_fd );
assert( __fd[file_descriptor] != NULL );
@ -59,11 +60,73 @@ __get_default_file(int file_descriptor,long * file_ptr)
goto out;
}
(*file_ptr) = (long)fd->fd_DefaultFile;
__fd_unlock(fd);
#if defined(__THREAD_SAFE)
{
/* Check if this file should be dynamically bound to one of the
three standard I/O streams. */
if(FLAG_IS_SET(fd->fd_Flags,FDF_STDIO))
{
switch(fd->fd_DefaultFile)
{
case STDIN_FILENO:
file = Input();
break;
case STDOUT_FILENO:
file = Output();
break;
case STDERR_FILENO:
#if defined(__amigaos4__)
{
file = ErrorOutput();
}
#else
{
struct Process * this_process = (struct Process *)FindTask(NULL);
file = this_process->pr_CES;
}
#endif /* __amigaos4__ */
/* The following is rather controversial; if the standard error stream
is unavailable, we default to reuse the standard output stream. This
is problematic if the standard output stream was redirected and should
not be the same as the standard error output stream. */
if(file == ZERO)
file = Output();
break;
default:
file = ZERO;
break;
}
}
else
{
file = fd->fd_DefaultFile;
}
}
#else
{
file = fd->fd_DefaultFile;
}
#endif /* __THREAD_SAFE */
(*file_ptr) = (long)file;
result = 0;
out:
__fd_unlock(fd);
return(result);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: termios_console_fdhookentry.c,v 1.2 2006-01-08 12:04:27 obarthel Exp $
* $Id: termios_console_fdhookentry.c,v 1.3 2006-09-12 14:16:44 obarthel Exp $
*
* :ts=4
*
@ -328,7 +328,7 @@ __termios_console_hook(
}
else
{
if(WaitForChar(fd->fd_DefaultFile,100000*tios->c_cc[VTIME]))
if(WaitForChar(file,100000*tios->c_cc[VTIME]))
result = Read(file,fam->fam_Data,fam->fam_Size);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_fpathconf.c,v 1.1 2006-07-28 14:37:28 obarthel Exp $
* $Id: unistd_fpathconf.c,v 1.2 2006-09-12 14:16:44 obarthel Exp $
*
* :ts=4
*
@ -63,6 +63,12 @@ fpathconf(int file_descriptor,int name)
goto out;
}
if(FLAG_IS_SET(fd->fd_Flags,FDF_STDIO) || FLAG_IS_SET(fd->fd_Flags,FDF_IS_SOCKET))
{
__set_errno(EBADF);
goto out;
}
fh = BADDR(fd->fd_DefaultFile);
ret = __pathconf(fh->fh_Type,name); /* Ok if fh->fh_Type==NULL */