*BSD News Article 14535


Return to BSD News archive

Newsgroups: comp.os.386bsd.development
Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!uwm.edu!zaphod.mps.ohio-state.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: <1993Apr16.044053.10665@fcom.cc.utah.edu>
Sender: news@fcom.cc.utah.edu
Organization: Weber State University  (Ogden, UT)
References: <1993Apr11.035322.19610@fcom.cc.utah.edu> <C5FJx6.o5w@ns1.nodak.edu> <C5G44z.8A5@sugar.neosoft.com>
Date: Fri, 16 Apr 93 04:40:53 GMT
Lines: 46

In article <C5G44z.8A5@sugar.neosoft.com> peter@NeoSoft.com (Peter da Silva) writes:
>In article <C5FJx6.o5w@ns1.nodak.edu> tinguely@plains.NoDak.edu (Mark Tinguely) writes:
>> the dumb approach.
>> 	Once the file starts executing, fail writes to the file.
>
>Better: if the file is open for writing, fail the exec. The file is probably
>in an inconsistent state anyway, and it doesn't make sense to trust it.

Do this *as well*, _not_ *instead*!

Basically the "itrunc" issues boil down to two main situations:

1)	Execute a file that is open for write.

	o	Process 1 opens the file for write
	o	Process 2 execs the file
	o	Process 1 writes the file (corrupting the "swap image")

2)	Open a file (which is executing) for write.

	o	Process 1 execs the file
	o	Process 2 opens the file for write
	o	Process 2 writes the file (corrupting the "swap image")


Both of these are failure modes in the current implementation.  Traditional
handling is to return an EBUSY in case 1 and an ETXTBSY in case 2.  An
EBUSY is acceptable, but ETXTBSY is not (if Posix compliance is desired).
This doesn't mean the failure mode isn't trapped!  It just means that it's
a more complicated issue to deal with.  Dealing with a failure by copying
the swap store to the swap and reissuing the open will deal with #2 without
requiring the ETXTBSY becoming visable in user space (where it would cause
Posix non-compliance).


					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
-------------------------------------------------------------------------------