On Tue, 17 Sep 2024 09:43:27 +0200, tomas.rippl@tutanota.com wrote:
> Hello, I am studying OpenBSD and I am currently working on file mods and the
> chmod(1) command. In that context, I have come across a behavior that I don't
> understand. My test directory contains two files: ll.out and power.exe.
>
> $ chmod 600 my-test-dir
> $ ls -ld my-test-dir/
> drw------- 2 user user 512 Sep 17 11:13 my-test-dir/
> $ ls my-test-dir
> ll.out power.exe
> $ ls -l my-test-dir
> total 0
> $
>
> I would expect that without the 'x' bit, the directory is not searchable and
> I won't be able to list its contents. But in fact I can, unless I use a long
> format (-l, -g or -n).
While the directory is not searchable, it is still _readable_. When
ls(1) calls getdents(2), it is able to read the directory's contents.
However, when you run "ls -l", it is unable to stat(2) the individual
files in the directory (to get the size, owner, mode, etc) and so
does not display them.
You can use ktrace(1) and kdump(1) to see the system calls used by
ls (or other programs) and compare what happens for "ls" vs. "ls -l".
- todd
No comments:
Post a Comment