XgRawFsFs


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.

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:
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.
Returns:
Pointer to a NUTFILE structure if successful or NUTFILE_EOF otherwise.
Bug:
Append mode not working as expected.

Definition at line 214 of file rawfs.c.

References RAWFILE::f_mode, free, malloc, memset(), and NUTFILE_EOF.

int RawFsFileClose ( NUTFILE *  nfp  ) 

Close a raw file.

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

Definition at line 247 of file rawfs.c.

References free, and NUTASSERT.

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

Write data to a file.

Parameters:
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.
Returns:
The number of bytes written. A return value of -1 indicates an error.

Definition at line 274 of file rawfs.c.

References RAWFILE::f_pos, RAWFILE::f_sect_num, RAWFILE::f_sect_pos, memcpy(), and NUTASSERT.

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:
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.
Returns:
The number of bytes written. A return value of -1 indicates an error.

Definition at line 346 of file rawfs.c.

int RawFsFileRead ( NUTFILE *  nfp,
void *  buffer,
int  size 
)

Read data from a file.

Parameters:
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.
Returns:
The number of bytes actually read. A return value of -1 indicates an error.

Definition at line 363 of file rawfs.c.

References RAWFILE::f_pos, RAWFILE::f_sect_num, RAWFILE::f_sect_pos, memcpy(), and NUTASSERT.

int RawFsUnmount ( NUTDEVICE *  dev  ) 

Unmount a raw volume.

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

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

Definition at line 498 of file rawfs.c.

References free, and NUTASSERT.

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:
dev Specifies the file system device.
blkmnt Handle of the block device's partition mount.
part_type Partition type, ignored.
Returns:
0 on success or -1 in case of an error.

Definition at line 529 of file rawfs.c.

References ENODEV, errno, free, malloc, memset(), NUTASSERT, NUTBLKDEV_INFO, NutEventPost(), BLKPAR_INFO::par_blkbp, BLKPAR_INFO::par_blksz, BLKPAR_INFO::par_nblks, and BLKPAR_INFO::par_nfp.


Variable Documentation

NUTDEVICE devRawFs0

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).

Definition at line 784 of file rawfs.c.


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/