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. |
Definition at line 214 of file rawfs.c.
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(). |
Definition at line 247 of file rawfs.c.
References free(), _NUTFILE::nf_fcb, and NUTASSERT.

| 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. |
Definition at line 274 of file rawfs.c.
References _NUTDEVICE::dev_dcb, _RAWFILE::f_pos, _RAWFILE::f_sect_num, _RAWFILE::f_sect_pos, memcpy(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, NUTASSERT, _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. |
Definition at line 363 of file rawfs.c.
References _NUTDEVICE::dev_dcb, _RAWFILE::f_pos, _RAWFILE::f_sect_num, _RAWFILE::f_sect_pos, memcpy(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, NUTASSERT, _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. |
Definition at line 498 of file rawfs.c.
References _NUTDEVICE::dev_dcb, free(), 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. |
Definition at line 529 of file rawfs.c.
References _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _NUTDEVICE::dev_ioctl, ENODEV, errno, free(), malloc(), memset(), _NUTFILE::nf_dev, 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).