Path: utzoo!attcan!uunet!know!sdd.hp.com!ucsd!mvb.saic.com!ncr-sd!ncrlnk!ncr-mpd!Chuck.Phillips From: Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips) Newsgroups: comp.unix.internals Subject: Re: replacement getwd(3). Message-ID: Date: 11 Nov 90 11:05:19 GMT References: <1431@carol.fwi.uva.nl> Sender: news@ncr-mpd.FtCollins.NCR.COM Followup-To: comp.unix.internals Organization: NCR Microelectronics, Ft. Collins, CO Lines: 53 In-reply-to: casper@fwi.uva.nl's message of 7 Nov 90 09:57:49 GMT >>>>> On 7 Nov 90 09:57:49 GMT, casper@fwi.uva.nl (Casper H.S. Dik) said: Casper> I've written a replacement getwd(3) for SunOS 4.x that returns Casper> ~user/tail (with ~user expanded as in /etc/passwd) if the current Casper> directory is a subdirectory of a user's home directory. Casper> [The original might return: /tmp_mnt/foo/bar/bletch/usrs/casper/dir Casper> the new returns /usr/casper/dir] Casper> I've installed it in my own copy of the shared library and thinks seem Casper> to work fine. Casper> My question is: what utilities (if any) will break because of this? Interesting idea, but I'd be more than a little concerned about programs that *assume* the path returned by getwd() is a valid path. (That very problem has caused some pain around here.) By using your getwd() and putting a bogus directory in /etc/passwd, you could seriously confuse a program. However, always stripping off the initial "/tmp_mnt" from a getwd() path is a _good thing_ when running the automounter. IMHO, Sun's version of getwd() should do this by default. Problem: 1. User cd's into automounted directory. Directory is either mounted at that time or already mounted. 2. The mount times out and file system is unmounted. 3. User attempts to access file system again using a "/tmp_mnt/..." path. 4. It FAILS! The automounter only pays attention to paths that _don't_ begin with "/tmp_mnt", and the file system doesn't get remounted. We had one application that would work correctly, as long as you never paused for ten minutes or longer when using it. If you _did_ pause that long or longer, the screen would go black and you'd have to reboot the machine to recover. _That_ was a fun problem to figure out! :-) I suspect there is a good reason for the /tmp_mnt parallel directory hierarchy, like avoiding unnecessary stat()s of (or directory open()s in) NFS file systems. BTW, Laura Pearlman wrote a fast getwd() replacement that takes extra pains to avoid unnecessary stat()s of remote directories (avoiding unnecessary NFS overhead), although it requires an addition to the kernal. She sent the code to sun-spots and xanth last January. Since we weren't, and still aren't on the net :-(, I can't tell you what happened from there. Cheers, -- Chuck Phillips MS440 NCR Microelectronics chuck.phillips%ftcollins.ncr.com 2001 Danfield Ct. Ft. Collins, CO. 80525 ...uunet!ncrlnk!ncr-mpd!bach!chuckp