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

From: Eric Pruitt <eric.pruitt_AT_gmail.com>
Date: Mon, 8 Dec 2014 20:37:47 -0800

On Mon, Dec 08, 2014 at 08:27:07PM -0800, Michael Forney wrote:
> When you lstat "foo/", where foo is a symlink to a directory, you look
> up information about the directory, not the symlink.
> [...]
>
> 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

I see, thanks. I didn't realize that the syscalls handled arguments with
slashes differently and thought it was handled at the application-level.

Eric

PS -- You can filter for certain syscalls by using the -e option of
strace e.g. strace -e lstat ...
Received on Tue Dec 09 2014 - 05:37:47 CET

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