Nut/OS  5.0.5
API Reference
Raw File System

Very simple raw file system. More...

Collaboration diagram for Raw File System:

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

NUTFILERawFsFileOpen (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.

Detailed Description

Very simple raw file system.


Typedef Documentation

typedef struct _RAWVOLUME RAWVOLUME
typedef struct _RAWFILE RAWFILE

Raw device file descriptor.


Function Documentation

NUTFILE* RawFsFileOpen ( NUTDEVICE dev,
const char *  path,
int  mode,
int  acc 
)

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.

Parameters:
devSpecifies the file system device.
pathPathname of the file to open which is ignored here, because the raw file system doesn't support multiple file entries.
modeOperation mode.
accFile attribute, ignored.
Returns:
Pointer to a NUTFILE structure if successful or NUTFILE_EOF otherwise.
Bug:
Append mode not working as expected.

References _RAWFILE::f_mode, free(), malloc(), memset(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, and NUTFILE_EOF.

Here is the call graph for this function:

int RawFsFileClose ( NUTFILE nfp)

Close a raw file.

Parameters:
nfpPointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen().
Returns:
0 on success, -1 otherwise.

References free(), _NUTFILE::nf_fcb, NULL, NUTASSERT, and rc.

Here is the call graph for this function:

int RawFsFileWrite ( NUTFILE nfp,
const void *  buffer,
int  len 
)

Write data to a file.

Parameters:
nfpPointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen().
bufferPointer to the data to be written. If zero, then the output buffer will be flushed.
lenNumber of bytes to write.
Returns:
The number of bytes written. A return value of -1 indicates an error.

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.

Here is the call graph for this function:

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.

Parameters:
nfpPointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen().
bufferPointer to the data in program space. If zero, then the output buffer will be flushed.
lenNumber of bytes to write.
Returns:
The number of bytes written. A return value of -1 indicates an error.
int RawFsFileRead ( NUTFILE nfp,
void *  buffer,
int  size 
)

Read data from a file.

Parameters:
nfpPointer to a NUTFILE structure, obtained by a previous call to RawFsFileOpen().
bufferPointer to the data buffer to fill.
sizeMaximum number of bytes to read.
Returns:
The number of bytes actually read. A return value of -1 indicates an error.

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.

Here is the call graph for this function:

int RawFsUnmount ( NUTDEVICE dev)

Unmount a raw volume.

This routine is called by the block device driver while unmounting a partition.

Parameters:
devSpecifies the file system device.
Returns:
0 on success or -1 in case of an error.

References _NUTDEVICE::dev_dcb, free(), NULL, and NUTASSERT.

Here is the call graph for this function:

int RawFsMount ( NUTDEVICE dev,
NUTFILE blkmnt,
uint8_t  part_type 
)

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.

Parameters:
devSpecifies the file system device.
blkmntHandle of the block device's partition mount.
part_typePartition type, ignored.
Returns:
0 on success or -1 in case of an error.

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.

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    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).