mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
ca929bcfa5
Summary: This is pretty simplistic: we just wlock and add a delta for the set of file(s) that were changed in a given fuse operation (this is typically 1 file, but rename affects 2). To reduce boilerplate very slightly, I've added an initializer_list constructor for JournalDelta that makes it less cumbersome to create a JournalDelta for a list of files. Reviewed By: simpkins Differential Revision: D3866053 fbshipit-source-id: cd918e2c98c022d5ef79430cd8ab4aef88875239
107 lines
2.8 KiB
C++
107 lines
2.8 KiB
C++
/*
|
|
* Copyright (c) 2016, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <folly/Synchronized.h>
|
|
#include <memory>
|
|
#include "eden/fs/journal/JournalDelta.h"
|
|
#include "eden/utils/PathFuncs.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
namespace fusell {
|
|
class MountPoint;
|
|
}
|
|
|
|
class BindMount;
|
|
class ClientConfig;
|
|
class ObjectStore;
|
|
class Overlay;
|
|
class Journal;
|
|
|
|
/*
|
|
* EdenMount contains all of the data about a specific eden mount point.
|
|
*
|
|
* This contains:
|
|
* - The fusell::MountPoint object which manages our FUSE interactions with the
|
|
* kernel.
|
|
* - The ObjectStore object used for retreiving/storing object data.
|
|
* - The Overlay object used for storing local changes (that have not been
|
|
* committed/snapshotted yet).
|
|
*/
|
|
class EdenMount {
|
|
public:
|
|
EdenMount(
|
|
std::shared_ptr<fusell::MountPoint> mountPoint,
|
|
std::unique_ptr<ObjectStore> objectStore,
|
|
std::shared_ptr<Overlay> overlay,
|
|
std::unique_ptr<const ClientConfig> clientConfig);
|
|
virtual ~EdenMount();
|
|
|
|
/*
|
|
* Get the MountPoint object.
|
|
*
|
|
* This returns a raw pointer since the EdenMount owns the mount point.
|
|
* The caller should generally maintain a reference to the EdenMount object,
|
|
* and not directly to the MountPoint object itself.
|
|
*/
|
|
fusell::MountPoint* getMountPoint() const {
|
|
return mountPoint_.get();
|
|
}
|
|
|
|
/*
|
|
* Return the path to the mount point.
|
|
*/
|
|
const AbsolutePath& getPath() const;
|
|
|
|
/*
|
|
* Return bind mounts that are applied for this mount. These are based on the
|
|
* state of the ClientConfig when this EdenMount was created.
|
|
*/
|
|
const std::vector<BindMount>& getBindMounts() const;
|
|
|
|
/*
|
|
* Return the ObjectStore used by this mount point.
|
|
*
|
|
* The ObjectStore is guaranteed to be valid for the lifetime of the
|
|
* EdenMount.
|
|
*/
|
|
ObjectStore* getObjectStore() const {
|
|
return objectStore_.get();
|
|
}
|
|
|
|
const std::shared_ptr<Overlay>& getOverlay() const {
|
|
return overlay_;
|
|
}
|
|
|
|
folly::Synchronized<Journal>& getJournal() {
|
|
return journal_;
|
|
}
|
|
|
|
private:
|
|
// Forbidden copy constructor and assignment operator
|
|
EdenMount(EdenMount const&) = delete;
|
|
EdenMount& operator=(EdenMount const&) = delete;
|
|
|
|
std::shared_ptr<fusell::MountPoint> mountPoint_;
|
|
std::unique_ptr<ObjectStore> objectStore_;
|
|
std::shared_ptr<Overlay> overlay_;
|
|
|
|
/*
|
|
* Note that this config will not be updated if the user modifies the
|
|
* underlying config files after the ClientConfig was created.
|
|
*/
|
|
const std::unique_ptr<const ClientConfig> clientConfig_;
|
|
|
|
folly::Synchronized<Journal> journal_;
|
|
};
|
|
}
|
|
}
|