From af2d27a9c47b53728565bac98cbb9788f1ffd426 Mon Sep 17 00:00:00 2001 From: Chris Dinh Date: Fri, 13 Sep 2024 13:25:41 -0700 Subject: [PATCH] Move is_eden_fs_mount to common/utils Summary: Moves is_eden_fs_mount out of watchman into eden/common/utils This function checks if an entry in the mount table is an edenfs mount by seeing if it starts with `edenfs:` The intention is to have a single source of determining what entries are eden mounts to prevent duplicated code TARGETS changes by autodeps Reviewed By: genevievehelsel Differential Revision: D62528347 fbshipit-source-id: b1edf7e811334de815c5255e5d3dc9536d177fb8 --- eden/common/utils/FSDetect.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 eden/common/utils/FSDetect.h diff --git a/eden/common/utils/FSDetect.h b/eden/common/utils/FSDetect.h new file mode 100644 index 0000000..2673adf --- /dev/null +++ b/eden/common/utils/FSDetect.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +#include + +namespace facebook::eden { + +inline bool is_edenfs_fs_type(folly::StringPiece fs_type) { + return !fs_type.empty() && + (fs_type == "edenfs" || fs_type.startsWith("edenfs:")); +} + +inline bool is_edenfs_fs_mount( + folly::StringPiece line_entry, + const std::string& mountPoint) { + return is_edenfs_fs_type(line_entry) && + line_entry.find(mountPoint) != std::string::npos; +} + +} // namespace facebook::eden