#include "distortos/FileSystem/littlefs1/Littlefs1FileSystem.hpp"
|
constexpr | Littlefs1FileSystem (devices::MemoryTechnologyDevice &memoryTechnologyDevice, const size_t readBlockSize={}, const size_t programBlockSize={}, const size_t eraseBlockSize={}, const size_t blocksCount={}, const size_t lookahead=32 *16) |
| Littlefs1FileSystem's constructor. More...
|
|
| ~Littlefs1FileSystem () override |
| Littlefs1FileSystem's destructor. More...
|
|
int | format () override |
| Formats associated device with the file system. More...
|
|
int | getFileStatus (const char *path, struct stat &status) override |
| Returns status of file. More...
|
|
int | getStatus (struct statvfs &status) override |
| Returns status of file system. More...
|
|
void | lock () override |
| Locks the file system for exclusive use by current thread. More...
|
|
int | makeDirectory (const char *path, mode_t mode) override |
| Makes a directory. More...
|
|
int | mount () override |
| Mounts file system on associated device. More...
|
|
std::pair< int, std::unique_ptr< Directory > > | openDirectory (const char *path) override |
| Opens directory. More...
|
|
std::pair< int, std::unique_ptr< File > > | openFile (const char *path, int flags) override |
| Opens file. More...
|
|
int | remove (const char *path) override |
| Removes file or directory. More...
|
|
int | rename (const char *path, const char *newPath) override |
| Renames file or directory. More...
|
|
void | unlock () override |
| Unlocks the file system which was previously locked by current thread. More...
|
|
int | unmount () override |
| Unmounts file system from associated device. More...
|
|
virtual | ~FileSystem ()=default |
| FileSystem's destructor. More...
|
|
| FileSystem (const FileSystem &)=delete |
|
FileSystem & | operator= (const FileSystem &)=delete |
|
|
class | Littlefs1Directory |
|
class | Littlefs1File |
|
◆ Littlefs1FileSystem()
constexpr distortos::Littlefs1FileSystem::Littlefs1FileSystem |
( |
devices::MemoryTechnologyDevice & |
memoryTechnologyDevice, |
|
|
const size_t |
readBlockSize = {} , |
|
|
const size_t |
programBlockSize = {} , |
|
|
const size_t |
eraseBlockSize = {} , |
|
|
const size_t |
blocksCount = {} , |
|
|
const size_t |
lookahead = 32 * 16 |
|
) |
| |
|
inlineexplicit |
Littlefs1FileSystem's constructor.
- Parameters
-
[in] | memoryTechnologyDevice | is a reference to memory technology device on which the file system will be mounted |
[in] | readBlockSize | is the read block size, bytes, 0 to use default value of device, default - 0 |
[in] | programBlockSize | is the program block size, bytes, 0 to use default value of device, default - 0 |
[in] | eraseBlockSize | is the erase block size, bytes, 0 to use default value of device, default - 0 |
[in] | blocksCount | is the number of erase blocks used for file system, 0 to use max value of device, default - 0 |
[in] | lookahead | is the number of blocks to lookahead during block allocation, default - 512 |
◆ ~Littlefs1FileSystem()
distortos::Littlefs1FileSystem::~Littlefs1FileSystem |
( |
| ) |
|
|
override |
Littlefs1FileSystem's destructor.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is unmounted.
◆ format()
int distortos::Littlefs1FileSystem::format |
( |
| ) |
|
|
overridevirtual |
Formats associated device with the file system.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is unmounted.
- Returns
- 0 on success, error code otherwise:
- ENOMEM - unable to allocate memory for file system;
- converted error codes returned by lfs1_format();
- error codes returned by MemoryTechnologyDevice::open();
Implements distortos::FileSystem.
◆ getFileStatus()
int distortos::Littlefs1FileSystem::getFileStatus |
( |
const char * |
path, |
|
|
struct stat & |
status |
|
) |
| |
|
overridevirtual |
Returns status of file.
Similar to stat()
st_mode
field is set in all cases, st_size
field is set only for regular files. All other fields are zero-initialized.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
-
path is valid.
- Parameters
-
[in] | path | is the path to file for which status should be returned, must be valid |
[out] | status | is a reference to stat struct into which status of file will be written |
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_stat();
Implements distortos::FileSystem.
◆ getStatus()
int distortos::Littlefs1FileSystem::getStatus |
( |
struct statvfs & |
status | ) |
|
|
overridevirtual |
Returns status of file system.
Similar to statvfs()
f_bsize
, f_frsize
, f_blocks
, f_bfree
, f_bavail
and f_namemax
fields are set in all cases. All other fields are zero-initialized.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
- Parameters
-
[out] | status | is a reference to statvfs struct into which status of file system will be written |
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_traverse();
Implements distortos::FileSystem.
◆ lock()
void distortos::Littlefs1FileSystem::lock |
( |
| ) |
|
|
overridevirtual |
Locks the file system for exclusive use by current thread.
When the object is locked, any call to any member function from other thread will be blocked until the object is unlocked. Locking is optional, but may be useful when more than one operation must be done atomically.
- Note
- Locks are recursive.
- Warning
- This function must not be called from interrupt context!
- Precondition
- The number of recursive locks of file system is less than 65535.
- Postcondition
- File system is locked.
Implements distortos::FileSystem.
◆ makeDirectory()
int distortos::Littlefs1FileSystem::makeDirectory |
( |
const char * |
path, |
|
|
mode_t |
mode |
|
) |
| |
|
overridevirtual |
Makes a directory.
Similar to mkdir()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
-
path is valid.
- Parameters
-
[in] | path | is the path of the directory that will be created, must be valid |
[in] | mode | is the value of permission bits of the created directory |
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_mkdir();
Implements distortos::FileSystem.
◆ mount()
int distortos::Littlefs1FileSystem::mount |
( |
| ) |
|
|
overridevirtual |
Mounts file system on associated device.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is unmounted.
- Returns
- 0 on success, error code otherwise:
- ENOMEM - unable to allocate memory for file system;
- converted error codes returned by lfs1_mount();
- error codes returned by MemoryTechnologyDevice::open();
Implements distortos::FileSystem.
◆ openDirectory()
std::pair< int, std::unique_ptr< Directory > > distortos::Littlefs1FileSystem::openDirectory |
( |
const char * |
path | ) |
|
|
overridevirtual |
Opens directory.
Similar to opendir()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
-
path is valid.
- Parameters
-
[in] | path | is the path of directory that will be opened, must be valid |
- Returns
- pair with return code (0 on success, error code otherwise) and
std::unique_ptr
with opened directory; error codes:
Implements distortos::FileSystem.
◆ openFile()
std::pair< int, std::unique_ptr< File > > distortos::Littlefs1FileSystem::openFile |
( |
const char * |
path, |
|
|
int |
flags |
|
) |
| |
|
overridevirtual |
Opens file.
Similar to open()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
-
path is valid.
-
flags are valid.
- Parameters
-
[in] | path | is the path of file that will be opened, must be valid |
[in] | flags | are file status flags, must be valid, for list of available flags and valid combinations see open() |
- Returns
- pair with return code (0 on success, error code otherwise) and
std::unique_ptr
with opened file; error codes:
Implements distortos::FileSystem.
◆ remove()
int distortos::Littlefs1FileSystem::remove |
( |
const char * |
path | ) |
|
|
overridevirtual |
Removes file or directory.
Similar to remove()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
-
path is valid.
- Parameters
-
[in] | path | is the path of file or directory that will be removed, must be valid |
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_remove();
Implements distortos::FileSystem.
◆ rename()
int distortos::Littlefs1FileSystem::rename |
( |
const char * |
path, |
|
|
const char * |
newPath |
|
) |
| |
|
overridevirtual |
Renames file or directory.
Similar to rename()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
-
path and newPath are valid.
- Parameters
-
[in] | path | is the path of file or directory that will be renamed, must be valid |
[in] | newPath | is the new path of file or directory, must be valid |
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_rename();
Implements distortos::FileSystem.
◆ unlock()
void distortos::Littlefs1FileSystem::unlock |
( |
| ) |
|
|
overridevirtual |
Unlocks the file system which was previously locked by current thread.
- Note
- Locks are recursive.
- Warning
- This function must not be called from interrupt context!
- Precondition
- This function is called by the thread that locked the file system.
Implements distortos::FileSystem.
◆ unmount()
int distortos::Littlefs1FileSystem::unmount |
( |
| ) |
|
|
overridevirtual |
Unmounts file system from associated device.
- Note
- Even if error code is returned, the file system must not be used (until it is successfully mounted again).
- Warning
- This function must not be called from interrupt context!
- Precondition
- File system is mounted.
- Postcondition
- File system is unmounted.
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_unmount();
- error codes returned by MemoryTechnologyDevice::close();
Implements distortos::FileSystem.
◆ blocksCount_
size_t distortos::Littlefs1FileSystem::blocksCount_ |
|
private |
number of erase blocks used for file system, 0 to use max value of device
◆ configuration_
lfs1_config distortos::Littlefs1FileSystem::configuration_ |
|
private |
configuration of littlefs
◆ eraseBlockSize_
size_t distortos::Littlefs1FileSystem::eraseBlockSize_ |
|
private |
erase block size, bytes, 0 to use default value of device
◆ fileSystem_
lfs1_t distortos::Littlefs1FileSystem::fileSystem_ |
|
private |
◆ lookahead_
size_t distortos::Littlefs1FileSystem::lookahead_ |
|
private |
number of blocks to lookahead during block allocation
◆ lookaheadBuffer_
std::unique_ptr<uint8_t[]> distortos::Littlefs1FileSystem::lookaheadBuffer_ |
|
private |
◆ memoryTechnologyDevice_
reference to associated memory technology device
◆ mounted_
bool distortos::Littlefs1FileSystem::mounted_ |
|
private |
tells whether the file system is currently mounted on associated memory technology device (true) or not (false)
◆ mutex_
mutex for serializing access to the object
◆ programBlockSize_
size_t distortos::Littlefs1FileSystem::programBlockSize_ |
|
private |
program block size, bytes, 0 to use default value of device
◆ programBuffer_
std::unique_ptr<uint8_t[]> distortos::Littlefs1FileSystem::programBuffer_ |
|
private |
◆ readBlockSize_
size_t distortos::Littlefs1FileSystem::readBlockSize_ |
|
private |
read block size, bytes, 0 to use default value of device
◆ readBuffer_
std::unique_ptr<uint8_t[]> distortos::Littlefs1FileSystem::readBuffer_ |
|
private |
The documentation for this class was generated from the following files: