Gentoo Archives: gentoo-user

From: "Anthony E. Caudel" <acaudel@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Dumb question
Date: Thu, 12 Oct 2006 06:24:23
Message-Id: 452DDDFB.6020702@gt.rr.com
In Reply to: Re: [gentoo-user] Dumb question by Daniel Barkalow
1 Daniel Barkalow wrote:
2 > On Tue, 10 Oct 2006, Anthony E. Caudel wrote:
3 >
4 >> I have been using Gentoo for more than 2 years now and have always
5 >> wondered (but never asked - That's the "dumb" part) how Gentoo manages
6 >> to update a package that happens to be running at the time.
7 >>
8 >> Given that the old version (the one running) is deleted, how does it
9 >> manage to keep standing if you just cut its legs off?
10 >
11 > Userspace technically never "deletes" anything in the UNIX model; it
12 > either "truncates" it (not what's going on here) or it "unlinks" it.
13 > "Unlink" causes the file not to have the filename any more, and the kernel
14 > gets rid of files which aren't in use and have no name (of course, nobody
15 > can tell when or if this happens, aside from the disk not filling up,
16 > because there would be no way to look at the file anyway).
17 >
18 > If you look at /proc/<PID>/maps for a program you've upgraded, you'll
19 > probably find funny notations in there, indicating that the file it's
20 > using is not the file that currently has that filename.
21 >
22 > ("truncate" and otherwise openning the file for writing actually affect
23 > the file, not the filename, and would therefore cause programs to crash if
24 > you overwrote them.)
25 >
26 > Technical terms: the file itself is called an "inode", and the name is a
27 > "dentry" (actually, the last part of the path, which is all that goes away
28 > in a single operation, is the dentry). A dentry stores the inode number of
29 > the inode at that path, and "unlink" removes the dentry. What's actually
30 > happening in an upgrade is "rename", which, as a single operation, unlinks
31 > any dentry with the destination path, links the source inode to the
32 > destination dentry, and unlinks the source dentry. This means that no
33 > program can see the path empty or with half of a file or see the file with
34 > two names.
35 >
36 > -Daniel
37 > *This .sig left intentionally blank*
38
39 Thanks all. I guess I now understand how it works.
40
41 Someone noted that if you update sshd for example, a restart would be in
42 order afterward. This would seem to be true of a lot of programs. So
43 would a total restart of the system (just short of a reboot) be warranted?
44
45 Tony
46
47 --
48 Those who would give up essential Liberty, to purchase a little temporary
49 Safety, deserve neither Liberty nor Safety.
50 -- Benjamin Franklin
51 --
52 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Dumb question "Bo Ørsted Andresen" <bo.andresen@××××.dk>