lkml.org 
[lkml]   [1998]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Anybody out there? (ETXTBSY)
On Fri, Aug 28, 1998 at 06:33:48PM +0200, Juan J. Quintela wrote:
> Petri Kaukasoina <kaukasoi@elektroni.ee.tut.fi> wrote:
> > why unlink() ? rename() should be enough and then there's no time when
> > /bin/sh or libc is missing.
>
> From the man page of rename:
>
> If newpath already exists it will be atomically overwrit­
> ^^^^^^^^
> ten (subject to a few conditions - see ERRORS below), so
> ^^^
> that there is no point at which another process attempting
> to access newpath will find it missing.
>
> You don't want to overwrite the existing libc.so or your running
> binaries running against it will stop work in that moment.

Well the man page may be a little obscure.

'cp new_libc.so libc.so' or 'cat new_libc.so > libc.so' would overwrite the
inode of the old libc.so using write() so that running binaries would crash.

rename("new_libc.so","libc.so") does not overwrite the inode of the old
libc.so. The old inode will exist unmodified until it will be deleted when
all the binaries using it have finished (if libc.so was the only link). You
could even do
link("libc.so","backup_libc.so");rename("new_libc.so","libc.so") to save a
perfectly working backup copy of the old libc. What the man page means by
overwriting is that rename() only overwrites the directory entry of libc.so
so that it points to the inode of the new libc.so. This overwriting is done
atomically so that there is no moment when the directory entry 'libc.so'
would not point to either version of the library. But it does not affect the
contents of the inodes in question.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:1.094 / U:1.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site