From 4a22cc63fd2032308a062d2b8ddf7f283432f34f Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 21 Apr 2017 09:31:01 +0000 Subject: Fix the advice on how to atomically replace directories with s6-ln or POSIX --- doc/faq.html | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/faq.html b/doc/faq.html index 8df36cb..09c3a99 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -215,20 +215,21 @@ To ensure that the new database will be used on the next boot, atomically update the link:
  olddb=`s6-linkname -f /etc/s6-rc/compiled`
- s6-ln -sf compiled-$stamp /etc/s6-rc/compiled
+ s6-ln -nsf compiled-$stamp /etc/s6-rc/compiled
 
The use of the s6-ln -utility is recommended, because not all implementations of the +utility is recommended, because the ln -standard actually perform an atomic replacement. (For instance, ln -sf -from GNU coreutils first removes the old link, then creates the new one: -this is not atomic and may break your system if you're unlucky and get a -power failure at the wrong time.) s6-ln is guaranteed to do the right thing. -Alternatively, you could run something like ln -sf compiled-$stamp -/etc/s6-rc/compiled.new ; mv -f /etc/s6-rc/compiled.new -/etc/s6-rc/compiled, but that's more complex and may also fail with -bad mv implementations. +standard actually forbids an atomic replacement, so utilities that +follow it to the letter, for instance, ln from GNU coreutils, cannot +be atomic: they first remove the old link, then create the new one. If you +do not have +s6-ln, +you need to perform an unintuitive workaround to get POSIX-compliant tools to +do the right thing: + ln -sf compiled-$stamp /etc/s6-rc/compiled/compiled && +mv -f /etc/s6-rc/compiled/compiled /etc/s6-rc
  • Your current compiled database, stored in /etc/s6-rc/compiled-$stamp, is now accessible via the /etc/s6-rc/compiled symlink and will be used at boot time. You do -- cgit v1.2.3