Base class for all File systems.
More...
#include <Devtab.hxx>
|
| | FileSystem () |
| | Constructor.
|
| |
| virtual | ~FileSystem () |
| | Destructor.
|
| |
| virtual void | mount (const char *mount_point)=0 |
| | Mount the file system.
|
| |
| virtual void | format ()=0 |
| | Format the file system, all data will be lost.
|
| |
|
| static int | open (struct _reent *reent, const char *path, int flags, int mode) |
| | Open a file or device.
|
| |
| static int | close (struct _reent *reent, int fd) |
| | Close a file or device.
|
| |
| static int | unlink (struct _reent *reent, const char *path) |
| | Remove a file.
|
| |
| static int | stat (struct _reent *reent, const char *path, struct stat *stat) |
| | Get the status information of a file or device.
|
| |
| static int | fsync (int fd) |
| | Synchronize (flush) a file to disk.
|
| |
| static int | closedir (DIR *dirp) |
| | Close a directory.
|
| |
| static DIR * | opendir (const char *name) |
| | Open a directory.
|
| |
| static struct dirent * | readdir (DIR *dirp) |
| | Read the next entry in a directory.
|
| |
| static ssize_t | read (struct _reent *reent, int fd, void *buf, size_t count) |
| | Read from a file or device.
|
| |
| static ssize_t | write (struct _reent *reent, int fd, const void *buf, size_t count) |
| | Write to a file or device.
|
| |
| static _off_t | lseek (struct _reent *reent, int fd, _off_t offset, int whence) |
| | Change the offset index of a file or device.
|
| |
| static int | fstat (struct _reent *reent, int fd, struct stat *stat) |
| | Get the status information of a file or device.
|
| |
| static int | ioctl (int fd, unsigned long int key, unsigned long data) |
| | Request and ioctl transaction.
|
| |
| static int | fcntl (int fd, int cmd, unsigned long data) |
| | Manipulate a file descriptor.
|
| |
| static bool | is_device (int fd) |
| | Test if the file descriptor belongs to a device.
|
| |
|
| virtual int | unlink (const char *path)=0 |
| | Remove a file.
|
| |
| virtual int | fstat (File *file, struct stat *stat) override |
| | Get the status information of a file or device.
|
| |
| virtual int | stat (const char *path, struct stat *stat)=0 |
| | Get the status information of a file or device.
|
| |
| virtual int | fsync (File *file)=0 |
| | Synchronize (flush) a file to disk.
|
| |
| virtual int | closedir (File *file)=0 |
| | Close a directory.
|
| |
| virtual File * | opendir (File *file, const char *name)=0 |
| | Open a directory.
|
| |
| virtual struct dirent * | readdir (File *file)=0 |
| | Read the next entry in a directory.
|
| |
| | FileIO (const char *name) |
| | Constructor.
|
| |
| virtual | ~FileIO () |
| | Destructor.
|
| |
| virtual int | open (File *file, const char *path, int flags, int mode)=0 |
| | Open a file or device.
|
| |
| virtual int | close (File *file)=0 |
| | Close a file or device.
|
| |
| virtual ssize_t | read (File *file, void *buf, size_t count)=0 |
| | Read from a file or device.
|
| |
| virtual ssize_t | write (File *file, const void *buf, size_t count)=0 |
| | Write to a file or device.
|
| |
| virtual off_t | lseek (File *f, off_t offset, int whence) |
| | Seek method.
|
| |
| virtual int | ioctl (File *file, unsigned long int key, unsigned long data) |
| | Request an ioctl transaction.
|
| |
| virtual int | fcntl (File *file, int cmd, unsigned long data) |
| | Manipulate a file descriptor.
|
| |
| virtual bool | select (File *file, int mode) |
| | Device select method.
|
| |
|
| static int | fd_alloc (void) |
| | Allocate a free file descriptor.
|
| |
| static void | fd_free (int fd) |
| | Free up a file descriptor.
|
| |
| static File * | file_lookup (int fd) |
| | Looks up a reference to a File corresponding to a given file descriptor.
|
| |
| static int | fd_lookup (File *file) |
| | Looks up a file descriptor corresponding to a given File reference.
|
| |
| const char * | name |
| | device name
|
| |
| static const unsigned int | numOpenFiles = 20 |
| |
| static File | files [] |
| | File descriptor pool.
|
| |
| static OSMutex | mutex |
| | mutual exclusion for fileio
|
| |
Base class for all File systems.
Definition at line 279 of file Devtab.hxx.
◆ FileSystem()
| FileSystem::FileSystem |
( |
| ) |
|
◆ ~FileSystem()
| FileSystem::~FileSystem |
( |
| ) |
|
|
virtual |
◆ close()
| int FileSystem::close |
( |
struct _reent * |
reent, |
|
|
int |
fd |
|
) |
| |
|
static |
Close a file or device.
- Parameters
-
| reent | thread save reentrant structure |
| fd | file descriptor to close |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 159 of file FileSystem.cxx.
◆ closedir() [1/2]
| int FileSystem::closedir |
( |
DIR * |
dirp | ) |
|
|
static |
Close a directory.
- Parameters
-
dirp directory pointer to close
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 269 of file FileSystem.cxx.
◆ closedir() [2/2]
| virtual int FileSystem::closedir |
( |
File * |
file | ) |
|
|
protectedpure virtual |
Close a directory.
- Parameters
-
| file | file reference for this device |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Implemented in SPIFFS.
◆ format()
| virtual void FileSystem::format |
( |
| ) |
|
|
pure virtual |
Format the file system, all data will be lost.
The file system must not be mounted at the time of calling this.
Implemented in SPIFFS.
◆ fs_lookup()
| FileSystem * FileSystem::fs_lookup |
( |
const char * |
path | ) |
|
|
staticprivate |
Locate the file system for a given path.
- Parameters
-
| path | full path to file/directory |
- Returns
- reference to file system on success, else nullptr
Definition at line 81 of file FileSystem.cxx.
◆ fstat()
| int FileSystem::fstat |
( |
File * |
file, |
|
|
struct stat * |
stat |
|
) |
| |
|
overrideprotectedvirtual |
Get the status information of a file or device.
- Parameters
-
| file | file reference for this device |
| stat | structure to fill status info into |
- Returns
- 0 upon successor or negative error number upon error.
Implements FileIO.
Reimplemented in SPIFFS.
Definition at line 236 of file FileSystem.cxx.
◆ fsync() [1/2]
| virtual int FileSystem::fsync |
( |
File * |
file | ) |
|
|
protectedpure virtual |
Synchronize (flush) a file to disk.
- Parameters
-
| file | file reference for this device |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Implemented in SPIFFS.
◆ fsync() [2/2]
| int FileSystem::fsync |
( |
int |
fd | ) |
|
|
static |
Synchronize (flush) a file to disk.
- Parameters
-
| fd | file descriptor to sync |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 246 of file FileSystem.cxx.
◆ mount()
| virtual void FileSystem::mount |
( |
const char * |
mount_point | ) |
|
|
pure virtual |
Mount the file system.
- Parameters
-
| mount_point | path in the root file system for the mount point Must not contain any trailing '/' characters, e.g. "/usr", not "/usr/". Unlike in linux, each mount must be entirely unique point in the system. For example, mounting of both "/usr" and "/usr/bin" is is not supported. However, "/usr" and "/usr1" is supported. This saves on file open logic. |
Implemented in SPIFFS.
◆ open()
| int FileSystem::open |
( |
struct _reent * |
reent, |
|
|
const char * |
path, |
|
|
int |
flags, |
|
|
int |
mode |
|
) |
| |
|
static |
Open a file or device.
- Parameters
-
| reent | thread save reentrant structure |
| path | file or device name |
| flags | open flags |
| mode | open mode, ignored in this implementation |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 119 of file FileSystem.cxx.
◆ opendir() [1/2]
| DIR * FileSystem::opendir |
( |
const char * |
name | ) |
|
|
static |
Open a directory.
- Parameters
-
- Returns
- pointer to the open directory on success, NULL on error
Definition at line 291 of file FileSystem.cxx.
◆ opendir() [2/2]
| virtual File * FileSystem::opendir |
( |
File * |
file, |
|
|
const char * |
name |
|
) |
| |
|
protectedpure virtual |
Open a directory.
- Parameters
-
| file | file reference for this device |
| name | directory path |
- Returns
- pointer to the open directory on success, NULL on error
Implemented in SPIFFS.
◆ readdir() [1/2]
| struct dirent * FileSystem::readdir |
( |
DIR * |
dirp | ) |
|
|
static |
Read the next entry in a directory.
- Parameters
-
| dirp | directory pointer to read. |
- Returns
- pointer to a struct dirent representing the next directectory entry
Definition at line 325 of file FileSystem.cxx.
◆ readdir() [2/2]
| virtual struct dirent * FileSystem::readdir |
( |
File * |
file | ) |
|
|
protectedpure virtual |
Read the next entry in a directory.
- Parameters
-
| file | file reference for this device |
- Returns
- pointer to a struct dirent representing the next directectory entry
Implemented in SPIFFS.
◆ stat() [1/2]
| virtual int FileSystem::stat |
( |
const char * |
path, |
|
|
struct stat * |
stat |
|
) |
| |
|
protectedpure virtual |
Get the status information of a file or device.
- Parameters
-
| path | file or device name |
| stat | structure to fill status info into |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Implemented in SPIFFS.
◆ stat() [2/2]
| int FileSystem::stat |
( |
struct _reent * |
reent, |
|
|
const char * |
path, |
|
|
struct stat * |
stat |
|
) |
| |
|
static |
Get the status information of a file or device.
- Parameters
-
| reent | thread safe reentrant structure |
| path | file or device name |
| stat | structure to fill status info into |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
- Parameters
-
| reent | thread save reentrant structure |
| path | file or device name |
| stat | structure to fill status info into |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 212 of file FileSystem.cxx.
◆ unlink() [1/2]
| virtual int FileSystem::unlink |
( |
const char * |
path | ) |
|
|
protectedpure virtual |
Remove a file.
- Parameters
-
- Returns
- 0 upon successor or negative error number upon error.
Implemented in SPIFFS.
◆ unlink() [2/2]
| int FileSystem::unlink |
( |
struct _reent * |
reent, |
|
|
const char * |
path |
|
) |
| |
|
static |
Remove a file.
- Parameters
-
| reent | thread safe reentrant structure |
| path | file name |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 187 of file FileSystem.cxx.
◆ first
first device in linked list
Definition at line 417 of file Devtab.hxx.
◆ next
next device in linked list
Definition at line 420 of file Devtab.hxx.
◆ prev
previous device in linked list
Definition at line 423 of file Devtab.hxx.
The documentation for this class was generated from the following files: