Re: stupid question re kernal build make install
On Wed, 14 Mar 2007, Jacob Yocom-Piatt wrote: > 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? > > > > > > > to prevent a poorly timed "act of god" from making the system unbootable. Doesn't this method also keep the original file correctly mapped by any processes (the running kernel? a debugger?) that may have it open for some reason or other?Just "cp bsd /bsd" would perhaps wreck such a process. With the given method, the old version of /bsd just leaves the namespace, but the vnode, if open, still maps the old blocks, which won't be freed until close(2)d. This is in addtion to the other reason of providing an atomic action, and not messing with the kernel until nearly all possibilities for the action to fail (no space on /, blah blah) have been eliminated, as others have already mentioned. Dave
Re: stupid question re kernal build make install
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
Re: stupid question re kernal build make install
The chance on something like that happening during the mv is much smaller, because it takes much less time. More importantly, mv (actually, rename(2)) is an atomic operation, which means there is no period of time where /bsd does not exist. If the system dies while there is no /bsd, it won't have a kernel to load when it boots. --lyndon
Re: stupid question re kernal build make install
On 2007/03/14 17:28, 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? many of the ways in which a copy could fail will result in a broken destination file. mv uses the rename system call when source and destination are on the same filesystem; this provides a guarantee noted in rename(2).
Re: stupid question re kernal build make install
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. Maurice
Re: stupid question re kernal build make install
On Wed, Mar 14, 2007 at 04:34:02PM -0500, Jacob Yocom-Piatt wrote: > 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? > > > > > > > to prevent a poorly timed "act of god" from making the system unbootable. Thx. Makes sense. Many times the explaination is the simple one. I was overcomplicating things. Cheers.
Re: stupid question re kernal build make install
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? to prevent a poorly timed "act of god" from making the system unbootable.
stupid question re kernal build make install
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?