about summary refs log tree commit diff
path: root/src/nix-store
diff options
context:
space:
mode:
authorGuillaume Maudoux <guillaume.maudoux@uclouvain.be>2019-02-28T23·54+0100
committerGuillaume Maudoux <layus.on@gmail.com>2019-03-09T23·56+0100
commitebc86550f92ec76cda0961ecc625944ec402d2cd (patch)
tree50c7349a7569139b544c4173ac27064b36a0e432 /src/nix-store
parenta17f86ce3a67dd2dab2329d7262bc4ad4e7c37ff (diff)
Make roots a map of store paths to pinning links
This new structure makes more sense as there may be many sources rooting
the same store path. Many profiles can reference the same path but this
is even more true with /proc/<pid>/maps where distinct pids can and
often do map the same store path.
This implementation is also more efficient as the `Roots` map contains
only one entry per rooted store path.
Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/nix-store.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 33138baff388..b281ea2dd328 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -428,9 +428,10 @@ static void opQuery(Strings opFlags, Strings opArgs)
                     referrers, true, settings.gcKeepOutputs, settings.gcKeepDerivations);
             }
             Roots roots = store->findRoots();
-            for (auto & i : roots)
-                if (referrers.find(i.second) != referrers.end())
-                    cout << format("%1%\n") % i.first;
+            for (auto & [path, roots] : roots)
+                if (referrers.find(path) != referrers.end())
+                    for (auto & root : roots)
+                        cout << format("%1% -> %2%\n") % root % path;
             break;
         }
 
@@ -591,8 +592,9 @@ static void opGC(Strings opFlags, Strings opArgs)
 
     if (printRoots) {
         Roots roots = store->findRoots();
-        for (auto & i : roots)
-            cout << i.first << " -> " << i.second << std::endl;
+        for (auto & [path, roots] : roots)
+            for (auto & root : roots)
+                cout << root << " -> " << path << std::endl;
     }
 
     else {