Subject: Re: Vi still can't remove its own vi-recover files from NFS /var/tmp
To: NetBSD-current Discussion List <current-users@NetBSD.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-users
Date: 01/24/2004 22:06:58
[ On Sunday, January 25, 2004 at 00:49:11 (+0100), Christian Biere wrote: ]
> Subject: Re: Vi still can't remove its own vi-recover files from NFS /var/tmp
>
> Greg A. Woods wrote:
> > Note the file in question is (and was) "/etc/nsswitch.conf".
> 
> This file was probably used because /var/tmp or the file to be edited
> was on NFS-mounted partition, right?

Maybe.  :-)  The file being edited is certainly on NFS -- the system is
diskless.  I don't think that's why vi calls upon nsswitch.conf though
-- it's probably got more to do with some getpw*() call.

> > As far as I can tell from the code nsdispatch(3) is just using fopen()
> > and (since it uses lex & yacc), fread().
> 
> Well, flex(3) uses isatty() without checking for a character special
> device. So, gethostbyname() etc. will trigger a TIOCGETA for
> /etc/nsswitch.conf.

Ah, of course.  I was a bit quick to give up on looking for a separate
isatty() call in the (f)lex generated code when I found the fread() call
since they would both occur at the same position in the ktrace output.

Adding "%option never-interactive" to the lex source fixes this "problem".

Lex should probably also be invoked with '-B' as well.

> > As for reproducing the main subject issue, yes that still happens too:
>  
> >   4446 vi       CALL  unlink(0xa61e0)
> >   4446 vi       NAMI  "/var/tmp/vi.recover/vi.04446b"
> >   4446 vi       RET   unlink 0
> >   4446 vi       CALL  unlink(0xad440)
> >   4446 vi       NAMI  "/var/tmp/vi.recover/recover.04446d"
> >   4446 vi       RET   unlink -1 errno 13 Permission denied
>  
> > as before the recover.* file can be removed after 'vi' has exited....
> 
> Well, vi uses locks for the recover files which might interfere in
> some way NFS.

Although that's a logical explanation on the surface, it doesn't quite
explain why there's no problem with unlinking the "vi.*" files (they
seem to be locked also -- at least from what I see in the ktrace).

-- 
						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>          Secrets of the Weird <woods@weird.com>