PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs323] Directory Links
Date: Thursday, 03 Sep 2020, 08:34:07


    > Message Posted By: Unknown
    >
    > In a previous answer you said that there can exist a hard link to a
    > subdirectory. Correct me if I am wrong, but I thought in class that you
    > said you could not hard link directories as it would cause infinite loops
    > while traversing.

SHORT ANSWER:

Only the OS can create a hard link to a directory, and
it only does so when creating directories.


LONG ANSWER:

A hard link is a pair (local_name,inode#) that appears
in a directory file and is used to give a name to the
file represented by the inode#.

When the OS creates a subdirectory CHI in a parent
directory PAR (as a result of a mkdir(PAR/CHI) system
call), it creates two hard links to CHI, one in PAR
using the name CHI, the other in CHI using the name .
(= the name that refers to the directory itself).

It also creates a hard link to PAR in CHI using the
name .. (= the name that refers to the parent).

The OS will not create any other hard links to
directories.

--Stan-
PREV INDEX NEXT