Base class for both Device and FileSystem objects.
More...
#include <Devtab.hxx>
|
| 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.
|
| |
|
| | 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 | fstat (File *file, struct stat *stat)=0 |
| | Get the status information of a file or device.
|
| |
| 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
|
| |
|
|
| DISALLOW_COPY_AND_ASSIGN (FileIO) |
| |
Base class for both Device and FileSystem objects.
Definition at line 72 of file Devtab.hxx.
◆ FileIO()
| FileIO::FileIO |
( |
const char * |
name | ) |
|
|
inlineprotected |
Constructor.
- Parameters
-
| name | name of mount point in the root file system. Pointer must be valid throughout the entire lifetime. |
Definition at line 144 of file Devtab.hxx.
◆ ~FileIO()
| virtual FileIO::~FileIO |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ close()
| virtual int FileIO::close |
( |
File * |
file | ) |
|
|
protectedpure virtual |
◆ fcntl() [1/2]
| int FileIO::fcntl |
( |
File * |
file, |
|
|
int |
cmd, |
|
|
unsigned long |
data |
|
) |
| |
|
protectedvirtual |
Manipulate a file descriptor.
- Parameters
-
| file | file reference for this device |
| cmd | operation to perform |
| data | parameter to the cmd operation |
- Returns
- dependent on the operation (POSIX compliant where applicable) or negative error number upon error.
Reimplemented in Pipe, CC32xxSocket, CC32xxSocket, and FreeRTOSTCPSocket.
Definition at line 310 of file Fileio.cxx.
◆ fcntl() [2/2]
| int FileIO::fcntl |
( |
int |
fd, |
|
|
int |
cmd, |
|
|
unsigned long |
data |
|
) |
| |
|
static |
Manipulate a file descriptor.
- Parameters
-
| fd | file descriptor |
| cmd | operation to perform |
| data | parameter to the cmd operation |
- Returns
- dependent on the operation (POSIX compliant where applicable) or -1 on error with errno set appropriately
Definition at line 233 of file Fileio.cxx.
◆ fd_alloc()
| int FileIO::fd_alloc |
( |
void |
| ) |
|
|
staticprotected |
Allocate a free file descriptor.
This call must be made with the static Device::mutex locked.
- Returns
- file number on success, else -1 on failure
-
file number on success, else -1 on failure
Definition at line 47 of file Fileio.cxx.
◆ fd_free()
| void FileIO::fd_free |
( |
int |
fd | ) |
|
|
staticprotected |
Free up a file descriptor.
- Parameters
-
Definition at line 71 of file Fileio.cxx.
◆ fd_lookup()
| int FileIO::fd_lookup |
( |
File * |
file | ) |
|
|
staticprotected |
Looks up a file descriptor corresponding to a given File reference.
- Parameters
-
| file | is a reference to a File structure. |
- Returns
- file descriptor (assert on error).
Definition at line 101 of file Fileio.cxx.
◆ file_lookup()
| File * FileIO::file_lookup |
( |
int |
fd | ) |
|
|
staticprotected |
Looks up a reference to a File corresponding to a given file descriptor.
- Parameters
-
| fd | is a file descriptor as supplied to the read-write-close-ioctl commands. |
- Returns
- NULL and sets errno if fd is invalid, otherwise the File reference.
Definition at line 82 of file Fileio.cxx.
◆ fstat() [1/2]
| virtual int FileIO::fstat |
( |
File * |
file, |
|
|
struct stat * |
stat |
|
) |
| |
|
protectedpure virtual |
◆ fstat() [2/2]
| int FileIO::fstat |
( |
struct _reent * |
reent, |
|
|
int |
fd, |
|
|
struct stat * |
stat |
|
) |
| |
|
static |
Get the status information of a file or device.
- Parameters
-
| reent | thread safe reentrant structure |
| fd | file descriptor to get status of |
| stat | structure to fill status info into |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 186 of file Fileio.cxx.
◆ ioctl() [1/2]
| int FileIO::ioctl |
( |
File * |
file, |
|
|
unsigned long int |
key, |
|
|
unsigned long |
data |
|
) |
| |
|
protectedvirtual |
Request an ioctl transaction.
- Parameters
-
| file | file reference for this device |
| key | ioctl key |
| data | key data |
- Returns
- 0 upon success or negative error number upon error.
Reimplemented in NonBlockNode, I2C, TCAN4550Can, MCP2515Can, RailcomDriverBase< HW >, RailcomDriverBase< HW >, Serial, Socket, SPI, TCAN4550Can, Stm32Can, Stm32Uart, CC32xxUart, TivaDCC< HW >, TivaUart, TivaCan, and TivaNRZ< HW >.
Definition at line 299 of file Fileio.cxx.
◆ ioctl() [2/2]
| int FileIO::ioctl |
( |
int |
fd, |
|
|
unsigned long int |
key, |
|
|
unsigned long |
data |
|
) |
| |
|
static |
Request and ioctl transaction.
- Parameters
-
| fd | file descriptor |
| key | ioctl key |
| data | key data |
- Returns
- 0 upon success, -1 upon failure with errno containing the cause
Definition at line 209 of file Fileio.cxx.
◆ is_device()
| static bool FileIO::is_device |
( |
int |
fd | ) |
|
|
inlinestatic |
Test if the file descriptor belongs to a device.
- Parameters
-
- Returns
- true if fd belongs to a device, false if belongs to a file system
Definition at line 134 of file Devtab.hxx.
◆ lseek() [1/2]
| off_t FileIO::lseek |
( |
File * |
f, |
|
|
off_t |
offset, |
|
|
int |
whence |
|
) |
| |
|
protectedvirtual |
Seek method.
- Parameters
-
| f | file reference for this device |
| offset | offset in bytes from whence directive |
| whence | SEEK_SET if to set the file offset to an abosolute position, SEEK_CUR if to set the file offset from current position |
- Returns
- current offest or negative error number upon error.
- Parameters
-
| f | file reference for this device |
| offset | offset in bytes from whence directive |
| whence | SEEK_SET if to set the file offset to an abosolute position, SEEK_CUR if to set the file offset from current position |
- Returns
- current offset, or -1 with errno set upon error.
Reimplemented in Pipe, Socket, SPIFFS, and EEPROM.
Definition at line 279 of file Fileio.cxx.
◆ lseek() [2/2]
| _off_t FileIO::lseek |
( |
struct _reent * |
reent, |
|
|
int |
fd, |
|
|
_off_t |
offset, |
|
|
int |
whence |
|
) |
| |
|
static |
Change the offset index of a file or device.
- Parameters
-
| reent | thread save reentrant structure |
| fd | file descriptor to seek |
| offset | offset within file |
| whence | type of seek to complete |
- Returns
- resulting offset from beginning of file, -1 upon failure with errno containing the cause
Definition at line 163 of file Fileio.cxx.
◆ open()
| virtual int FileIO::open |
( |
File * |
file, |
|
|
const char * |
path, |
|
|
int |
flags, |
|
|
int |
mode |
|
) |
| |
|
protectedpure virtual |
◆ read() [1/2]
| virtual ssize_t FileIO::read |
( |
File * |
file, |
|
|
void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
protectedpure virtual |
Read from a file or device.
- Parameters
-
| file | file reference for this device |
| buf | location to place read data |
| count | number of bytes to read |
- Returns
- number of bytes read upon success, -1 upon failure with errno containing the cause
Implemented in Null, TivaFlash, Pic32mxCan, BenchmarkCan, Can, DccDecoder< Module >, DeviceFile, EEPROM, I2C, TCAN4550Can, Pipe, RailcomDriverBase< HW >, RailcomDriverBase< HW >, RamDiskBase, Serial, Socket, SPI, TCAN4550Can, MbedAsyncUSBSerial, Pic32mxCdc, SPIFFS, Stm32RailcomSender, TivaDCC< HW >, TivaNRZ< HW >, TinyUsbCdc, and TivaTestPacketSource< HW >.
◆ read() [2/2]
| ssize_t FileIO::read |
( |
struct _reent * |
reent, |
|
|
int |
fd, |
|
|
void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Read from a file or device.
- Parameters
-
| reent | thread save reentrant structure |
| fd | file descriptor to read |
| buf | location to place read data |
| count | number of bytes to read |
- Returns
- number of bytes read upon success, -1 upon failure with errno containing the cause
- Parameters
-
| reent | thread safe reentrant structure |
| fd | file descriptor to read |
| buf | location to place read data |
| count | number of bytes to read |
- Returns
- number of bytes read upon success, -1 upon failure with errno containing the cause
Definition at line 115 of file Fileio.cxx.
◆ select()
| virtual bool FileIO::select |
( |
File * |
file, |
|
|
int |
mode |
|
) |
| |
|
inlineprotectedvirtual |
Device select method.
Default impementation returns true.
- Parameters
-
| file | reference to the file |
| mode | FREAD for read active, FWRITE for write active, 0 for exceptions |
- Returns
- true if active, false if inactive
Reimplemented in Can, DccDecoder< Module >, TCAN4550Can, Pipe, Serial, Socket, TCAN4550Can, CC32xxSocket, CC32xxSocket, FreeRTOSTCPSocket, Pic32mxCan, Pic32mxCdc, TivaCdc, TivaTestPacketSource< HW >, and TinyUsbCdc.
Definition at line 226 of file Devtab.hxx.
◆ write() [1/2]
| virtual ssize_t FileIO::write |
( |
File * |
file, |
|
|
const void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
protectedpure virtual |
Write to a file or device.
- Parameters
-
| file | file reference for this device |
| buf | location to find write data |
| count | number of bytes to write |
- Returns
- number of bytes written upon success, -1 upon failure with errno containing the cause
Implemented in TivaTestPacketSource< HW >, Null, RailcomDriverBase< HW >, RailcomDriverBase< HW >, TivaFlash, Pic32mxCan, BenchmarkCan, Can, DccDecoder< Module >, DeviceFile, EEPROM, I2C, TCAN4550Can, Pipe, RamDiskBase, Serial, Socket, SPI, TCAN4550Can, MbedAsyncUSBSerial, Pic32mxCdc, SPIFFS, Stm32RailcomSender, TivaDCC< HW >, TivaCdc, TivaNRZ< HW >, and TinyUsbCdc.
◆ write() [2/2]
| ssize_t FileIO::write |
( |
struct _reent * |
reent, |
|
|
int |
fd, |
|
|
const void * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Write to a file or device.
- Parameters
-
| reent | thread save reentrant structure |
| fd | file descriptor to write |
| buf | location to find write data |
| count | number of bytes to write |
- Returns
- number of bytes written upon success, -1 upon failure with errno containing the cause
Definition at line 139 of file Fileio.cxx.
◆ Device
◆ FileSystem
◆ files
◆ mutex
mutual exclusion for fileio
Definition at line 264 of file Devtab.hxx.
◆ name
◆ numOpenFiles
| const unsigned int FileIO::numOpenFiles = 20 |
|
staticprotected |
- Returns
- the maximum number of open file descriptors possible (the size of the files[] array.
Definition at line 258 of file Devtab.hxx.
The documentation for this class was generated from the following files: