Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!bu-cs!budd From: budd@bu-cs.BU.EDU (Philip Budne) Newsgroups: comp.unix.wizards Subject: Re: pwd Message-ID: <44969@bu-cs.BU.EDU> Date: 20 Dec 89 04:57:39 GMT References: <263@zircon.UUCP> Reply-To: budd@bu.edu (Phil Budne) Distribution: comp Organization: Boston University, Disinformation Technology Lines: 51 In article <263@zircon.UUCP> davidb@Pacer.UUCP (David Barts) writes: > >How does /bin/pwd work? it stats "." then opendirs ".." and stats each entry until it finds one with the same device and i number, it then does a chdir(".."); This is repeated until "/" and "." are the same. buit2% trapfile /bin/pwd 0x2100: stat("/",0xefff594) 0x227c: stat(".",0xefff594) 0x2438: open("..", 0) -> 3 0x2454: fstat(3,0xefff510) 0x2148: chdir("..") 0x2174: fstat(3,0xefff558) 0x23ea: close(3) 0x227c: stat(".",0xefff594) 0x2438: open("..", 0) -> 3 0x2454: fstat(3,0xefff510) 0x2148: chdir("..") 0x2174: fstat(3,0xefff558) 0x2222: stat(".",0xefff558) 0x2222: stat("..",0xefff558) 0x2222: stat("lost+found",0xefff558) 0x2222: stat("dev",0xefff558) 0x2222: stat("etc",0xefff558) 0x2222: stat("bin",0xefff558) 0x2222: stat("mnt",0xefff558) 0x2222: stat("private",0xefff558) 0x2222: stat("pub",0xefff558) 0x2222: stat("tmp",0xefff558) 0x2222: stat("usr",0xefff558) 0x2222: stat(".cshrc",0xefff558) 0x2222: stat(".login",0xefff558) 0x2222: stat(".profile",0xefff558) 0x2222: stat("usr8",0xefff558) 0x2222: stat("stand",0xefff558) 0x2222: stat("vmunix",0xefff558) 0x2222: stat("lib",0xefff558) 0x2222: stat("private.MC68020",0xefff558) 0x2222: stat("usr1",0xefff558) 0x2222: stat("usr2",0xefff558) 0x23ea: close(3) 0x227c: stat(".",0xefff594) 0x22cc: chdir("/usr2/budd") 0x4d3c: ioctl(1,0x40067408,0xefff76c) Inappropriate ioctl for device 0x3c1c: fstat(1,0xefff78c) 0x38d4: close(0) 0x38d4: close(1) 0x38d4: close(2) /usr2/budd