filesystemInterface.hpp (b17f82519d4a912c9bc2aa47499126f4a84aace0) | filesystemInterface.hpp (82897c35761f505c2b881f72c61f726f7d562692) |
---|---|
1#pragma once 2 3#include <sys/mount.h> 4 5#include <filesystem> 6#include <string> 7 8namespace estoraged 9{ 10 11/** @class FilesystemInterface 12 * @brief Interface to the filesystem operations that eStoraged needs. 13 * @details This class is used to mock out the filesystem operations. 14 */ 15class FilesystemInterface 16{ 17 public: 18 virtual ~FilesystemInterface() = default; 19 | 1#pragma once 2 3#include <sys/mount.h> 4 5#include <filesystem> 6#include <string> 7 8namespace estoraged 9{ 10 11/** @class FilesystemInterface 12 * @brief Interface to the filesystem operations that eStoraged needs. 13 * @details This class is used to mock out the filesystem operations. 14 */ 15class FilesystemInterface 16{ 17 public: 18 virtual ~FilesystemInterface() = default; 19 |
20 FilesystemInterface() = default; 21 FilesystemInterface(const FilesystemInterface&) = delete; 22 FilesystemInterface& operator=(const FilesystemInterface&) = delete; 23 24 FilesystemInterface(FilesystemInterface&&) = delete; 25 FilesystemInterface& operator=(FilesystemInterface&&) = delete; 26 |
|
20 /** @brief Runs the mkfs command to create the filesystem. 21 * @details Used for mocking purposes. 22 * 23 * @param[in] logicalVolume - name of the mapped LUKS device. 24 * 25 * @returns 0 on success, nonzero on failure. 26 */ 27 virtual int runMkfs(const std::string& logicalVolume) = 0; --- 53 unchanged lines hidden (view full) --- 81}; 82 83/** @class Filesystem 84 * @brief Implements FilesystemInterface 85 */ 86class Filesystem : public FilesystemInterface 87{ 88 public: | 27 /** @brief Runs the mkfs command to create the filesystem. 28 * @details Used for mocking purposes. 29 * 30 * @param[in] logicalVolume - name of the mapped LUKS device. 31 * 32 * @returns 0 on success, nonzero on failure. 33 */ 34 virtual int runMkfs(const std::string& logicalVolume) = 0; --- 53 unchanged lines hidden (view full) --- 88}; 89 90/** @class Filesystem 91 * @brief Implements FilesystemInterface 92 */ 93class Filesystem : public FilesystemInterface 94{ 95 public: |
89 ~Filesystem() = default; | 96 ~Filesystem() override = default; 97 Filesystem() = default; 98 Filesystem(const Filesystem&) = delete; 99 Filesystem& operator=(const Filesystem&) = delete; |
90 | 100 |
101 Filesystem(Filesystem&&) = delete; 102 Filesystem& operator=(Filesystem&&) = delete; 103 |
|
91 int runMkfs(const std::string& logicalVolume) override 92 { 93 std::string mkfsCommand("mkfs.ext4 /dev/mapper/" + logicalVolume); | 104 int runMkfs(const std::string& logicalVolume) override 105 { 106 std::string mkfsCommand("mkfs.ext4 /dev/mapper/" + logicalVolume); |
107 // calling 'system' uses a command processor //NOLINTNEXTLINE |
|
94 return system(mkfsCommand.c_str()); 95 } 96 97 int doMount(const char* source, const char* target, 98 const char* filesystemtype, unsigned long mountflags, 99 const void* data) override 100 { 101 return mount(source, target, filesystemtype, mountflags, data); --- 23 unchanged lines hidden --- | 108 return system(mkfsCommand.c_str()); 109 } 110 111 int doMount(const char* source, const char* target, 112 const char* filesystemtype, unsigned long mountflags, 113 const void* data) override 114 { 115 return mount(source, target, filesystemtype, mountflags, data); --- 23 unchanged lines hidden --- |