23#ifndef STORAGE_HELPER_H
24#define STORAGE_HELPER_H
29#include <netinet/in.h>
51 std::string* loopDevice);
53 const size_t storageSize,
55 const std::string& fileSystem);
57 const std::string& logTag);
58 static std::string
getLoopDevice(
const std::string &backingFile);
59 static int getMountOptions(
const std::list<std::string> &mountOptions);
104 static bool rmdirContents(
int dirFd,
const std::string& path);
109 static bool Test_mkdirRecursive(
const std::string& rootfsPath);
110 static bool Test_openLoopDevice();
111 static bool Test_attachLoopDevice(std::string& imagePath);
112 static bool Test_cleanMountLostAndFound(
const std::string& rootfsPath);
113 static bool Test_checkWriteReadMount(
const std::string& tmpPath);
Help functions for Storage related things.
Definition StorageHelper.h:45
static bool rmdirRecursive(int dirFd, const std::string &path)
Removes a directory and all it's contents.
Definition StorageHelper.cpp:490
static bool attachFileToLoopDevice(int loopFd, int fileFd)
Attempts to attach the file to the loop device.
Definition StorageHelper.cpp:146
static int attachLoopDevice(const std::string &sourceFile, std::string *loopDevice)
Attaches the given file to an available loop device.
Definition StorageHelper.cpp:228
static bool rmdirContents(int dirFd, const std::string &path)
Removes the contents of a directory but leave the actual directory in place.
Definition StorageHelper.cpp:531
static void cleanMountLostAndFound(const std::string &mountPoint, const std::string &logTag)
Logs and deletes any files found in the lost+found directory of the mount point.
Definition StorageHelper.cpp:329
static bool createFileIfNeeded(const std::string &filePath, const size_t storageSize, const uid_t userId, const std::string &fileSystem)
Checks if file exists, if yes return true, if not try to create it. If success return true,...
Definition StorageHelper.cpp:273
static int openLoopDevice(std::string *loopDevice)
Attempts to open an available loop device.
Definition StorageHelper.cpp:60
static bool deleteRecursive(int dirfd, int depth)
Recursive function that deletes everything within the supplied directory (as a descriptor).
Definition StorageHelper.cpp:564
static std::string getLoopDevice(const std::string &backingFile)
Get the loop device for a given backing file.
Definition StorageHelper.cpp:420
static int loopDeviceAssociate(int fileFd, std::string *loopDevPath)
Associates a give file descriptor with a loop device.
Definition StorageHelper.cpp:197