config: add a per-repo mount protocol

Summary:
On macOS, EdenFS will soon be exposed as an NFS server. To ease the transition,
let's have a per-mount config to decide whether this repository should be
mounted via FUSE or NFS

Reviewed By: genevievehelsel

Differential Revision: D26139992

fbshipit-source-id: d28b0e2327c1101f3555ab0bbc9a5b03d82fd7ff
This commit is contained in:
Xavier Deguillard 2021-02-03 16:43:32 -08:00 committed by Facebook GitHub Bot
parent 86114ab338
commit 990af745e2
2 changed files with 34 additions and 0 deletions

View File

@ -30,10 +30,24 @@ constexpr folly::StringPiece kRepoSection{"repository"};
constexpr folly::StringPiece kRepoSourceKey{"path"};
constexpr folly::StringPiece kRepoTypeKey{"type"};
constexpr folly::StringPiece kRepoCaseSensitiveKey{"case-sensitive"};
constexpr folly::StringPiece kMountProtocol{"protocol"};
#ifdef _WIN32
constexpr folly::StringPiece kRepoGuid{"guid"};
#endif
#ifdef _WIN32
constexpr folly::StringPiece kMountProtocolPrjfs{"prjfs"};
#else
constexpr folly::StringPiece kMountProtocolFuse{"fuse"};
#endif
constexpr folly::StringPiece kMountProtocolNFS{"nfs"};
#ifdef _WIN32
constexpr folly::StringPiece kMountProtocolDefault{kMountProtocolPrjfs};
#else
constexpr folly::StringPiece kMountProtocolDefault{kMountProtocolFuse};
#endif
// Files of interest in the client directory.
const facebook::eden::RelativePathPiece kSnapshotFile{"SNAPSHOT"};
const facebook::eden::RelativePathPiece kOverlayDir{"local"};
@ -175,6 +189,12 @@ std::unique_ptr<CheckoutConfig> CheckoutConfig::loadFromClientDirectory(
config->repoType_ = *repository->get_as<std::string>(kRepoTypeKey.str());
config->repoSource_ = *repository->get_as<std::string>(kRepoSourceKey.str());
auto mountProtocol = repository->get_as<std::string>(kMountProtocol.str())
.value_or(kMountProtocolDefault);
config->mountProtocol_ = mountProtocol == kMountProtocolNFS
? MountProtocol::NFS
: (folly::kIsWindows ? MountProtocol::PRJFS : MountProtocol::FUSE);
// Read optional case-sensitivity.
auto caseSensitive = repository->get_as<bool>(kRepoCaseSensitiveKey.str());
config->caseSensitive_ =

View File

@ -20,6 +20,12 @@
namespace facebook {
namespace eden {
enum class MountProtocol {
FUSE,
PRJFS,
NFS,
};
/**
* CheckoutConfig contains the configuration state for a single Eden checkout.
*
@ -83,6 +89,13 @@ class CheckoutConfig {
return repoType_;
}
/**
* Get the channel type that this mount should be using.
*/
MountProtocol getMountProtocol() const {
return mountProtocol_;
}
/**
* Get the repository source.
*
@ -115,6 +128,7 @@ class CheckoutConfig {
const AbsolutePath mountPath_;
std::string repoType_;
std::string repoSource_;
MountProtocol mountProtocol_;
bool caseSensitive_{!folly::kIsWindows};
#ifdef _WIN32
Guid repoGuid_;