Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Attributes | List of all members
ImageManager Class Reference

Static Public Member Functions

static bool checkFSImage (const std::string &filepath, uid_t userId, const std::string &fs, bool fix=true)
 Checks if the given fs image exists and is mountable.
 
static bool checkFSImageAt (int dirFd, const std::string &filepath, uid_t userId, const std::string &fs, bool fix=true)
 
static bool createFSImage (const std::string &filepath, uid_t userId, size_t size, const std::string &fs)
 Create a filesystem image of the given size and format.
 
static bool createFSImageAt (int dirFd, const std::string &filepath, uid_t userId, size_t size, const std::string &fs)
 
static void deleteFSImage (const std::string &filepath)
 Removes a package's private data image file.
 
static void deleteFSImageAt (int dirFd, const std::string &filepath)
 

Static Private Attributes

static const std::string xAttrUserIdName = "user.storage.plugin"
 

Member Function Documentation

◆ checkFSImage()

bool ImageManager::checkFSImage ( const std::string &  filepath,
uid_t  userId,
const std::string &  fs,
bool  fix = true 
)
static

Checks if the given fs image exists and is mountable.

The function will fail in the following cases:

  • the image file doesn't exist
  • xattr are supported and the value for the "user.storage.plugin" doesn't match the supplied userId
  • the image file exists but fsck.ext failed and it couldn't correct the errors

If the file system image existed and fsck validated (or repaired) it, true is returned.

Parameters
[in]filepathThe fully qualified path to the filesystem image
[in]userIdThe expected user id set in the xattr of the image file
[in]fixIf true and the filesystem image exists but is corrupt it will attempt to fix the corruption.
Returns
true on success and false on the failure.

◆ createFSImage()

bool ImageManager::createFSImage ( const std::string &  filepath,
uid_t  userId,
size_t  size,
const std::string &  fs 
)
static

Create a filesystem image of the given size and format.

This function creates an empty file of the given size and then uses one of the mkfs tools to write a file system structure into the file.

Warning
If this function aborts in the middle of the process there is a possibility it could leak temporary files. Some sort of clean-up needs be down at start-up to remove previous temporary files.
Parameters
[in]filepathThe fully qualified path to the filesystem image
[in]userIdThe user id to set set in the xattr of the image
[in]sizeThis size of the image to create in bytes
[in]fsThe filesystem type of image file (ext4)
Returns
true on success and false on the failure.

◆ deleteFSImage()

void ImageManager::deleteFSImage ( const std::string &  filepath)
static

Removes a package's private data image file.

Simply a wrapper around the unlink call.

Parameters
[in]filepathThe fully qualified path to the filesystem image

The documentation for this class was generated from the following files: