Re: [dev] [sbase] [PATCH v3] ls: Handle symlinks to directories properly

From: Michael Forney <mforney_AT_mforney.org>
Date: Mon, 8 Dec 2014 20:27:07 -0800

On Mon, Dec 08, 2014 at 04:21:30PM -0800, Eric Pruitt wrote:
> Unless I'm missing something, I still don't see anything in that patch
> pertaining to the interpretation of slashes.

I'm not sure what you're expecting...

When you lstat "foo/", where foo is a symlink to a directory, you look
up information about the directory, not the symlink. "ls" does not do
anything differently. You can also see that POSIX does not specify
anything related to interpretation of slashes in the specification of
the "ls" (because it do not need any sort of special interpretation).

See, this example (pruned for the system calls that matter)

$ strace ls -l foo
lstat("foo", {st_mode=S_IFLNK|0777, st_size=3, ...}) = 0
stat("foo", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
lrwxrwxrwx 1 michael michael 3 Dec 09 20:22 foo -> bar
$ strace ls -l foo/
lstat("foo/", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
-rw------- 1 michael michael 0 Dec 09 20:23 hello
-rw------- 1 michael michael 0 Dec 09 20:23 world
$
Received on Tue Dec 09 2014 - 05:27:07 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 09 2014 - 05:36:08 CET