about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-03-10T22·27+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-03-10T22·27+0000
commitfdea084c365083a65eb363973400416107b5e32b (patch)
tree82584bb341b821205fd73122276ae38dd9320f2f /src
parent37d1b1cafd17a18dc7dbef3b4ba7fb204158d58b (diff)
* Allow `make check' to work in directories that have symlink
  components.

Diffstat (limited to 'src')
-rw-r--r--src/libmain/shared.cc25
-rw-r--r--src/libstore/store.cc20
2 files changed, 22 insertions, 23 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 1e48a6365220..97528f123e4a 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -23,7 +23,7 @@ extern "C" {
 volatile sig_atomic_t blockInt = 0;
 
 
-void sigintHandler(int signo)
+static void sigintHandler(int signo)
 {
     if (!blockInt) {
         _isInterrupted = 1;
@@ -54,7 +54,7 @@ void printGCWarning()
 }
 
 
-void setLogType(string lt)
+static void setLogType(string lt)
 {
     if (lt == "pretty") logType = ltPretty;
     else if (lt == "escapes") logType = ltEscapes;
@@ -63,22 +63,6 @@ void setLogType(string lt)
 }
 
 
-void checkStoreNotSymlink(Path path)
-{
-    struct stat st;
-    while (path != "/") {
-        if (lstat(path.c_str(), &st))
-            throw SysError(format("getting status of `%1%'") % path);
-        if (S_ISLNK(st.st_mode))
-            throw Error(format(
-                "the path `%1%' is a symlink; "
-                "this is not allowed for the Nix store and its parent directories")
-                % path);
-        path = dirOf(path);
-    }
-}
-
-
 struct RemoveTempRoots 
 {
     ~RemoveTempRoots()
@@ -109,11 +93,6 @@ static void initAndRun(int argc, char * * argv)
     nixDBPath = getEnv("NIX_DB_DIR", nixStateDir + "/db");
     nixConfDir = canonPath(getEnv("NIX_CONF_DIR", NIX_CONF_DIR));
 
-    /* Check that the store directory and its parent are not
-       symlinks. */
-    if (getEnv("NIX_IGNORE_SYMLINK_STORE") != "1")
-        checkStoreNotSymlink(nixStore);
-
     /* Catch SIGINT. */
     struct sigaction act, oact;
     act.sa_handler = sigintHandler;
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index e792fd28cedc..556ba8e62166 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -76,10 +76,30 @@ static void upgradeStore07();
 static void upgradeStore09();
 
 
+void checkStoreNotSymlink()
+{
+    if (getEnv("NIX_IGNORE_SYMLINK_STORE") == "1") return;
+    Path path = nixStore;
+    struct stat st;
+    while (path != "/") {
+        if (lstat(path.c_str(), &st))
+            throw SysError(format("getting status of `%1%'") % path);
+        if (S_ISLNK(st.st_mode))
+            throw Error(format(
+                "the path `%1%' is a symlink; "
+                "this is not allowed for the Nix store and its parent directories")
+                % path);
+        path = dirOf(path);
+    }
+}
+
+
 void openDB(bool reserveSpace)
 {
     if (readOnlyMode) return;
 
+    checkStoreNotSymlink();
+
     try {
         Path reservedPath = nixDBPath + "/reserved";
         string s = querySetting("gc-reserved-space", "");