diff options
author | Artemis Tosini <lix@artem.ist> | 2024-04-22 17:32:21 +0000 |
---|---|---|
committer | Artemis Tosini <lix@artem.ist> | 2024-04-23 16:17:05 +0000 |
commit | b247ef72dc7bcc857288c0ddcceb3e42f76a78f1 (patch) | |
tree | 01ec226e6f1e030797bde73bac219c2eb87e7c00 /src/libstore/local-store.hh | |
parent | c8c838381d8e76450ffd57b778bb28217b32084d (diff) |
libstore: Create platform LocalStore subclasses
This creates new subclasses of LocalStore for each OS to include
platform-specific functionality. Currently this just includes garbage
collector roots but it could be extended to sandboxing as well.
In order to make sure that the generic LocalStore is not accidentally
constructed, its constructor is protected. A Fallback is provided which
implements no functionality except constructors.
Change-Id: I836a28e90b68309873f75afb83e0f1b2e2c89fb3
Diffstat (limited to 'src/libstore/local-store.hh')
-rw-r--r-- | src/libstore/local-store.hh | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index fe26a0f27..b8d1f02ab 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -127,26 +127,35 @@ private: const PublicKeys & getPublicKeys(); -public: - - /** - * Hack for build-remote.cc. - */ - PathSet locksHeld; +protected: /** * Initialise the local store, upgrading the schema if * necessary. + * Protected so that users don't accidentally create a LocalStore + * instead of a platform's subclass. */ LocalStore(const Params & params); LocalStore(std::string scheme, std::string path, const Params & params); - ~LocalStore(); +public: + + /** + * Hack for build-remote.cc. + */ + PathSet locksHeld; + + virtual ~LocalStore(); static std::set<std::string> uriSchemes() { return {}; } /** + * Create a LocalStore, possibly a platform-specific subclass + */ + static std::shared_ptr<LocalStore> makeLocalStore(const Params & params); + + /** * Implementations of abstract store API methods. */ @@ -330,6 +339,12 @@ private: void findRootsNoTemp(Roots & roots, bool censor); + /** + * Find possible garbage collector roots in a platform-specific manner, + * e.g. by looking in `/proc` or using `lsof` + */ + virtual void findPlatformRoots(UncheckedRoots & unchecked); + void findRuntimeRoots(Roots & roots, bool censor); std::pair<Path, AutoCloseFD> createTempDirInStore(); |