inode number -> pathname? (4.2BSD)
William LeFebvre
phil at RICE.ARPA
Fri Jul 12 04:27:54 AEST 1985
> Ahh! Now you changed the rules! (and only want directories). You could
> backtrack thru .. which is what pwd does but it still is a bit irksome,
I did not change the rules! The original article stated: "I am
looking for a good way to generate the full path name of a directory..."
Looks to me like he said "path name of a directory". As I said in my
previous message, this problem is much, much harder to solve for any
arbitrary file.
> By the way, UNIX does not limit a directory to have a unique pathname,
> but rmdir, mvdir, ln, and mkdir try to make it look like it does. If
> you are superuser and write your own little C program you can make
> extra links to a directory.
It is true that the Unix *kernel* does not limit directories to a
single pathname. Neither does the kernel require the two filenames "."
and ".." to be the first two names in a directory. Nor does it require
that file descriptors 0, 1, and 2 be used for standard input, output,
and error, respectively. Yet all three of these characteristics are
considered to be part of the overall Unix system. They are conventions
that should be adhered to. Are you claiming that "rmdir, mvdir, ln,
and mkdir" are not part of Unix?
Clarification: the "mkdir" system call does make "." and ".." in the
directory it creates. But "mknod" with the right bits doesn't. And
under 4.1, "mv" was setuid to root so that directories could be moved.
The only way to move them was by linking and unlinking them, and only
root can do that. There was no "rename" call in 4.1. BUT the kernel
doesn not require that a directory always have "." and "..". Root can
easily unlink them!
Yes you can have five different names all pointing to the same
directory inode, but ".." can only point back to one of them. And if
you really are crazed enough to do this, you had better make sure your
Unix system never crashes again, because "fsck" will get gastric
distress trying to digest the spaghetti file system it will find. Urp!
Such a file system is just really disagreeable to many parts of Unix,
even though the kernel lets you get away with it.
See? I know my Unix.
William LeFebvre
Department of Computer Science
Rice University
<phil at Rice.arpa>
or, for the daring: <phil at Rice.edu>
More information about the Comp.unix.wizards
mailing list