From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1G3tfV-0002kZ-Jk for garchives@archives.gentoo.org; Fri, 21 Jul 2006 11:59:46 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k6LBvgSF020494; Fri, 21 Jul 2006 11:57:42 GMT Received: from forum.psychotherapie.org (s15216962.onlinehome-server.info [217.160.22.205]) by robin.gentoo.org (8.13.7/8.13.6) with ESMTP id k6LBqMtg029634 for ; Fri, 21 Jul 2006 11:52:23 GMT Received: (from uucp@localhost) by forum.psychotherapie.org (8.13.3/8.13.3/SuSE Linux 0.7) with UUCP id k6LBqN3h027171 for gentoo-user@lists.gentoo.org; Fri, 21 Jul 2006 13:52:23 +0200 Received: (from weigelt@localhost) by metux.de (8.12.10/8.12.10) id k6LBpP57026569 for gentoo-user@lists.gentoo.org; Fri, 21 Jul 2006 13:51:25 +0200 Date: Fri, 21 Jul 2006 13:51:25 +0200 From: Enrico Weigelt To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] march in /etc/make.conf Message-ID: <20060721115125.GF4971@nibiru.local> References: <20060706082214.96392.qmail@web33811.mail.mud.yahoo.com> <200607061035.30151.ext-dirk.heinrichs@nokia.com> <44ACD798.8000302@mid.message-center.info> <200607061050.56257.uwix@iway.na> <44ACE259.60603@mid.message-center.info> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44ACE259.60603@mid.message-center.info> User-Agent: Mutt/1.4.1i X-Archives-Salt: ae187749-a9ba-4072-9aaa-b9424d740753 X-Archives-Hash: 73c98950427cac9f7a3639616662fd75 * Alexander Skwar wrote: Hi, > Well, depends on how you define "open files are overwritten". On > Linux, it is like you say. But on Windows and HP-UX, you CANNOT > replace a file, if it's still opened somewhere. Eg. you cannot > replace /bin/sh. Instead, a new file will be created and after > a reboot, the new file will be moved in place (that's how it > works on HP-UX, on Windows you cannot overwrite opened files.). > > What I mean: On Linux, you can replace /bin/sh even if it used. > You cannot overwrite the used inodes/blocks, that's absolutely > correct, but that's not what I meant. ACK. I'll try to explain the logic behind a little bit more detailed: On Linux (and probably other Unix'ish kernels), files are not identified by names, but inode-id's. The name is just an pointer to the file, just like an DNS-name->IP-addr mapping ;-) Many such pointers to some file may exist. Only when all pointers are removed (open fd's also considered as an pointer) the file gets actually removed. That's why the syscall used for removing a file is called unlink(): it just removes the given name but does not actually delete it. When you intend to replace some file, you've got two choices: (from the kernel's view) a) open the existing file, probably truncate it and write new the data. if someone has opened this file, he will see the changes you made. If the file has been mmap'ed to some process, it will see the changes immediately in its address space. therefore files should be locked (at least the used regions), so an accidental overwrite (which may cause ugly crashes) can be prevented. AFAIK on Linux, .TEXT segments are always locked when the get mapped in (you you get "busy" when trying to write there) b) create a new file under the old name. either by renaming or unlink'ing the old file. here you've got no problem w/ other processes holding the file opened, since you actually have two different files. the new file only gets accessed when you (re)open the file and thus let the kernel do an new name->inode lookup. BTW: when coding installers for running systems (which in fact is the case in >90%). Do not use cp (at least GNU coreutils), since it *overwrites* the existing file (case a). This will fail on used .TEXT (=executable code) files, since they're locked and most likely produce problems with other open files. If writing the file does not run almost immediately you should first write to some temporary file (on the same filesystem!) and then do a quick rename (unlink(..) ; rename(..)) so nobody tries to use unfinished files. And be very careful you reinstall you (running) installer ! Several years ago, glibc had a critical problem, which screwed up your system on install over the running system: it first removed the /lib/ld.so and /lib/libc* symlinks and then recreated them by separate calling /bin/rm and /bin/ln binaries. If they weren't linked statically, it killed itself - /bin/ln coulnd'n be executed since libc was unusable in this moment. Using -s flag to ln instead of calling rm did the trick. I have no idea how careful emerge is here ... cu -- --------------------------------------------------------------------- Enrico Weigelt == metux IT service - http://www.metux.de/ --------------------------------------------------------------------- Please visit the OpenSource QM Taskforce: http://wiki.metux.de/public/OpenSource_QM_Taskforce Patches / Fixes for a lot dozens of packages in dozens of versions: http://patches.metux.de/ --------------------------------------------------------------------- -- gentoo-user@gentoo.org mailing list