The system call on UN*X oid systems lstat(2) is like stat(2), except when asked about a symbolic link. Whereas stat() returns data about the referenced file, lstat() returns data about the link.

In particular, if the link doesn't point to an existing file, stat() will fail, but lstat() will still return data.

To get the target of the symlink, use readlink(2).