*BSD News Article 13874


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!aardvark.ucs.uoknor.edu!ns1.nodak.edu!plains.NoDak.edu!tinguely
Newsgroups: comp.os.386bsd.development
Subject: File Truncation Philosophy
Message-ID: <C4tJ6C.C17@ns1.nodak.edu>
From: tinguely@plains.NoDak.edu (Mark Tinguely)
Date: Thu, 1 Apr 1993 18:54:12 GMT
Sender: usenet@ns1.nodak.edu (Usenet login)
Organization: North Dakota State University
Nntp-Posting-Host: plains.nodak.edu
Lines: 32

		******** Request for Comments ********

 As most of you know that with 386bsd installing a new copy of a running
 program causes the running program to crash and core. This happens due to
 couple of things. Fist, with the Mach VM used in 386bsd, executing
 instructions are paged directly from the executable in the filesystem
 (whereas old BSD VMs copy the executable to swap and page from there).
 Secondly, programs like "cp" TRUNCATES the existing file when copying in
 the new copy of the program. When the executing program does the next page
 fault the fault will fail and the program will crash/core.

 The easy fix is to move or remove the file before installing the new
 program. The filesystem does work correctly and keep a copy of the executable
 and the VM still finds and uses this copy.

 It would be NICE to not have to worry about unlinking the file associated
 with running programs before making our copies. Nate and all the others
 working the patchkit are interested in this, also very important if the user
 is restoring from a backup (as I learned once).

 The philosophy question is should we change "cp" and "cat" to unlink (remove)
 the file before opening? Or even lower in the filesystem (as would need be in
 the restore example).

 I can think of several reasons to not do this:
	1) won't have the same inode.
	2) won't cover all cases -- using open(2) and O_TRUNC will still 
	   cause the same problem.
 
 If you have other ideas or opinions, flame away.

--mark.