Mail Archives: djgpp-workers/1996/06/27/04:40:54
I think there is a subtle bug in open()/_open():
The higher bits of omode are masked out before a possibly existing
file system extensions gets a chance to read them. Here are my
diff -c files that correct this. The O_TEXT/O_BINARY stuff is OK,
may one might add in the docs that a FSE does not have to bother with
that. I just found out by gross lazyness.
*** dos/io/_open.old Sun Nov 26 04:47:48 1995
--- dos/io/_open.c Thu Jun 27 14:58:16 1996
***************
*** 27,38 ****
_put_path(filename);
if(_USE_LFN) {
r.x.ax = 0x716c;
! r.x.bx = oflag;
r.x.dx = 1; /* Open existing file */
r.x.si = __tb_offset;
} else {
r.h.ah = 0x3d;
! r.h.al = oflag;
r.x.dx = __tb_offset;
}
r.x.cx = 0;
--- 27,40 ----
_put_path(filename);
if(_USE_LFN) {
r.x.ax = 0x716c;
! r.x.bx = oflag & 0xff; /* :TOM: new open() doesn't mask out upper bits,
! ** so we have to do it here.
! */
r.x.dx = 1; /* Open existing file */
r.x.si = __tb_offset;
} else {
r.h.ah = 0x3d;
! r.h.al = oflag & 0xff; /* :TOM: see above */
r.x.dx = __tb_offset;
}
r.x.cx = 0;
*** posix/fcntl/open.old Mon Aug 28 01:56:46 1995
--- posix/fcntl/open.c Thu Jun 27 15:02:40 1996
***************
*** 33,43 ****
bintext = O_BINARY;
/* DOS doesn't want to see these bits */
oflag &= ~(O_TEXT | O_BINARY);
dmode = (*((&oflag)+1) & S_IWUSR) ? 0 : 1;
! fd = _open(filename, oflag & 0xff); /* only low byte used */
if (fd == -1 && oflag & O_CREAT)
fd = _creat(filename, dmode);
--- 33,44 ----
bintext = O_BINARY;
/* DOS doesn't want to see these bits */
+ /* :TOM: and an FSE does not want to see them, too, so this is OK */
oflag &= ~(O_TEXT | O_BINARY);
dmode = (*((&oflag)+1) & S_IWUSR) ? 0 : 1;
! fd = _open(filename,oflag); /* :TOM: Pass through all of oflag */
if (fd == -1 && oflag & O_CREAT)
fd = _creat(filename, dmode);
Ciao
Tom
******************************************************************
* Thomas Demmer * Phone : +49 234 700 6434 *
* Universitaetsstr. 150 * or you try *
* Lehrstuhl fuer Stroemungsmechanik * +49 234 700 2896 *
* D-44780 Bochum * and MIGHT get someone who *
* * knows where I am *
* Demmer AT LStM DOT Ruhr-Uni-Bochum DOT De * Fax : +49 234 709-4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
******************************************************************
Standards are great. They give non-conformists something
not to conform to.
- Raw text -