*BSD News Article 14187


Return to BSD News archive

Newsgroups: comp.os.386bsd.development
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!usc!howland.reston.ans.net!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!csn!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: Re: File Truncation Philosophy
Message-ID: <1993Apr8.004011.2750@fcom.cc.utah.edu>
Sender: news@fcom.cc.utah.edu
Organization: Weber State University  (Ogden, UT)
References: <C4tJ6C.C17@ns1.nodak.edu> <C4vqBI.CoK@ns1.nodak.edu>
Date: Thu, 8 Apr 93 00:40:11 GMT
Lines: 53

In article <C4vqBI.CoK@ns1.nodak.edu> tinguely@plains.NoDak.edu (Mark Tinguely) writes:
>> As most of you know that with 386bsd installing a new copy of a running
>> program causes the running program to crash and core. ...
>
> The best idea from the netnews is to mark the executable text file busy. It
> was also pointed out to me that this feature already exists in the Net-2 code,
> but was not enabled in 386bsd.
>
> Sure enough there is a vnode flag VTEXT that is checked in the vn_writechk()
> and if set when writing then ETXTBSY is returned.
>
> There is two logical places that this flag could be set in vm/vnode_pager.c
> when a vnode pager is allocated and kern/execve.c when executing. The flag
> is deleted when the vnode_pager is deallocated. Against my better judgment,
> I put it in kern_execve.c because I assume since it is not in the vnode pager
> allocation routine, the original authors wanted it to go into kern_execve.c.

[ ...patch to set VTEXT on exec... ]

Try the following:

1)	Install the patch.
2)	Open a binary read/write.
3)	Run the binary (on another login or whereever).
4)	Write the file.

The write not being specifically disallowed at open time, a failure is not
expected later.  This implies that if the reference count is non-zero, the
VTEXT should be checked to ensure that it is set *before* completing the
exec.  THere is also the implication (I have yet to try this, sorry) that
the file can't be deleted while running -- something that *should* be
allowed, as the blocks used as swap store won't be deleted until the last
open reference goes away.

This is less elegant than the itrunc soloution (which admittedly doesn't
handle the write case -- it also needs handling) or the copy-on-write to
swap (that fixes the normal file as swap store problem entirely).

Comments?



					Terry Lambert
					terry@icarus.weber.edu
					terry_lambert@novell.com
---
Any opinions in this posting are my own and not those of my present
or previous employers.
-- 
-------------------------------------------------------------------------------
                                        "I have an 8 user poetic license" - me
 Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
-------------------------------------------------------------------------------