Mail Archives: djgpp-workers/2000/09/17/13:33:53
I'm in the process of adding proper O_APPEND functionality.
One thing I'm doing is expanding the __file_handle_modes variable to
an array of unsigned shorts so it'll be able to hold the O_APPEND flag
too.
Then I'm trying to make sure the O_APPEND doesn't disappear by the
plentiful masking operations. E. g. this code in
src/libc/dos/io/setmode.c:
newmode = (oldmode & ~(O_BINARY|O_TEXT)) | (mode & (O_BINARY|O_TEXT));
becomes:
newmode = (oldmode & ~(O_BINARY|O_TEXT|O_APPEND)) | (mode & (O_BINARY|O_TEXT|O_APPEND));
Now, in src/libc/posix/unistd/dup2.c there is this code:
int
dup2(int fd, int newfd)
{
__dpmi_regs r;
if (fd == newfd)
return newfd;
__file_handle_set(newfd, __file_handle_modes[fd] ^ (O_BINARY|O_TEXT));
r.h.ah = 0x46;
r.x.bx = fd;
r.x.cx = newfd;
__dpmi_int(0x21, &r);
if (r.x.flags & 1)
{
errno = __doserr_to_errno(r.x.ax);
return -1;
}
setmode(newfd, __file_handle_modes[fd]);
return newfd;
}
I don't understand this so I don't know if O_APPEND should go beside
O_BINARY and O_TEXT or not.
Can anyone enlighten me?
Right,
MartinS
- Raw text -