2004-08-25 11:43:49 +00:00
|
|
|
#ifndef __GC_H
|
|
|
|
#define __GC_H
|
|
|
|
|
2005-01-19 16:39:47 +00:00
|
|
|
#include "util.hh"
|
2004-08-25 11:43:49 +00:00
|
|
|
|
2005-01-31 10:27:25 +00:00
|
|
|
|
2005-01-27 15:21:29 +00:00
|
|
|
/* Garbage collector operation. */
|
2005-02-01 15:05:32 +00:00
|
|
|
typedef enum {
|
|
|
|
gcReturnRoots,
|
|
|
|
gcReturnLive,
|
|
|
|
gcReturnDead,
|
|
|
|
gcDeleteDead,
|
2005-12-23 21:08:42 +00:00
|
|
|
gcDeleteSpecific,
|
2005-02-01 15:05:32 +00:00
|
|
|
} GCAction;
|
|
|
|
|
|
|
|
/* If `action' is set to `gcReturnRoots', find and return the set of
|
|
|
|
roots for the garbage collector. These are the store paths
|
|
|
|
symlinked to in the `gcroots' directory. If `action' is
|
|
|
|
`gcReturnLive', return the set of paths reachable from (i.e. in the
|
|
|
|
closure of) the roots. If `action' is `gcReturnDead', return the
|
|
|
|
set of paths not reachable from the roots. If `action' is
|
|
|
|
`gcDeleteDead', actually delete the latter set. */
|
2005-12-23 21:08:42 +00:00
|
|
|
void collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
2005-12-23 21:36:44 +00:00
|
|
|
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed);
|
2004-08-25 11:43:49 +00:00
|
|
|
|
2005-01-31 10:27:25 +00:00
|
|
|
/* Register a temporary GC root. This root will automatically
|
2005-01-31 12:19:53 +00:00
|
|
|
disappear when this process exits. WARNING: this function should
|
|
|
|
not be called inside a BDB transaction, otherwise we can
|
|
|
|
deadlock. */
|
2005-01-31 10:27:25 +00:00
|
|
|
void addTempRoot(const Path & path);
|
|
|
|
|
2005-01-31 21:20:59 +00:00
|
|
|
/* 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();
|
|
|
|
|
2005-02-01 12:36:25 +00:00
|
|
|
/* Register a permanent GC root. */
|
2005-02-01 13:48:46 +00:00
|
|
|
Path addPermRoot(const Path & storePath, const Path & gcRoot,
|
|
|
|
bool indirect);
|
2005-02-01 12:36:25 +00:00
|
|
|
|
2005-01-31 10:27:25 +00:00
|
|
|
|
2004-08-25 11:43:49 +00:00
|
|
|
#endif /* !__GC_H */
|