2020-09-23 19:40:09 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "folly/portability/Windows.h"
|
|
|
|
|
2020-09-23 19:40:09 +03:00
|
|
|
#include <ProjectedFSLib.h> // @manual
|
2020-11-14 01:26:17 +03:00
|
|
|
#include "eden/fs/prjfs/Enumerator.h"
|
2020-09-23 19:40:09 +03:00
|
|
|
#include "eden/fs/utils/Guid.h"
|
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
|
|
|
|
|
|
|
namespace folly {
|
|
|
|
template <class T>
|
|
|
|
class Future;
|
|
|
|
} // namespace folly
|
|
|
|
|
|
|
|
namespace facebook::eden {
|
|
|
|
|
|
|
|
class ObjectFetchContext;
|
|
|
|
class EdenStats;
|
|
|
|
|
|
|
|
struct InodeMetadata {
|
|
|
|
// To ensure that the OS has a record of the canonical file name, and not
|
|
|
|
// just whatever case was used to lookup the file, we capture the
|
|
|
|
// relative path here.
|
|
|
|
RelativePath path;
|
|
|
|
size_t size;
|
|
|
|
bool isDir;
|
|
|
|
};
|
|
|
|
|
2020-12-04 20:11:42 +03:00
|
|
|
struct LookupResult {
|
|
|
|
InodeMetadata meta;
|
|
|
|
std::function<void()> incFsRefcount;
|
|
|
|
};
|
|
|
|
|
2021-02-10 22:46:19 +03:00
|
|
|
class PrjfsDispatcher {
|
2020-09-23 19:40:09 +03:00
|
|
|
public:
|
2021-02-10 22:46:19 +03:00
|
|
|
virtual ~PrjfsDispatcher();
|
|
|
|
explicit PrjfsDispatcher(EdenStats* stats);
|
2020-09-23 19:40:09 +03:00
|
|
|
|
|
|
|
EdenStats* getStats() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a directory
|
|
|
|
*/
|
2020-11-14 01:26:17 +03:00
|
|
|
virtual folly::Future<std::vector<FileMetadata>> opendir(
|
2020-09-23 19:40:09 +03:00
|
|
|
RelativePathPiece path,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup the specified file and get its attributes.
|
|
|
|
*/
|
2020-12-04 20:11:42 +03:00
|
|
|
virtual folly::Future<std::optional<LookupResult>> lookup(
|
2020-09-23 19:40:09 +03:00
|
|
|
RelativePath path,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if a file with the given name exist
|
|
|
|
*/
|
|
|
|
virtual folly::Future<bool> access(
|
|
|
|
RelativePath path,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read the file with the given name
|
|
|
|
*
|
|
|
|
* Returns the entire content of the file at path.
|
|
|
|
*
|
|
|
|
* In the future, this will return only what's in between offset and
|
|
|
|
* offset+length.
|
|
|
|
*/
|
|
|
|
virtual folly::Future<std::string> read(
|
|
|
|
RelativePath path,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification sent when a file was created
|
|
|
|
*/
|
|
|
|
virtual folly::Future<folly::Unit> newFileCreated(
|
2020-11-02 23:23:20 +03:00
|
|
|
RelativePath relPath,
|
|
|
|
RelativePath destPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
bool isDirectory,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification sent when a file was ovewritten
|
|
|
|
*/
|
|
|
|
virtual folly::Future<folly::Unit> fileOverwritten(
|
2020-11-02 23:23:20 +03:00
|
|
|
RelativePath relPath,
|
|
|
|
RelativePath destPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
bool isDirectory,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification sent when a file is closed after being modified
|
|
|
|
*/
|
|
|
|
virtual folly::Future<folly::Unit> fileHandleClosedFileModified(
|
2020-11-02 23:23:20 +03:00
|
|
|
RelativePath relPath,
|
|
|
|
RelativePath destPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
bool isDirectory,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification sent when a file is renamed
|
|
|
|
*/
|
|
|
|
virtual folly::Future<folly::Unit> fileRenamed(
|
2020-11-02 23:23:20 +03:00
|
|
|
RelativePath oldPath,
|
|
|
|
RelativePath newPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
bool isDirectory,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification sent prior to renaming a file
|
|
|
|
*
|
|
|
|
* A failure will block the rename operation
|
|
|
|
*/
|
|
|
|
virtual folly::Future<folly::Unit> preRename(
|
2020-11-02 23:23:20 +03:00
|
|
|
RelativePath oldPath,
|
|
|
|
RelativePath newPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
bool isDirectory,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
2020-12-10 18:40:24 +03:00
|
|
|
* Notification sent when a file is being removed
|
2020-09-23 19:40:09 +03:00
|
|
|
*/
|
2020-12-10 18:40:24 +03:00
|
|
|
virtual folly::Future<folly::Unit> fileHandleClosedFileDeleted(
|
2020-11-02 23:23:20 +03:00
|
|
|
RelativePath relPath,
|
|
|
|
RelativePath destPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
bool isDirectory,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification sent prior to creating a hardlink
|
|
|
|
*
|
|
|
|
* A failure will block the hardlink operation
|
|
|
|
*/
|
|
|
|
virtual folly::Future<folly::Unit> preSetHardlink(
|
2020-11-02 23:23:20 +03:00
|
|
|
RelativePath oldPath,
|
|
|
|
RelativePath newPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
bool isDirectory,
|
|
|
|
ObjectFetchContext& context) = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
EdenStats* stats_{nullptr};
|
|
|
|
};
|
|
|
|
} // namespace facebook::eden
|