From 345a95afe9e265bc433eea46c32c507ea84a72a4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Feb 2006 13:58:10 +0000 Subject: * Allow the size of the GC reserved file to be specified in nix.conf through the new `gc-reserved-space' option. --- src/libstore/globals.cc | 19 ++++++++++++------- src/libstore/globals.hh | 2 ++ src/libstore/store.cc | 6 ++++-- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src/libstore') diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index a69bc0c30307..fc338892f22d 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -75,17 +75,22 @@ Strings querySetting(const string & name, const Strings & def) } -bool queryBoolSetting(const string & name, bool def) +string querySetting(const string & name, const string & def) { Strings defs; - if (def) defs.push_back("true"); else defs.push_back("false"); - + defs.push_back(def); + Strings value = querySetting(name, defs); if (value.size() != 1) - throw Error(format("configuration option `%1%' should be either `true' or `false', not a list") - % name); - - string v = value.front(); + throw Error(format("configuration option `%1%' should not be a list") % name); + + return value.front(); +} + + +bool queryBoolSetting(const string & name, bool def) +{ + string v = querySetting(name, def ? "true" : "false"); if (v == "true") return true; else if (v == "false") return false; else throw Error(format("configuration option `%1%' should be either `true' or `false', not `%2%'") diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index cb199fd3692f..b5de709f7b54 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -56,6 +56,8 @@ extern bool readOnlyMode; Strings querySetting(const string & name, const Strings & def); +string querySetting(const string & name, const string & def); + bool queryBoolSetting(const string & name, bool def); diff --git a/src/libstore/store.cc b/src/libstore/store.cc index 25e2d6e36009..94c992f22936 100644 --- a/src/libstore/store.cc +++ b/src/libstore/store.cc @@ -82,12 +82,14 @@ void openDB(bool reserveSpace) try { Path reservedPath = nixDBPath + "/reserved"; - off_t reservedSize = 1024 * 1024; + string s = querySetting("gc-reserved-space", ""); + int reservedSize; + if (!string2Int(s, reservedSize)) reservedSize = 1024 * 1024; if (reserveSpace) { struct stat st; if (stat(reservedPath.c_str(), &st) == -1 || st.st_size != reservedSize) - writeFile(reservedPath, string(1024 * 1024, 'X')); + writeFile(reservedPath, string(reservedSize, 'X')); } else deletePath(reservedPath); -- cgit 1.4.1