Mail Archives: djgpp-workers/2002/06/21/17:46:50
Hello.
pavenis AT lanet DOT lv wrote:
[snip]
> Anyway it seems that it's not only problem. Anyway it seems to need
> debugging as there are still problems:
>
> TMPDIR=E:/ works
>
> TMPDIR=E:\ works
>
> TMPDIR=E:/TMP/ works
>
> TMPDIR=E:/TMP\ does not work (access in try() fails and as result TMP is
> tried). Does not work both with currnt CVS version of DJGPP and
> v2.03 update. In current CVS version _chmod(file_name,0) fails
> (in src/libc/posix/unistd/access.c)
You can reproduce this using tests/libc/posix/unistd/access.c. Try something
like this from bash:
cd tests/libc/posix/unistd
make all
./access.exe c:/ c:\\ c:/temp c:\\temp c:/temp/ c:/temp\\
You should get something like this:
bash-2.04$ ./access.exe c:/ c:\\ c:/temp c:\\temp c:/temp/ c:/temp\\
access c:/: F_OK: YES R_OK: YES W_OK: YES X_OK: YES D_OK: YES
access c:\: F_OK: YES R_OK: YES W_OK: YES X_OK: YES D_OK: YES
access c:/temp: F_OK: YES R_OK: YES W_OK: YES X_OK: YES D_OK: YES
access c:\temp: F_OK: YES R_OK: YES W_OK: YES X_OK: YES D_OK: YES
access c:/temp/: F_OK: YES R_OK: YES W_OK: YES X_OK: YES D_OK: YES
access c:/temp\: F_OK: NO R_OK: NO W_OK: NO X_OK: NO D_OK: NO
I think there's actually a bug in _put_path. There's code to remove a trailing
slash, but it only does that for forward slashes. IMHO it should do this for
backward slashes too. The diff below contains a patch for this. So far I've
only tested it with a demo program, but it should be tested with more
heavy-duty stuff, given how important _put_path is.
I also noticed what I think is a bug in findfirst. It does not restrict the
attrib argument in any way. We need to restrict it to be <= 255, otherwise we
the bits 8-15 end up being required attributes in the DOS call.
The test program tests/libc/dos/ff.c exposes this bug in findfirst, because it
sets the attrib argument to -1. Nothing is found, since nothing can possibly
match the set of required attributes.
There is a patch below, which restricts the attrib argument appropriately in
findfirst.
Thanks, bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
Index: src/libc/dos/dir/findfirs.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/dir/findfirs.c,v
retrieving revision 1.2
diff -p -u -3 -r1.2 findfirs.c
--- src/libc/dos/dir/findfirs.c 31 Aug 1996 21:09:32 -0000 1.2
+++ src/libc/dos/dir/findfirs.c 21 Jun 2002 21:36:39 -0000
@@ -23,6 +23,11 @@ findfirst(const char *pathname, struct f
return -1;
}
+ /* The low 8 bits are the allowable attributes; the next 8 bits
+ are the required attributes. We have no required attributes,
+ so mask off bits 8-15. */
+ attrib &= 0xff;
+
pathlen = strlen(pathname) + 1;
_put_path(pathname);
Index: src/libc/dos/io/putpath.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/putpath.c,v
retrieving revision 1.7
diff -p -u -3 -r1.7 putpath.c
--- src/libc/dos/io/putpath.c 10 Jun 2001 11:48:23 -0000 1.7
+++ src/libc/dos/io/putpath.c 21 Jun 2002 21:36:40 -0000
@@ -163,7 +163,7 @@ _put_path2(const char *path, int offset)
/* remove trailing slash if it doesn't
represent the root directory */
if (o-2 >= __tb+offset
- && _farnspeekb(o-1) == '/'
+ && (_farnspeekb(o-1) == '/' || _farnspeekb(o-1) == '\\')
&& _farnspeekb(o-2) != ':')
o--;
- Raw text -