From 990af745e22a7c5095bc4691574c3dbba44bc501 Mon Sep 17 00:00:00 2001 From: Xavier Deguillard Date: Wed, 3 Feb 2021 16:43:32 -0800 Subject: [PATCH] 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 --- eden/fs/config/CheckoutConfig.cpp | 20 ++++++++++++++++++++ eden/fs/config/CheckoutConfig.h | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/eden/fs/config/CheckoutConfig.cpp b/eden/fs/config/CheckoutConfig.cpp index a91389503a..f83d3b9813 100644 --- a/eden/fs/config/CheckoutConfig.cpp +++ b/eden/fs/config/CheckoutConfig.cpp @@ -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::loadFromClientDirectory( config->repoType_ = *repository->get_as(kRepoTypeKey.str()); config->repoSource_ = *repository->get_as(kRepoSourceKey.str()); + auto mountProtocol = repository->get_as(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(kRepoCaseSensitiveKey.str()); config->caseSensitive_ = diff --git a/eden/fs/config/CheckoutConfig.h b/eden/fs/config/CheckoutConfig.h index 4e135ebf10..c30d87baa4 100644 --- a/eden/fs/config/CheckoutConfig.h +++ b/eden/fs/config/CheckoutConfig.h @@ -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_;