Joe Krahn:
> When you do fstat() on a symlink, st_size is supposed to return the 
> length of the stored symlink-target string, rather than the file data 
> size. So, if you want to read the symlink string to store it in the 

No, that is wrong.
fstat(2) for symlink doesn't return the length of the stored
symlink-target string.
Will you try this simple C program under an empty dir on ext2?
It will show you the size of /etc/hosts (after some error messagees).

#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
        int err, fd;
        char *f, *s;
        struct stat st;

        s = "symlink";
        f = "no_such_file";
        err = access(f, F_OK);
        perror(f);
        assert(err);
        err = symlink(f, s);
        assert(!err);
        fd = open(s, O_RDONLY);
        perror(s);
        assert(fd < 0);
        unlink(s);

        f = "/etc/hosts";
        err = access(f, F_OK);
        assert(!err);
        err = symlink(f, s);
        assert(!err);
        fd = open(s, O_RDONLY);
        assert(fd >= 0);
        err = fstat(fd, &st);
        assert(!err);
        printf("%s size %lu\n", s, st.st_size);

        return 0;
}


J. R. Okajima


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com

Reply via email to