guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

26/27: Add a ‘verifyStore’ RPC


From: Ludovic Courtès
Subject: 26/27: Add a ‘verifyStore’ RPC
Date: Wed, 03 Jun 2015 22:00:47 +0000

civodul pushed a commit to branch nix
in repository guix.

commit 715478fe09a73cec70f5c6f869cac482f004596f
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jun 1 23:20:11 2015 +0200

    Add a ‘verifyStore’ RPC
    
    Hello!
    
    The patch below adds a ‘verifyStore’ RPC with the same signature as the
    current LocalStore::verifyStore method.
    
    Thanks,
    Ludo’.
    
    >From aef46c03ca77eb6344f4892672eb6d9d06432041 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <address@hidden>
    Date: Mon, 1 Jun 2015 23:17:10 +0200
    Subject: [PATCH] Add a 'verifyStore' remote procedure call.
---
 nix/libstore/remote-store.cc    |   10 ++++++++++
 nix/libstore/remote-store.hh    |    1 +
 nix/libstore/store-api.hh       |    4 ++++
 nix/libstore/worker-protocol.hh |    3 ++-
 nix/nix-daemon/nix-daemon.cc    |   10 ++++++++++
 5 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/nix/libstore/remote-store.cc b/nix/libstore/remote-store.cc
index 140fe9c..0539bbe 100644
--- a/nix/libstore/remote-store.cc
+++ b/nix/libstore/remote-store.cc
@@ -585,6 +585,16 @@ void RemoteStore::optimiseStore()
     readInt(from);
 }
 
+bool RemoteStore::verifyStore(bool checkContents, bool repair)
+{
+    openConnection();
+    writeInt(wopVerifyStore, to);
+    writeInt(checkContents, to);
+    writeInt(repair, to);
+    processStderr();
+    return readInt(from) != 0;
+}
+
 void RemoteStore::processStderr(Sink * sink, Source * source)
 {
     to.flush();
diff --git a/nix/libstore/remote-store.hh b/nix/libstore/remote-store.hh
index 14209cb..030120d 100644
--- a/nix/libstore/remote-store.hh
+++ b/nix/libstore/remote-store.hh
@@ -85,6 +85,7 @@ public:
 
     void optimiseStore();
 
+    bool verifyStore(bool checkContents, bool repair);
 private:
     AutoCloseFD fdSocket;
     FdSink to;
diff --git a/nix/libstore/store-api.hh b/nix/libstore/store-api.hh
index 97a60a6..3764f3e 100644
--- a/nix/libstore/store-api.hh
+++ b/nix/libstore/store-api.hh
@@ -254,6 +254,10 @@ public:
     /* Optimise the disk space usage of the Nix store by hard-linking files
        with the same contents. */
     virtual void optimiseStore() = 0;
+
+    /* Check the integrity of the Nix store.  Returns true if errors
+       remain. */
+    virtual bool verifyStore(bool checkContents, bool repair) = 0;
 };
 
 
diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh
index 4b040b7..d037d74 100644
--- a/nix/libstore/worker-protocol.hh
+++ b/nix/libstore/worker-protocol.hh
@@ -42,7 +42,8 @@ typedef enum {
     wopQueryValidPaths = 31,
     wopQuerySubstitutablePaths = 32,
     wopQueryValidDerivers = 33,
-    wopOptimiseStore = 34
+    wopOptimiseStore = 34,
+    wopVerifyStore = 35
 } WorkerOp;
 
 
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 5801989..96a4e4b 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -647,6 +647,16 @@ static void performOp(bool trusted, unsigned int 
clientVersion,
         writeInt(1, to);
         break;
 
+    case wopVerifyStore: {
+       bool checkContents = readInt(from) != 0;
+       bool repair = readInt(from) != 0;
+       startWork();
+       bool errors = store->verifyStore(checkContents, repair);
+       stopWork();
+       writeInt(errors, to);
+       break;
+    }
+
     default:
         throw Error(format("invalid operation %1%") % op);
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]