-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
appFs - introduce telemetry::appFs library for managing FUSE filesyst…
…em with telemetry librabry integration This commit introduces the telemetry::appFs library, which seamlessly integrates with the telemetry library to simplify the management of FUSE (Filesystem in Userspace) filesystems.
- Loading branch information
1 parent
076e70e
commit 0b64a8b
Showing
5 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* @file | ||
* @brief Definition of the AppFsFuse class for managing FUSE filesystem | ||
* @author Pavel Siska <siska@cesnet.cz> | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <fuse3/fuse.h> | ||
#include <memory> | ||
#include <string> | ||
#include <telemetry.hpp> | ||
#include <thread> | ||
|
||
namespace telemetry::appFs { | ||
|
||
/** | ||
* @brief The AppFsFuse class for managing FUSE filesystem. | ||
*/ | ||
class AppFsFuse { | ||
public: | ||
/** | ||
* @brief Constructor for AppFsFuse. | ||
* | ||
* @param rootDirectory A shared pointer to the telemetry root directory. | ||
* | ||
* @throws std::runtime_error if rootDirectory is nullptr. | ||
*/ | ||
AppFsFuse(std::shared_ptr<Directory> rootDirectory); | ||
|
||
/** | ||
* @brief Sets up and mounts the FUSE filesystem. | ||
* | ||
* This method sets up the FUSE filesystem with the provided mount point directory path. | ||
* It creates a new thread to run the FUSE event loop. | ||
* | ||
* @param mountPoint The mount point directory path. | ||
* @param tryToUnmountOnStart Whether to attempt unmounting the mount point if it's already | ||
* mounted. | ||
* | ||
* @throws std::runtime_error if setup and mount process fails. | ||
*/ | ||
void setupAndMount(const std::string& mountPoint, bool tryToUnmountOnStart = true); | ||
|
||
/** | ||
* @brief Unmounts the FUSE filesystem. | ||
* | ||
* This method unmounts the FUSE filesystem. It interrupts the FUSE event loop. | ||
* | ||
* @note This method is also called automatically when the AppFsFuse instance is destroyed. | ||
*/ | ||
void unmount(); | ||
|
||
/** | ||
* @brief Destructor for AppFsFuse. | ||
* | ||
* Terminates the thread running the loop. | ||
* | ||
* @note This method unmounts the FUSE filesystem. | ||
*/ | ||
~AppFsFuse(); | ||
|
||
private: | ||
std::unique_ptr<struct fuse, decltype(&fuse_destroy)> m_fuse {nullptr, &fuse_destroy}; | ||
std::shared_ptr<Directory> m_rootDirectory; | ||
std::thread m_fuseThread; | ||
}; | ||
|
||
} // namespace telemetry::appFs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
add_subdirectory(telemetry) | ||
add_subdirectory(appFs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
list(APPEND APPFS_SOURCE_FILES | ||
appFs.cpp | ||
) | ||
|
||
if (TELEMETRY_BUILD_SHARED) | ||
add_library(appFs SHARED ${APPFS_SOURCE_FILES}) | ||
else() | ||
add_library(appFs STATIC ${APPFS_SOURCE_FILES}) | ||
endif() | ||
|
||
add_library(telemetry::appFs ALIAS appFs) | ||
|
||
target_compile_definitions(appFs PUBLIC FUSE_USE_VERSION=30 _FILE_OFFSET_BITS=64) | ||
target_link_libraries(appFs PUBLIC telemetry PkgConfig::fuse) | ||
target_include_directories(appFs PUBLIC ${CMAKE_SOURCE_DIR}/include) | ||
|
||
if (TELEMETRY_INSTALL_TARGETS) | ||
install(TARGETS appFs LIBRARY DESTINATION ${INSTALL_DIR_LIB}) | ||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION ${INSTALL_DIR_INCLUDE}) | ||
endif() |
Oops, something went wrong.