portable realpath

D. Hugh Redelmeier hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Tue Dec 13 17:52:40 UTC 2011


| From: James Knott <james.knott-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org>

| I thought multiple hard links didn't work with directories.  Also are . and ..
| hard links or relative locations.  You can have those in different
| directories, where they refer to different locations.

In the original UNIX filesystems, . and .. were real links.  I don't know
if that is so in current filesystems.

You are not "supposed" to create links to directories.  It certainly
could be done.  But then you've broken a rule and who knows what
programs would then break (eg. find, dump).  I think that fsck checks
for this problem.

In the original UNIX filesystem, directories were just files with a
simple table in them, but marked as directories.  The table was simply
an array of entries like this:

struct directory_entry {
	/* I don't remember the order of these fields */
	unsigned short	inode_number;
	char name[14];	/* note: NUL-padded, not NUL-terminated! */
};

Notice that there isn't enough information for a name to refer to a
different filesystem from the one containing the directory.

A hard link is just a normal directory entry.

A symlink is something quite different: a file containing a path
string.
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list