. and ..
Was this introduced first with PDP-11 unix or did the convention
start on the PDP-7 already? It certainly seems to be the case with .
but how about ..? the dd directory seems to take on the role of a sort
of root directory and the now discovered program pd actually creates a
file .. (haven't tried to understand what it does though yet)
What does dd stand for, dotdot? directory directory?
. and .. are quite intuitive the more I think about it, they're essentially
acting as symbolic representations of the 'current' and 'parent' dirs
as
in, when we look at it from / :
/
|--|--|--|--|--|--|--|--|
/etc /bin /root /home /mnt /dev /usr
|--|--|--|--|--|--|--|--|
../ ../ ../ ../ ../ ../ ../ ../
As we see, each of the subdirectories hold a / prefix to them as we're used
to seeing, and this translated to the subfolders having their ../
descriptor denoting their parent (I think of them as recursive pointers to
parent dirs), where the parent holds ../ and child dir has a name like /..
and invoking
I don't know if it wasn't until the mkdir() syscall was added this approach
took form. There was an earlier 'Aha, Unix!' thread where Ken had mentioned
a similar thing, where invoking pwd gave only the /usr/name directory even
if the directory had been changed with chdir, essentially stemming out of
only the forked child changing dirs, when the cd wasn't built into the
shell (this was in the PDP-11 when he was writing the initial set utilities
like cd, ls)
Also, depending on the implementation of 'ls' we were to try this out
today, these are bound to have their differences. The original syscalls on
the PDP-7 had chdir,
swp: " system call dispatch table
jmp . " base instruction
.save; .getuid; .open; .read; .write; .creat; .seek; .tell
.close; .link; .unlink; .setuid; .rename; .exit; .time; .intrp
.chdir; .chmod; .chown; badcal; .sysloc; badcal; .capt; .rele
.status; badcal; .smes; .rmes; .fork
mkdir was probably in the works at this stage.
We should also touch upon the "cd -" as this one takes you back like a back
button into the directory you were last inside, whereas the cd ../.. takes
you up or down the hierarchy depending on the placement of the / and adding
placeholders i.e directory names in place of the .. (dots).
Of course, only the creators can embark upon the design details of the
hierarchical system and the reasons behind all the above and more.
Since you mentioned the word dd, the utility which serves me like none
other for my frequent rewrites of images, it too has an interesting past,
it seems like 'dd' was non-unixy in it's design approach, if I'm to
believe
the lores around, which leads me to think that this might have been another
one of the many idiosyncratic naming conventions used back then. More on
the dd stuff:
http://www.catb.org/jargon/html/D/dd.html
Personally, I just like to think of it in my head as disk-disk.
--
Abhinav Rajagopalan