diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-27T15·21+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-27T15·21+0000 |
commit | c505702265833a762d681952bcc72562d64a242e (patch) | |
tree | da6f095532755b766d7752d6925ea865ba0cefe2 /src/nix-env/profiles.cc | |
parent | 59682e618805701f9c249736514df6db457895f9 (diff) |
* Fix and simplify the garbage collector (it's still not concurrent,
though). In particular it's now much easier to register a GC root. Just place a symlink to whatever store path it is that you want to keep in /nix/var/nix/gcroots.
Diffstat (limited to 'src/nix-env/profiles.cc')
-rw-r--r-- | src/nix-env/profiles.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/nix-env/profiles.cc b/src/nix-env/profiles.cc index 96467831f128..abfdf9fede3d 100644 --- a/src/nix-env/profiles.cc +++ b/src/nix-env/profiles.cc @@ -62,11 +62,11 @@ Generations findGenerations(Path profile, int & curGen) static void makeNames(const Path & profile, unsigned int num, - Path & generation, Path & gcrootDrv) + Path & outLink, Path & drvLink) { Path prefix = (format("%1%-%2%") % profile % num).str(); - generation = prefix + "-link"; - gcrootDrv = prefix + "-drv.gcroot"; + outLink = prefix + "-output"; + drvLink = prefix + "-drv"; } @@ -79,20 +79,21 @@ Path createGeneration(Path profile, Path outPath, Path drvPath) unsigned int num = gens.size() > 0 ? gens.front().number : 0; /* Create the new generation. */ - Path generation, gcrootDrv; + Path outLink, drvLink; while (1) { - makeNames(profile, num, generation, gcrootDrv); - if (symlink(outPath.c_str(), generation.c_str()) == 0) break; + makeNames(profile, num, outLink, drvLink); + if (symlink(outPath.c_str(), outLink.c_str()) == 0) break; if (errno != EEXIST) - throw SysError(format("creating symlink `%1%'") % generation); + throw SysError(format("creating symlink `%1%'") % outLink); /* Somebody beat us to it, retry with a higher number. */ num++; } - writeStringToFile(gcrootDrv, drvPath); + if (symlink(drvPath.c_str(), drvLink.c_str()) != 0) + throw SysError(format("creating symlink `%1%'") % drvLink); - return generation; + return outLink; } |