lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, May 19, 2007 at 05:11:09PM -0300, Tomas Guisasola Gorham wrote:
> 	I beg your pardon!  I misunderstand the documentations
> about the stat and lstat functions.  I am not quite sure, but
> I think the actual implementation is not so wrong.  If we change
> `stat' by `lstat' we will have symbolic link information, which is
> what duck was asking for (and I think he is quite right about that).

lstat() and stat() don't do the same thing, one returns information
about the symlink, the other returns information about what is symlinked
to. It appears somebody wants a hybrid of the two calls, but no such
thing exists.

For example, if you call lstat() on a symlink, you will always get the
permissions of a symlink as 0777 (rwxrwxrwx), because symlinks don't
have permissions.

I think lfs should expose both stat() and lstat() interfaces, they both
exist as system calls because they are both useful. lfs has simplified
the file system too far.

> 	But there is no need to change the use of the macros.
> If I am not misreading the docs, a symlink could not be view
> (by `stat' or `lstat') as a regular file nor as a directory not
> anything else.  If I am understanding correctly the docs, there
> is no problem in the order of checking the macros.

If I misunderstand you, sorry, but this appears to be not quite right.
symlink, directory, file, ..., these are completely exclusive. A symlink
is not both a symlink and a file, it is just a symlink. You will never
see S_IFLNK and S_IFDIR set in st_mode at the same time, it doesn't
matter what order you check them in. A symlink doesn't even have to
point to anything!

Cheers,
Sam