Mail Archives: djgpp-workers/2001/08/11/04:49:31
Hi,
My question is in link.s shouldn't we either use stat() or fstat() not both?
Stat calls lstat() and the lstat file
If I move the open path1 and use the fd1 and change the code to use fstat
then the function almost works. Once I use fstat() I then find that the
newely created file has the read only bit set, I am currently looking at
this issue. I may be able to produce a patch very quickly once I know the
answer to the stat() or fstat() question above.
In link.c source lines ( may have added extra braces and spaces as I am
debugging a link issue under Win 2K):
/* Fail if path1 does not exist - stat() will set errno */
if (stat(path1, &statbuf1) < 0) return -1; /* STAT
LINE !!!!! */
/* Fail if path1 and path2 are on different devices */
if (fstat(fd2, &statbuf2) < 0) return -1; /*
FSTAT LINE !!!!! */
if (statbuf1.st_dev != statbuf2.st_dev) /* COMPARE FSTAT and
STAT */
{
(void)close(fd1);
(void)close(fd2);
(void)unlink(path2);
errno = EXDEV;
return -1;
}
/* Copy path1 to path2 */
do
{
nbyte = read(fd1, buf, sizeof buf);
if (nbyte <= 0) break;
if (write(fd2, buf, nbyte) != nbyte) nbyte = -1;
}
while (nbyte > 0);
Andrew
- Raw text -