summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-12-17 12:25:47 +0100
committerLudovic Courtès <ludo@gnu.org>2022-12-18 01:16:47 +0100
commit2d4d26769d6a3be1b21302b0bb2bd099fd55ccf8 (patch)
tree1b975e7063a14a4972852df5129befad57b159c2
parent239bfe2ec1fa3b4305500211e6cade6e4bda2a62 (diff)
daemon: Make "opening file" error messages distinguishable.
* nix/libstore/build.cc (DerivationGoal::openLogFile): Customize "opening file" error message. * nix/libutil/hash.cc (hashFile): Likewise. * nix/libutil/util.cc (readFile, writeFile): Likewise.
-rw-r--r--nix/libstore/build.cc2
-rw-r--r--nix/libutil/hash.cc2
-rw-r--r--nix/libutil/util.cc4
3 files changed, 4 insertions, 4 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 10a6093bd54..c5383bc756c 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -2576,7 +2576,7 @@ Path DerivationGoal::openLogFile()
2576 closeOnExec(fd); 2576 closeOnExec(fd);
2577 2577
2578 if (!(fLogFile = fdopen(fd.borrow(), "w"))) 2578 if (!(fLogFile = fdopen(fd.borrow(), "w")))
2579 throw SysError(format("opening file `%1%'") % logFileName); 2579 throw SysError(format("opening log file `%1%'") % logFileName);
2580 2580
2581 int err; 2581 int err;
2582 if (!(bzLogFile = BZ2_bzWriteOpen(&err, fLogFile, 9, 0, 0))) 2582 if (!(bzLogFile = BZ2_bzWriteOpen(&err, fLogFile, 9, 0, 0)))
diff --git a/nix/libutil/hash.cc b/nix/libutil/hash.cc
index 7853acdd494..9ba604eb85d 100644
--- a/nix/libutil/hash.cc
+++ b/nix/libutil/hash.cc
@@ -244,7 +244,7 @@ Hash hashFile(HashType ht, const Path & path)
244 start(ht, ctx); 244 start(ht, ctx);
245 245
246 AutoCloseFD fd = open(path.c_str(), O_RDONLY); 246 AutoCloseFD fd = open(path.c_str(), O_RDONLY);
247 if (fd == -1) throw SysError(format("opening file `%1%'") % path); 247 if (fd == -1) throw SysError(format("computing hash of file `%1%'") % path);
248 248
249 unsigned char buf[8192]; 249 unsigned char buf[8192];
250 ssize_t n; 250 ssize_t n;
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 4d3780e3c2e..82eac72120a 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -264,7 +264,7 @@ string readFile(const Path & path, bool drain)
264{ 264{
265 AutoCloseFD fd = open(path.c_str(), O_RDONLY); 265 AutoCloseFD fd = open(path.c_str(), O_RDONLY);
266 if (fd == -1) 266 if (fd == -1)
267 throw SysError(format("opening file `%1%'") % path); 267 throw SysError(format("reading file `%1%'") % path);
268 return drain ? drainFD(fd) : readFile(fd); 268 return drain ? drainFD(fd) : readFile(fd);
269} 269}
270 270
@@ -273,7 +273,7 @@ void writeFile(const Path & path, const string & s)
273{ 273{
274 AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666); 274 AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666);
275 if (fd == -1) 275 if (fd == -1)
276 throw SysError(format("opening file '%1%'") % path); 276 throw SysError(format("writing file '%1%'") % path);
277 writeFull(fd, s); 277 writeFull(fd, s);
278} 278}
279 279