/bin/pwd

Ueb28 a0528 at gray3.zrz.tu-berlin.de
Thu Sep 20 02:15:34 AEST 1990


In article <6960 at ozdaltx.UUCP> toma at ozdaltx.UUCP (Tom Armistead) writes:

   I don't know how /bin/pwd works - but I ran into the same problem and this
   is how I tackled it...

   Open "." using stat(2), get the inode number and save it.
   Open ".." using stat, get the inode number, if equal to the inode for "." then
	   you are at the root dir "/".
   If they are not equal:
       open ".." using opendir(3C) and read the entries from it using readdir(3C)
[etc.]

It has to be something like that, if not exactly. On a System here
around there is a partition with a scrambled root directory. When you
do a ls -al /expo1, you get:

total 24
drwxrwxrwx  18 root     root         368 Sep  5 20:21 
drwxr-xr-x   5 root     other         80 Jun 23 01:26 386ix
drwx------   3 a0203    101           64 May  2 22:12 a0203
drwxr-xr-x   3 a0238    other         64 Aug 27 10:57 a0238
[etc.]

The first entry is really blank, and there are NO "." and ".." entries.
System works fine, except for users or programs who want to do a pwd
on this partition. pwd answers:

	pwd: cannot open ..

I suggested to patch the first two entries to inode number 2 and the
names "." and "..", but a new Unix release will soon be installed, and
in this turn the partition will be backuped and mkfs'ed.

--
-----------------
Juergen Nickelsen
nickel at w104zrz.zrz.tu-berlin.de
nickelsen at mikroperipherik.e-technik.tu-berlin.dbp.de



More information about the Comp.unix.questions mailing list