From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Viro To: 9fans@cse.psu.edu Subject: Re: [9fans] Ephase question. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Tue, 13 Aug 2002 02:22:54 -0400 Topicbox-Message-UUID: db60ce90-eaca-11e9-9e20-41e7f4b1d025 On Tue, 13 Aug 2002, Ronald G Minnich wrote: > overwrite, yeah. That EBUSY will definitely occur for overwrite in > different ways on different unices. Now I see what you meant. > > On freebsd and Linux, exec happens via an mmap (more or less). Possibly > the behavioural difference you saw between binary and normal file was due > to how the kernels handle mmap for exec vs. file I/O, not due to it being > a binary vs. normal file. Yes. Notice that both Linux and FreeBSD have few reasons even for that protection (and it's not too consistent - e.g. shared libraries are not protected). It is, indeed, result of mmap() - there is a flag (MAP_DENYWRITE) used when we map the binary and it prevents opening file for write (and having file opened from write makes such mmap() call fail). IIRC, it's a compatibility with fairly old systems and it could be killed if anyone cared enough. There's absolutely no protection against unlink()/rename() and there's nothing to protect against - both would keep file alive until the final close()/munmap(), so there's nothing to break.