Mail Archives: djgpp-workers/2001/03/01/12:18:01
> In that case, you will need to reset all the bits in oflag except the
> lowest byte and the O_TEMPORARY bit, because DOS gives a different
> meaning to the other bits, and _creatnew plugs its last argument more
> or less directly into the BX register.
__set_fd_properties can handle being called multiple times, so I suggest
treating it much like __file_handle_set:
Index: djgpp/src/libc/posix/fcntl/open.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/fcntl/open.c,v
retrieving revision 1.7
diff -c -p -r1.7 open.c
*** open.c 2000/08/28 14:22:33 1.7
--- open.c 2001/03/01 16:41:50
***************
*** 1,3 ****
--- 1,4 ----
+ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
***************
*** 18,23 ****
--- 19,25 ----
#include <io.h>
#include <libc/dosio.h>
+ #include <libc/fdprops.h>
/* Extra share flags that can be indicated by the user */
int __djgpp_share_flags;
*************** open(const char* filename, int oflag, ..
*** 107,113 ****
--- 109,118 ----
}
if (should_create)
+ {
fd = _creatnew(real_name, dmode, oflag & 0xff);
+ __set_fd_properties(fd, real_name, oflag);
+ }
else
{
fd = _open(real_name, oflag);
*************** open(const char* filename, int oflag, ..
*** 132,138 ****
/* Don't call _creat on existing files for which _open fails,
since the file could be truncated as a result. */
else if ((oflag & O_CREAT))
! fd = _creat(real_name, dmode);
}
}
--- 137,147 ----
/* Don't call _creat on existing files for which _open fails,
since the file could be truncated as a result. */
else if ((oflag & O_CREAT))
! {
! fd = _creat(real_name, dmode);
! if (fd != -1)
! __set_fd_properties(fd, real_name, oflag);
! }
}
}
Index: djgpp/src/libc/dos/io/_creat_n.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_creat_n.c,v
retrieving revision 1.3
diff -c -p -r1.3 _creat_n.c
*** _creat_n.c 2001/01/30 19:53:25 1.3
--- _creat_n.c 2001/03/01 16:42:09
***************
*** 9,14 ****
--- 9,15 ----
#include <dos.h>
#include <libc/dosio.h>
#include <sys/fsext.h>
+ #include <libc/fdprops.h>
int
_creatnew(const char* filename, int attrib, int flags)
*************** _creatnew(const char* filename, int attr
*** 68,72 ****
--- 69,74 ----
return -1;
}
__file_handle_set(r.x.ax, O_BINARY);
+ __set_fd_properties(r.x.ax, filename, O_BINARY);
return r.x.ax;
}
- Raw text -