Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

Peanut File System
[File System API.]

Collaboration diagram for Peanut File System:


Detailed Description

Volatile RAM file system.


Data Structures

struct  PNUT_NODE
 Node structure. More...
struct  PNUT_DIRENTRY
 Directory entry structure. More...
struct  PNUT_FINDRESULT
 Directory search result information structure. More...
struct  _PNUTFILE
 PNUT file descriptor structure. More...

Peanut File System Configuration

The Nut/OS Configurator may be used to override the default values.

#define PNUT_BLOCK_SIZE   512
 Size of a filesystem block.
#define PNUT_DIRENT_SIZE   32
 Size of a directory entry.
#define PNUT_BLOCKS_PER_NODE   250
 Maximum number of blocks per node.
#define PNUTBANK_COUNT   30

Defines

#define SEEK_SET   0
#define SEEK_CUR   1
#define SEEK_END   2
#define NODETYPE_REG   0
#define NODETYPE_DIR   1
#define PNUT_MAX_NAMELEN   (PNUT_DIRENT_SIZE - sizeof(PNUT_BLKNUM) - sizeof(u_char) - 1)
 Maximum length of a base name.
#define PNUT_MAX_FILESIZE   (PNUT_BLOCKS_PER_NODE * PNUT_BLOCK_SIZE)
 Maximum size of a file or directory.
#define NUTBANK_SIZE   16384
 Size of each memory bank.
#define PNUT_TOTAL_BLOCKS   (PNUTBANK_COUNT * (NUTBANK_SIZE / PNUT_BLOCK_SIZE))
 Total number of blocks on this device.
#define BLOCKS_PER_BANK   (NUTBANK_SIZE / PNUT_BLOCK_SIZE)
#define NUTBANK_SR   0xFF00
#define NUTBANK_START   0x8000
#define NUTBANK_PTR   ((char *)NUTBANK_START)

Typedefs

typedef short PNUT_BLKNUM
typedef _PNUTFILE PNUTFILE
 PNUT file descriptor type.

Functions

void BankSelect (PNUT_BLKNUM blk)
 Make the bank visible, which contains the specified block.
PNUT_NODEBankNodePointer (PNUT_BLKNUM blk)
 Select specified bank and return pointer to block.
int PnutIOCtl (NUTDEVICE *dev, int req, void *conf)
 Device specific functions.

Variables

NUTDEVICE devPnut
 Peanut device information structure.


Define Documentation

#define PNUT_BLOCKS_PER_NODE   250
 

Maximum number of blocks per node.

Peanut supports only one node per file. Thus, this number multiplied by PNUT_BLOCK_SIZE specifies the maximum file size.

Changings this number will change the size of the node structure, which must fit into a single filesystem block.

#define PNUT_MAX_NAMELEN   (PNUT_DIRENT_SIZE - sizeof(PNUT_BLKNUM) - sizeof(u_char) - 1)
 

Maximum length of a base name.

This is a calculated value and depends on the definition of the block size and the size of a directory entry.

#define PNUT_MAX_FILESIZE   (PNUT_BLOCKS_PER_NODE * PNUT_BLOCK_SIZE)
 

Maximum size of a file or directory.

This is a calculated value and depends on the definition of the block size and the number of blocks per directory entry.

#define PNUT_TOTAL_BLOCKS   (PNUTBANK_COUNT * (NUTBANK_SIZE / PNUT_BLOCK_SIZE))
 

Total number of blocks on this device.

This value is calulated by multiplying the number of memory banks reserved for the file system by the number of blocks per bank.

For example, if all 30 banks, which are available on Ethernut 2, are reserved for PNUT and if the size of a block is 512 bytes, then 960 blocks are available.


Function Documentation

void BankSelect PNUT_BLKNUM  blk  ) 
 

Make the bank visible, which contains the specified block.

On Ethernut 2 we select a bank by writing the bank number to the bank register base address plus the bank number.

For example, writing 0x12 to 0xFF12 selects bank 18 (0x12), assuming that 0xFF00 is the bank register base address.

Parameters:
blk Block number to access.


Variable Documentation

NUTDEVICE devPnut
 

Initial value:

 {
    0,                          
    {'P', 'N', 'U', 'T', 0, 0, 0, 0, 0}
    ,                           
    IFTYP_RAM,                  
    0,                          
    0,                          
    0,                          
    0,                          
    PnutInit,                   
    PnutIOCtl,                  
    PnutFileRead,               
    PnutFileWrite,              

    PnutFileWrite_P,            

    PnutFileOpen,               
    PnutFileClose,              
    PnutFileSize                
}
Peanut device information structure.

Log
pnut.h,v
Revision 1.1 2005/02/05 20:37:17 haraldkipp Peanut added


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