about summary refs log tree commit diff
path: root/src/libstore/store-api.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-05T02·18+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-05T02·18+0000
commita9c4f66cfb1618833cc70ceaf13733730b634193 (patch)
tree47d3b9aab72f561e2e15f18b8ad415153bfd56ef /src/libstore/store-api.hh
parent29cf434a35d82529f56c085c9cd50858c148d086 (diff)
* 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.

Diffstat (limited to 'src/libstore/store-api.hh')
-rw-r--r--src/libstore/store-api.hh48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index bda232d3d232..19c5d81cf267 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -37,6 +37,16 @@ typedef list<Substitute> Substitutes;
 typedef std::map<Path, Path> Roots;
 
 
+/* Garbage collector operation. */
+typedef enum {
+    gcReturnRoots,
+    gcReturnLive,
+    gcReturnDead,
+    gcDeleteDead,
+    gcDeleteSpecific,
+} GCAction;
+
+
 class StoreAPI 
 {
 public:
@@ -127,6 +137,33 @@ public:
        outside of the Nix store that point to `storePath'.  */
     virtual Roots findRoots() = 0;
 
+    /* Depending on `action', this function does the following:
+
+       - `gcReturnRoots': find and return the set of roots for the
+         garbage collector.  These are the store paths symlinked to in
+         the `gcroots' directory.
+
+       - `gcReturnLive': return the set of paths reachable from
+         (i.e. in the closure of) the roots.
+
+       - `gcReturnDead': return the set of paths not reachable from
+         the roots.
+
+       - `gcDeleteDead': actually delete the latter set.
+
+       - `gcDeleteSpecific': delete the paths listed in
+         `pathsToDelete', insofar as they are not reachable.
+
+       If `ignoreLiveness' is set, then reachability from the roots is
+       ignored (dangerous!).  However, the paths must still be
+       unreferenced *within* the store (i.e., there can be no other
+       store paths that depend on them).
+
+       For `gcReturnDead', `gcDeleteDead' and `gcDeleteSpecific', the
+       number of bytes that would be or was freed is returned in
+       `bytesFreed'. */
+    virtual void collectGarbage(GCAction action, const PathSet & pathsToDelete,
+        bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed) = 0;
 };
 
 
@@ -177,6 +214,17 @@ std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
 Path computeStorePathForText(const string & suffix, const string & s);
 
 
+/* Remove the temporary roots file for this process.  Any temporary
+   root becomes garbage after this point unless it has been registered
+   as a (permanent) root. */
+void removeTempRoots();
+
+
+/* Register a permanent GC root. */
+Path addPermRoot(const Path & storePath, const Path & gcRoot,
+    bool indirect, bool allowOutsideRootsDir = false);
+
+
 /* For now, there is a single global store API object, but we'll
    purify that in the future. */
 extern boost::shared_ptr<StoreAPI> store;