From a9c4f66cfb1618833cc70ceaf13733730b634193 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Dec 2006 02:18:46 +0000 Subject: * Allow unprivileged users to run the garbage collector and to do `nix-store --delete'. But unprivileged users are not allowed to ignore liveness. * `nix-store --delete --ignore-liveness': ignore the runtime roots as well. --- src/libstore/gc.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libstore/gc.cc') diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index e5217c9b8636..4d8f25e655fc 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -1,4 +1,3 @@ -#include "gc.hh" #include "globals.hh" #include "misc.hh" #include "pathlocks.hh" @@ -428,7 +427,7 @@ static Paths topoSort(const PathSet & paths) } -void collectGarbage(GCAction action, const PathSet & pathsToDelete, +void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete, bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed) { result.clear(); @@ -446,7 +445,7 @@ void collectGarbage(GCAction action, const PathSet & pathsToDelete, /* Find the roots. Since we've grabbed the GC lock, the set of permanent roots cannot increase now. */ - Roots rootMap = ignoreLiveness ? Roots() : findRoots(true); + Roots rootMap = ignoreLiveness ? Roots() : nix::findRoots(true); PathSet roots; for (Roots::iterator i = rootMap.begin(); i != rootMap.end(); ++i) @@ -456,7 +455,8 @@ void collectGarbage(GCAction action, const PathSet & pathsToDelete, NIX_ROOT_FINDER environment variable. This is typically used to add running programs to the set of roots (to prevent them from being garbage collected). */ - addAdditionalRoots(roots); + if (!ignoreLiveness) + addAdditionalRoots(roots); if (action == gcReturnRoots) { result = roots; -- cgit 1.4.1