On Wed, 14 Mar 2007, Maurice Janssen wrote:

> On Wednesday, March 14, 2007 at 17:28:54 -0400, Clint M. Sand wrote:
> >I know this is a dumb question but make install on a kernel build does:
> >
> >rm -f /obsd
> >ln /bsd /obsd
> >cp bsd /nbsd
> >mv /nbsd /bsd
> >
> >
> >But I can't see the reasoning here. Why do we copy it then move it
> >rather than just copying it straight to /bsd?
> 
> If you cp the kernel to /bsd, you end up with a broken kernel in case of
> a power failure or other problem during the cp command.
> The chance on something like that happening during the mv is much
> smaller, because it takes much less time.

mv(1) is safe because the rename(2) system call is atomic. This has
little to do with the duration of the operation. See man rename(2). 

        -Otto

Reply via email to