Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!wje From: wje@redwood.mips.com (William J. Earl) Newsgroups: comp.sys.mips Subject: Re: Why does RISC/os mount care about current directory? Message-ID: <5119@spim.mips.COM> Date: 26 Jun 91 19:53:11 GMT References: Sender: news@mips.COM Reply-To: wje@redwood.mips.com (William J. Earl) Distribution: comp Organization: MIPS Computer Systems Inc. Lines: 46 Nntp-Posting-Host: redwood.mips.com In-reply-to: kmk@cc.tut.fi (Kai 'Kaizzu' Kein{nen) Originator: wje@redwood.mips.com In article , kmk@cc (Kai 'Kaizzu' Kein{nen) writes: > > We ran in a funny situation here today when we tried to issue a > mount-command from a directory which no longer exists: > > (lehtori is a RC6280 running RISC/os 4.51, thomas is VAX 11/780 running > Ultrix 4.1.) > > lehtori:/mnt/hide 343 # pwd > ..: No such file or directory > lehtori:/mnt/hide 344 # mkdir /mnt/disk > lehtori:/mnt/hide 345 # mount thomas:/mnt/ra3c /mnt/disk > mount: No such file or directory > lehtori:/mnt/hide 346 # cd /mnt > lehtori:/mnt 347 # mount thomas:/mnt/ra3c /mnt/disk > lehtori:/mnt 348 # mkdir hide > lehtori:/mnt 349 # cd hide > lehtori:/mnt/hide 350 # ( cd / ; rmdir /mnt/hide ) > lehtori:/mnt/hide 351 # mkdir /mnt/real > lehtori:/mnt/hide 352 # ln -s /mnt/real /mnt/link > lehtori:/mnt/hide 353 # mount thomas:/mnt/ra3c /mnt/link > mount: /mnt/: No such file or directory > lehtori:/mnt/hide 354 # mount thomas:/mnt/ra3c /mnt/real > mount: No such file or directory > lehtori:/mnt/hide 355 # > > This works fine at least on SunOS 4.1.1 and Ultrix 4.1. So the > academic question is: What does mount do with current directory? Why > does it give a funny error message when trying to do a mount via a > symbolic link when sitting in a directory which does not exist? mount attempts to remove all symbolic links and references to "." and ".." in the path to the mount point, to avoid ambiguity in /etc/mtab. In doing so, it uses realpath(3-bsd), which in turn tries to do getwd(), which in turn tries to open "..", which fails. realpath() could be a bit smarter, and skip the getwd() if there are in fact no "." or ".." items in the path. This is, however, not a particularly interesting failure mode, since the workaround (cd to some directory which is accessible) is simple. -- William J. Earl wje@mips.com MIPS Computer Systems 408-524-8172 930 Arques Avenue, M/S 1-03 FAX 408-524-8401 Sunnyvale, CA 94088-3650