Gentoo Archives: gentoo-user

From: Daniel Barkalow <barkalow@××××××××.org>
To: Gentoo Mailing List <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] Dumb question
Date: Wed, 11 Oct 2006 16:30:52
Message-Id: Pine.LNX.4.64.0610111201050.9789@iabervon.org
In Reply to: [gentoo-user] Dumb question by "Anthony E. Caudel"
1 On Tue, 10 Oct 2006, Anthony E. Caudel wrote:
2
3 > I have been using Gentoo for more than 2 years now and have always
4 > wondered (but never asked - That's the "dumb" part) how Gentoo manages
5 > to update a package that happens to be running at the time.
6 >
7 > Given that the old version (the one running) is deleted, how does it
8 > manage to keep standing if you just cut its legs off?
9
10 Userspace technically never "deletes" anything in the UNIX model; it
11 either "truncates" it (not what's going on here) or it "unlinks" it.
12 "Unlink" causes the file not to have the filename any more, and the kernel
13 gets rid of files which aren't in use and have no name (of course, nobody
14 can tell when or if this happens, aside from the disk not filling up,
15 because there would be no way to look at the file anyway).
16
17 If you look at /proc/<PID>/maps for a program you've upgraded, you'll
18 probably find funny notations in there, indicating that the file it's
19 using is not the file that currently has that filename.
20
21 ("truncate" and otherwise openning the file for writing actually affect
22 the file, not the filename, and would therefore cause programs to crash if
23 you overwrote them.)
24
25 Technical terms: the file itself is called an "inode", and the name is a
26 "dentry" (actually, the last part of the path, which is all that goes away
27 in a single operation, is the dentry). A dentry stores the inode number of
28 the inode at that path, and "unlink" removes the dentry. What's actually
29 happening in an upgrade is "rename", which, as a single operation, unlinks
30 any dentry with the destination path, links the source inode to the
31 destination dentry, and unlinks the source dentry. This means that no
32 program can see the path empty or with half of a file or see the file with
33 two names.
34
35 -Daniel
36 *This .sig left intentionally blank*
37 --
38 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Dumb question Michael Sullivan <michael@××××××××××××.com>
Re: [gentoo-user] Dumb question "Anthony E. Caudel" <acaudel@×××××.com>