Symlinks already present

Richard Damon Richard at Damon-Family.org
Tue Sep 1 08:55:55 EDT 2020


On 8/31/20 6:05 PM, Chris Angelico wrote:
> On Tue, Sep 1, 2020 at 5:08 AM Richard Damon <Richard at damon-family.org> wrote:
>> The file descriptor could remember the path used to get to it. chroot
>> shows that .. needs to be somewhat special, as it needs to go away for
>> anyone that . is their current root.
> But my point is that there might not actually *be* a valid path that
> gets you to a file descriptor. It can't remember something that
> doesn't exist. (And it's pretty impractical to do that even if it
> does.)

Remember, we are talking about a hypothetical OS that handles hardlinks
to directories, and defines that .. will point to the parent used to
come to it, NOT just having current *NIX allowing hardlinks to
directories with no remediation of the issues cause.

One result of the definition, is that when you open a file/directory, if
it might be a directory, the system WILL need to remember the path to it
(so as to provide a value for ..) and that memory will provide a
'reference' for the directories so they can't go away (just like an
unlinked file stays around will someone has it open). The normal way to
get a file descriptor starts from a path, so the path had to exist in
the first place, and since we are assuming that to get .., it keep a
reference to that path, it can't truly go away.

>
>> I see no problem with it being a hardlink, and in fact, executables know
>> the name they were executed by, so directories  knowing the path isn't
>> that different.
> Actually no, they don't. They are all taught, and being taught,
> believe, that their first argument is their name.
>
>> The key differnce between a hardlink and a symlink is
>> that hardlinks maintain existance, and always point to something that
>> exists (things know how many hardlinks refer to them). symlinks don't
>> reference the actual file object, but the symbolic path to it, which may
>> or may not actually exist, and who doesn't know such a link exists.
> Symlinks refer to a path, which may be relative. Hardlinks refer to an
> inode (or whatever other way you choose to identify an actual file's
> contents). It's entirely possible to have an open file or directory
> that no longer has any actual path referring to it; in fact, things
> don't know how many hardlinks refer to them, just how many references
> there are.
>
> ChrisA


-- 
Richard Damon



More information about the Python-list mailing list