Mail Archives: djgpp-workers/2003/01/13/13:10:03
Hello.
Richard Dawe wrote:
[snip]
> So if I stat 'a' above, I would expect it to resolve the symlink to 'a' and
> then return information about the symlink 'a', e.g.: the st_mode field would
> have the S_IFLNK bit set.
>
> Hmmm, it doesn't work that on Linux. Test program:
>
> ---Start teststat.c---
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/stat.h>
> #include <unistd.h>
>
> int
> main (int argc, char *argv[])
> {
> struct stat sbuf;
> int ret, i;
>
> for (i = 1; i < argc; i++) {
> ret = stat(argv[i], &sbuf);
> if (ret < 0)
> perror(argv[0]);
> }
>
> return(EXIT_SUCCESS);
> }
> ---End teststat.c---
>
> iolanthe:~ =] ln -nsf a a
> iolanthe:~ =] ls -l a
> lrwxrwxrwx 1 rich rich 1 Dec 19 22:05 a -> a
> iolanthe:~ =] ./src/tmp/teststat a
> ./src/tmp/teststat: Too many levels of symbolic links
>
> I guess I read the standard wrong. Sorry.
>
> The left 'a' in 'a -> a' above is bright blue, to indicate that the link is
> satisfied. An equivalent test with DJGPP shows the left 'a' in black on a
> red background, indicating that the link is broken. I wonder why that is.
Well, it turns out that my Linux set-up (RedHat Linux 6.2) has the same
colour-coding for satisfied and unsatisfied symlinks. I think it's a
relatively recent addition to have different colours for the two cases.
Bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -