mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-12 13:17:18 +02:00
doBind: Use our own lstat wrapper
Doesn't change much, but brings a bit more consistency to the code
This commit is contained in:
parent
913db9f738
commit
ae4737294e
1 changed files with 5 additions and 4 deletions
|
@ -24,7 +24,6 @@
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
@ -396,19 +395,21 @@ void LocalDerivationGoal::cleanupPostOutputsRegisteredModeNonCheck()
|
||||||
#if __linux__
|
#if __linux__
|
||||||
static void doBind(const Path & source, const Path & target, bool optional = false) {
|
static void doBind(const Path & source, const Path & target, bool optional = false) {
|
||||||
debug("bind mounting '%1%' to '%2%'", source, target);
|
debug("bind mounting '%1%' to '%2%'", source, target);
|
||||||
struct stat st;
|
|
||||||
|
|
||||||
auto bindMount = [&]() {
|
auto bindMount = [&]() {
|
||||||
if (mount(source.c_str(), target.c_str(), "", MS_BIND | MS_REC, 0) == -1)
|
if (mount(source.c_str(), target.c_str(), "", MS_BIND | MS_REC, 0) == -1)
|
||||||
throw SysError("bind mount from '%1%' to '%2%' failed", source, target);
|
throw SysError("bind mount from '%1%' to '%2%' failed", source, target);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (lstat(source.c_str(), &st) == -1) {
|
auto maybeSt = maybeLstat(source);
|
||||||
if (optional && errno == ENOENT)
|
if (!maybeSt) {
|
||||||
|
if (optional)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
throw SysError("getting attributes of path '%1%'", source);
|
throw SysError("getting attributes of path '%1%'", source);
|
||||||
}
|
}
|
||||||
|
auto st = *maybeSt;
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
createDirs(target);
|
createDirs(target);
|
||||||
bindMount();
|
bindMount();
|
||||||
|
|
Loading…
Add table
Reference in a new issue