From e0090fea40d4e7cdcbfbb879a7507be4f5f5f625 Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Thu, 11 Jul 2024 14:11:04 +0530 Subject: [PATCH] Explicitly set `errNo` for `filesystem_error`s --- src/libstore/build/derivation-goal.cc | 4 ++-- src/libstore/builtins/buildenv.cc | 2 +- src/libstore/optimise-store.cc | 2 +- src/libutil/file-system.cc | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 4da700b1524..bcc74d8fcce 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -795,7 +795,7 @@ static void movePath(const Path & src, const Path & dst) try { fs::permissions(src, st.permissions() | fs::perms::owner_write, permOpts); } catch (const fs::filesystem_error & e) { - throw SysError("setting permissions on '%s'", src); + throw SysError(e.code().value(), "setting permissions on '%s'", src); } } @@ -805,7 +805,7 @@ static void movePath(const Path & src, const Path & dst) try { fs::permissions(dst, st.permissions(), permOpts); } catch (const fs::filesystem_error & e) { - throw SysError("setting permissions on '%s'", dst); + throw SysError(e.code().value(), "setting permissions on '%s'", dst); } } } diff --git a/src/libstore/builtins/buildenv.cc b/src/libstore/builtins/buildenv.cc index 216bf4aa4be..37c9142804f 100644 --- a/src/libstore/builtins/buildenv.cc +++ b/src/libstore/builtins/buildenv.cc @@ -53,7 +53,7 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir, continue; } } catch (fs::filesystem_error & e) { - throw SysError("getting status of '%1%'", srcFile); + throw SysError(e.code().value(), "getting status of '%1%'", srcFile); } /* The files below are special-cased to that they don't show diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc index d5ed445dce2..ee1586e993e 100644 --- a/src/libstore/optimise-store.cc +++ b/src/libstore/optimise-store.cc @@ -26,7 +26,7 @@ static void makeWritable(const Path & path) std::filesystem::permissions(path, writePerms); } catch (std::filesystem::filesystem_error &e) { - throw SysError("changing writability of '%1%'", path); + throw SysError(e.code().value(), "changing writability of '%1%'", path); } } diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index d5026ec6551..b67a0c8c75b 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -194,7 +194,7 @@ std::optional maybeSymlinkStat(const fs::path & path) return std::nullopt; return st; } catch (fs::filesystem_error & e) { - throw SystemError("getting status of '%s'", path); + throw SystemError(e.code().value(), "getting status of '%s'", path); } } @@ -424,7 +424,7 @@ void createDirs(const Path & path) try { fs::create_directories(path); } catch (fs::filesystem_error & e) { - throw SysError("creating directory '%1%'", path); + throw SysError(e.code().value(), "creating directory '%1%'", path); } }