Mail Archives: djgpp-workers/2001/08/18/00:58:15
> > > I suggest the other way around: open first, then close the LFN
> > > handle. This way, you minimize the risk of something removing the
> > > file in between. (You might need to fsync the handle before the call
> > > to _open, though.)
At this point the file should be empty either way, so why would fsync
be needed? I think the odds of the file disappearing in the millisecond
between close and reopen to be pretty small (especially since this
insanity only is foisted upon Win2K/XP). But I'll play with it.
> > Shouldn't we worry about sharing permission on the file being
> > oopened twice?
>
> I don't know; is there some problem?
As written the patch seems to work. I created several long names and
was able to fstat() the handles and get correct information. Case
seems to be preserved.
Swapping to do an open first, then close also consumes (temporarily)
an additional file handle.
The _open also works fine with case. Opening an existing file by short
name doesn't seem to change anything.
*** _creat.bak Wed Jul 25 02:54:00 2001
--- _creat.c Fri Aug 17 23:00:12 2001
*************** _creat(const char* filename, int attrib)
*** 61,66 ****
--- 61,74 ----
errno = __doserr_to_errno(r.x.ax);
return -1;
}
+ if(use_lfn && _osmajor == 5 && _get_dos_version(1) == 0x532) {
+ /* Windows 2000 or XP; or NT with LFN TSR. Windows 2000 behaves
+ badly when using IOCTL and write-truncate calls on LFN handles.
+ We close the long name file and re-open it with _open.c (short)
+ to work around the bugs. */
+ _close(r.x.ax);
+ return _open(filename,2);
+ }
__file_handle_set(r.x.ax, O_BINARY);
return r.x.ax;
}
*** _creat_n.bak Tue Jan 30 13:53:26 2001
--- _creat_n.c Fri Aug 17 23:01:30 2001
*************** _creatnew(const char* filename, int attr
*** 67,72 ****
--- 67,80 ----
errno = __doserr_to_errno(r.x.ax);
return -1;
}
+ if(use_lfn && _osmajor == 5 && _get_dos_version(1) == 0x532) {
+ /* Windows 2000 or XP; or NT with LFN TSR. Windows 2000 behaves
+ badly when using IOCTL and write-truncate calls on LFN handles.
+ We close the long name file and re-open it with _open.c (short)
+ to work around the bugs. */
+ _close(r.x.ax);
+ return _open(filename, flags | 2);
+ }
__file_handle_set(r.x.ax, O_BINARY);
return r.x.ax;
}
- Raw text -