Very simple raw file system. More...
Data Structures | |
struct | _RAWVOLUME |
Volume info structure. More... | |
struct | _RAWFILE |
Raw device file descriptor. More... | |
Typedefs | |
typedef struct _RAWVOLUME | RAWVOLUME |
typedef struct _RAWFILE | RAWFILE |
Raw device file descriptor. | |
Functions | |
NUTFILE * | RawFsFileOpen (NUTDEVICE *dev, const char *path, int mode, int acc) |
Open a raw file. | |
int | RawFsFileClose (NUTFILE *nfp) |
Close a raw file. | |
int | RawFsFileWrite (NUTFILE *nfp, const void *buffer, int len) |
Write data to a file. | |
int | RawFsFileWrite_P (NUTFILE *nfp, PGM_P buffer, int len) |
Write data from program space to a file. | |
int | RawFsFileRead (NUTFILE *nfp, void *buffer, int size) |
Read data from a file. | |
int | RawFsUnmount (NUTDEVICE *dev) |
Unmount a raw volume. | |
int | RawFsMount (NUTDEVICE *dev, NUTFILE *blkmnt, uint8_t part_type) |
Mount a raw volume. | |
Variables | |
NUTDEVICE | devRawFs0 |
Raw device file system driver information structure. |
Very simple raw file system.
typedef struct _RAWVOLUME RAWVOLUME |
Open a raw file.
This function is called by the low level open routine of the C runtime library, using the _NUTDEVICE::dev_open entry.
dev | Specifies the file system device. |
path | Pathname of the file to open which is ignored here, because the raw file system doesn't support multiple file entries. |
mode | Operation mode. |
acc | File attribute, ignored. |
References _RAWFILE::f_mode, free(), malloc(), memset(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, and NUTFILE_EOF.
int RawFsFileClose | ( | NUTFILE * | nfp | ) |
Close a raw file.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen(). |
References free(), _NUTFILE::nf_fcb, NULL, NUTASSERT, and rc.
int RawFsFileWrite | ( | NUTFILE * | nfp, |
const void * | buffer, | ||
int | len | ||
) |
Write data to a file.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen(). |
buffer | Pointer to the data to be written. If zero, then the output buffer will be flushed. |
len | Number of bytes to write. |
References _NUTDEVICE::dev_dcb, _RAWFILE::f_pos, _RAWFILE::f_sect_num, _RAWFILE::f_sect_pos, memcpy(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, NULL, NUTASSERT, rc, _RAWVOLUME::vol_sect_buf, _RAWVOLUME::vol_sect_dirty, and _RAWVOLUME::vol_sect_len.
int RawFsFileWrite_P | ( | NUTFILE * | nfp, |
PGM_P | buffer, | ||
int | len | ||
) |
Write data from program space to a file.
This function is not yet implemented and will always return -1.
Similar to RawFsFileWrite() except that the data is located in program memory.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen(). |
buffer | Pointer to the data in program space. If zero, then the output buffer will be flushed. |
len | Number of bytes to write. |
int RawFsFileRead | ( | NUTFILE * | nfp, |
void * | buffer, | ||
int | size | ||
) |
Read data from a file.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen(). |
buffer | Pointer to the data buffer to fill. |
size | Maximum number of bytes to read. |
References _NUTDEVICE::dev_dcb, _RAWFILE::f_pos, _RAWFILE::f_sect_num, _RAWFILE::f_sect_pos, memcpy(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, NULL, NUTASSERT, rc, _RAWVOLUME::vol_sect_buf, and _RAWVOLUME::vol_sect_len.
int RawFsUnmount | ( | NUTDEVICE * | dev | ) |
Unmount a raw volume.
This routine is called by the block device driver while unmounting a partition.
dev | Specifies the file system device. |
References _NUTDEVICE::dev_dcb, free(), NULL, and NUTASSERT.
Mount a raw volume.
This routine is called by the block device driver while mounting a partition.
The routine may also initializes any caching mechanism. Thus, it must be called before any other read or write access.
dev | Specifies the file system device. |
blkmnt | Handle of the block device's partition mount. |
part_type | Partition type, ignored. |
References _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _NUTDEVICE::dev_ioctl, ENODEV, errno, free(), malloc(), memset(), _NUTFILE::nf_dev, NULL, NUTASSERT, NUTBLKDEV_INFO, NutEventPost(), _BLKPAR_INFO::par_blkbp, _BLKPAR_INFO::par_blksz, _BLKPAR_INFO::par_nblks, _BLKPAR_INFO::par_nfp, _RAWVOLUME::vol_fsmutex, _RAWVOLUME::vol_iomutex, _RAWVOLUME::vol_sect_buf, _RAWVOLUME::vol_sect_cnt, _RAWVOLUME::vol_sect_len, and _RAWVOLUME::vol_sect_num.
{ 0, {'R', 'A', 'W', 'F', 'S', '0', 0, 0, 0} , IFTYP_FS, 0, 0, 0, 0, RawFsInit, RawFsApiIOCtl, RawFsApiFileRead, RawFsApiFileWrite, RawFsApiFileWrite_P, RawFsApiFileOpen, RawFsApiFileClose, RawFsFileSize }
Raw device file system driver information structure.
A pointer to this structure must be passed to NutRegisterDevice() to bind this file system driver to the Nut/OS kernel. An application may then call /verbatim _open("AT45D0:0/RAWFS0", _O_RDWR | _O_BINARY); /endverbatim to mount the file system on the previously registered block device (devSpiAt45d0 in this example).