Mail Archives: djgpp-workers/2001/10/14/04:53:50
Hello.
In lseek and llseek we check that the file descriptor is not a pipe, since
you can't seek on pipes. But the check occurs after the DOS interrupt to
do the seek. I think the check should be moved before the interrupt, but
after the __FSEXT_lseek operation, to let FSEXT hooks do their thing.
Below is a patch to do this.
OK to commit?
Thanks, bye, Rich =]
--
Richard Dawe
http://www.phekda.freeserve.co.uk/richdawe/
Index: src/libc/posix/unistd/lseek.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/lseek.c,v
retrieving revision 1.4
diff -p -c -3 -r1.4 lseek.c
*** src/libc/posix/unistd/lseek.c 2001/03/25 18:17:10 1.4
--- src/libc/posix/unistd/lseek.c 2001/10/14 08:49:29
*************** lseek(int handle, off_t offset, int when
*** 24,29 ****
--- 24,38 ----
return rv;
}
+ has_props = __has_fd_properties(handle);
+
+ /* POSIX doesn't allow seek on a pipe. */
+ if (has_props && (__fd_properties[handle]->flags & FILE_DESC_PIPE))
+ {
+ errno = ESPIPE;
+ return -1;
+ }
+
r.h.ah = 0x42;
r.h.al = whence;
r.x.bx = handle;
*************** lseek(int handle, off_t offset, int when
*** 34,49 ****
{
errno = __doserr_to_errno(r.x.ax);
return -1;
! }
!
! has_props = __has_fd_properties(handle);
!
! /* POSIX doesn't allow seek on a pipe. */
! if (has_props && (__fd_properties[handle]->flags & FILE_DESC_PIPE))
! {
! errno = ESPIPE;
! return -1;
! }
if (!has_props ||
(__fd_properties[handle]->flags & FILE_DESC_DONT_FILL_EOF_GAP) ==
0)
--- 43,49 ----
{
errno = __doserr_to_errno(r.x.ax);
return -1;
! }
if (!has_props ||
(__fd_properties[handle]->flags & FILE_DESC_DONT_FILL_EOF_GAP) ==
0)
Index: src/libc/compat/unistd/llseek.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/llseek.c,v
retrieving revision 1.4
diff -p -c -3 -r1.4 llseek.c
*** src/libc/compat/unistd/llseek.c 2001/03/25 18:18:08 1.4
--- src/libc/compat/unistd/llseek.c 2001/10/14 08:49:29
*************** llseek( int handle, offset_t offset, int
*** 33,38 ****
--- 33,47 ----
}
}
+ has_props = __has_fd_properties(handle);
+
+ /* POSIX doesn't allow seek on a pipe. */
+ if (has_props && (__fd_properties[handle]->flags & FILE_DESC_PIPE))
+ {
+ errno = ESPIPE;
+ return -1;
+ }
+
r.h.ah = 0x42;
r.h.al = whence;
r.x.bx = handle;
*************** llseek( int handle, offset_t offset, int
*** 42,56 ****
if( r.x.flags & 1 )
{
errno = __doserr_to_errno(r.x.ax);
- return -1;
- }
-
- has_props = __has_fd_properties(handle);
-
- /* POSIX doesn't allow seek on a pipe. */
- if (has_props && (__fd_properties[handle]->flags & FILE_DESC_PIPE))
- {
- errno = ESPIPE;
return -1;
}
--- 51,56 ----
- Raw text -