Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Prediction is very difficult, especially of the future. -- Niels Bohr


devel / comp.lang.tcl / Is there a blind spot in file attributes?

SubjectAuthor
* Is there a blind spot in file attributes?Luc
`- Is there a blind spot in file attributes?Rich

1
Is there a blind spot in file attributes?

<20231218215308.655e252b@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12992&group=comp.lang.tcl#12992

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Is there a blind spot in file attributes?
Date: Mon, 18 Dec 2023 21:53:08 -0300
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <20231218215308.655e252b@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="d75c75ee777823ce9de807864949de08";
logging-data="3934673"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zmnSjIZTNB4Fyv+cs5fvRIEzCIBAHBBQ="
Cancel-Lock: sha1:N4v+WjMeoCzbsOfB241RkU5xtQE=
 by: Luc - Tue, 19 Dec 2023 00:53 UTC

I just found out something interesting about file attributes and broken
symlinks. The file command can't read them at all.

file attributes symlinkfile -owner

It's interesting because it tries to go straight to the linked file even
though I never told it to with readlink. It doesn't seem to care about
the symlink file.

That makes sense and I even find it convenient when trying to determine
whether it's a directory, for example. It doesn't care about the link,
it just looks at the target and saves me an extra step.

But the user may want to delete the link because it's no longer valid,
it's a broken link, in which case it may be good to see who the owner
is.

When checking for mtime, the file command also gets the date and time
of the target, not the link. I happen to like that behavior better,
but I can't figure out how to obtain the information on the symlink file
specifically in case I need it. When was that symlink created (which is
very likely the same date and time as mtime)? It seems I can't extract
that information with Tcl.

The other file manager I have here (SpaceFM) treats a symlink like a
regular file, except that it displays the target file in the status bar.
For everything else, the target is ignored. Like I said, I often find
the Tcl way better, but what if I want or need the other way?

Is there a way?

--
Luc
>>

Re: Is there a blind spot in file attributes?

<ulqrol$3odlf$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12993&group=comp.lang.tcl#12993

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Is there a blind spot in file attributes?
Date: Tue, 19 Dec 2023 01:31:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <ulqrol$3odlf$1@dont-email.me>
References: <20231218215308.655e252b@lud1.home>
Injection-Date: Tue, 19 Dec 2023 01:31:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d8ac2ae90418f23629f9379636c6a89e";
logging-data="3946159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/6rF1miVdVYHGmOArMNXG2"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:McXm+8LfTJEQDSitWqczIDRei2c=
 by: Rich - Tue, 19 Dec 2023 01:31 UTC

Luc <luc@sep.invalid> wrote:
> I just found out something interesting about file attributes and broken
> symlinks. The file command can't read them at all.
>
> file attributes symlinkfile -owner
>
> It's interesting because it tries to go straight to the linked file even
> though I never told it to with readlink. It doesn't seem to care about
> the symlink file.

You are not seeing the full picture. It is libc/the kernel that does
not care. Unless you use the correct libc calls, accessing a symlink
always accesses the file to which the symlink points.

> That makes sense and I even find it convenient when trying to determine
> whether it's a directory, for example. It doesn't care about the link,
> it just looks at the target and saves me an extra step.

If you do want ifo about the link itself, you need to use lstat to get
the symlink info.

> But the user may want to delete the link because it's no longer valid,
> it's a broken link, in which case it may be good to see who the owner
> is.

That is what the lstat subcommand to file is meant for, to get the info
on the "link" rather than the file to which it points.

> When checking for mtime, the file command also gets the date and time
> of the target, not the link. I happen to like that behavior better,
> but I can't figure out how to obtain the information on the symlink file
> specifically in case I need it.

lstat -- it is right there in the docs.

> When was that symlink created (which is very likely the same date and
> time as mtime)? It seems I can't extract that information with Tcl.

No, you can, you just have to ask the right way, with lstat.

> Is there a way?

Yes, see above.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor