Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!unido!tub!tubopal!opal.cs.tu-berlin.de!a0528 From: a0528@gray3.zrz.tu-berlin.de (Ueb28) Newsgroups: comp.unix.questions Subject: Re: /bin/pwd Message-ID: Date: 19 Sep 90 16:15:34 GMT References: <2488@idunno.Princeton.EDU> <6960@ozdaltx.UUCP> Sender: news@tubopal.UUCP Reply-To: nickel@w104zrz.zrz.tu-berlin.de Organization: Technical University of Berlin Lines: 38 In-reply-to: toma@ozdaltx.UUCP's message of 18 Sep 90 02:30:33 GMT In article <6960@ozdaltx.UUCP> toma@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@w104zrz.zrz.tu-berlin.de nickelsen@mikroperipherik.e-technik.tu-berlin.dbp.de