run edenfsctl redirect fixup after mout is done

Summary: Use `Subprocess` in `win/utils` to call `edenfsctl redirection fixup` after mount is done.

Reviewed By: wez

Differential Revision: D22958764

fbshipit-source-id: a485994a3816169299e8514a5c355f3d37edad99
This commit is contained in:
Zeyi (Rice) Fan 2020-08-24 21:35:57 -07:00 committed by Facebook GitHub Bot
parent 4d21d2dd8a
commit 50378e741a
2 changed files with 28 additions and 28 deletions

View File

@ -51,6 +51,7 @@
#ifdef _WIN32
#include "eden/fs/win/mount/EdenDispatcher.h" // @manual
#include "eden/fs/win/mount/PrjfsChannel.h" // @manual
#include "eden/fs/win/utils/Subprocess.h" // @manual
#else
#include <folly/File.h>
#include <folly/Subprocess.h>
@ -434,30 +435,35 @@ FOLLY_NODISCARD folly::Future<folly::Unit> EdenMount::removeBindMount(
auto absRepoPath = getPath() + repoPath;
return serverState_->getPrivHelper()->bindUnMount(absRepoPath.stringPiece());
}
#endif // !_WIN32
folly::SemiFuture<Unit> EdenMount::performBindMounts() {
return folly::makeSemiFutureWith([&] {
std::vector<std::string> argv{FLAGS_edenfsctlPath,
"redirect",
"fixup",
"--mount",
getPath().c_str()};
return futureSubprocess(folly::Subprocess(argv));
})
.deferValue([&](folly::ProcessReturnCode&& returnCode) {
if (returnCode.state() == folly::ProcessReturnCode::EXITED &&
returnCode.exitStatus() == 0) {
return folly::unit;
}
folly::CalledProcessError err(returnCode);
throw std::runtime_error(folly::to<std::string>(
"Failed to run `",
FLAGS_edenfsctlPath,
" fixup --mount ",
getPath(),
"`: ",
folly::exceptionStr(err)));
})
std::vector<std::string> argv{
FLAGS_edenfsctlPath, "redirect", "fixup", "--mount", getPath().c_str()};
#ifndef _WIN32
auto redirectFuture =
folly::makeSemiFutureWith(
[&] { return futureSubprocess(folly::Subprocess(argv)); })
.deferValue([&](folly::ProcessReturnCode&& returnCode) {
if (returnCode.state() == folly::ProcessReturnCode::EXITED &&
returnCode.exitStatus() == 0) {
return folly::unit;
}
folly::CalledProcessError err(returnCode);
throw std::runtime_error(folly::to<std::string>(
"Failed to run `",
FLAGS_edenfsctlPath,
" fixup --mount ",
getPath(),
"`: ",
folly::exceptionStr(err)));
});
#else
auto redirectFuture =
folly::makeSemiFutureWith([&] { Subprocess redirect(argv); });
#endif // !_WIN32
return std::move(redirectFuture)
.deferError([&](folly::exception_wrapper err) {
throw std::runtime_error(folly::to<std::string>(
"Failed to run `",
@ -468,7 +474,6 @@ folly::SemiFuture<Unit> EdenMount::performBindMounts() {
folly::exceptionStr(err)));
});
}
#endif // !_WIN32
EdenMount::~EdenMount() {}

View File

@ -1381,10 +1381,6 @@ folly::Future<std::shared_ptr<EdenMount>> EdenServer::mount(
return makeFuture<std::shared_ptr<EdenMount>>(
std::move(edenMount));
} else {
#ifdef _WIN32
return makeFuture<std::shared_ptr<EdenMount>>(
std::move(edenMount));
#else
// Perform all of the bind mounts associated with the
// client. We don't need to do this for the takeover
// case as they are already mounted.
@ -1397,7 +1393,6 @@ folly::Future<std::shared_ptr<EdenMount>> EdenServer::mount(
return edenMount;
})
.via(getServerState()->getThreadPool().get());
#endif
}
})
.thenTry([this, mountStopWatch, doTakeover, edenMount](auto&& t) {