about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-09-19T20·17-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-09-19T20·17-0400
commitb9c2b4d5b4cd5d52a950e6dd90eb2e2e79891fa0 (patch)
treee0f8f1b95570604fa64cd89fb53a50f44f72dcb0 /src/libutil
parentb9124a5c336fd231adaa548cf5be311731847848 (diff)
Remove setting of the immutable bit
Using the immutable bit is problematic, especially in conjunction with
store optimisation.  For instance, if the garbage collector deletes a
file, it has to clear its immutable bit, but if the file has
additional hard links, we can't set the bit afterwards because we
don't know the remaining paths.

So now that we support having the entire Nix store as a read-only
mount, we may as well drop the immutable bit.  Unfortunately, we have
to keep the code to clear the immutable bit for backwards
compatibility.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/immutable.cc22
-rw-r--r--src/libutil/immutable.hh6
2 files changed, 2 insertions, 26 deletions
diff --git a/src/libutil/immutable.cc b/src/libutil/immutable.cc
index f72f856254..766af49393 100644
--- a/src/libutil/immutable.cc
+++ b/src/libutil/immutable.cc
@@ -16,7 +16,7 @@
 namespace nix {
 
 
-void changeMutable(const Path & path, bool mut)
+void makeMutable(const Path & path)
 {
 #if defined(FS_IOC_SETFLAGS) && defined(FS_IOC_GETFLAGS) && defined(FS_IMMUTABLE_FL)
 
@@ -38,30 +38,12 @@ void changeMutable(const Path & path, bool mut)
     /* Silently ignore errors getting/setting the immutable flag so
        that we work correctly on filesystems that don't support it. */
     if (ioctl(fd, FS_IOC_GETFLAGS, &flags)) return;
-
     old = flags;
-    
-    if (mut) flags &= ~FS_IMMUTABLE_FL;
-    else flags |= FS_IMMUTABLE_FL;
-
+    flags &= ~FS_IMMUTABLE_FL;
     if (old == flags) return;
-
     if (ioctl(fd, FS_IOC_SETFLAGS, &flags)) return;
-    
 #endif
 }
 
 
-void makeImmutable(const Path & path)
-{
-    changeMutable(path, false);
-}
-
-
-void makeMutable(const Path & path)
-{
-    changeMutable(path, true);
-}
-
-
 }
diff --git a/src/libutil/immutable.hh b/src/libutil/immutable.hh
index 8af4190049..8e98b76a41 100644
--- a/src/libutil/immutable.hh
+++ b/src/libutil/immutable.hh
@@ -4,12 +4,6 @@
 
 namespace nix {
 
-/* Make the given path immutable, i.e., prevent it from being modified
-   in any way, even by root.  This is a no-op on platforms that do not
-   support this, or if the calling user is not privileged.  On Linux,
-   this is implemented by doing the equivalent of ‘chattr +i path’. */
-void makeImmutable(const Path & path);
-
 /* Make the given path mutable. */
 void makeMutable(const Path & path);