Peanut File System
[File System API.]

Collaboration diagram for Peanut File System:

Detailed Description

Volatile RAM file system.


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(uint8_t) - 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 struct _PNUTFILE PNUTFILE
 PNUT file descriptor type.

Functions

void BankSelect (PNUT_BLKNUM blk)
 Make the bank visible, which contains the specified block.
PNUT_NODE * BankNodePointer (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_BLOCK_SIZE   512

Size of a filesystem block.

Definition at line 121 of file pnutfs.c.

Referenced by BankNodePointer().

#define PNUT_DIRENT_SIZE   32

Size of a directory entry.

Definition at line 131 of file pnutfs.c.

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

Definition at line 147 of file pnutfs.c.

#define PNUTBANK_COUNT   30

Definition at line 160 of file pnutfs.c.

#define SEEK_SET   0

Definition at line 168 of file pnutfs.c.

#define SEEK_CUR   1

Definition at line 169 of file pnutfs.c.

#define SEEK_END   2

Definition at line 170 of file pnutfs.c.

#define NODETYPE_REG   0

Definition at line 173 of file pnutfs.c.

#define NODETYPE_DIR   1

Definition at line 174 of file pnutfs.c.

#define PNUT_MAX_NAMELEN   (PNUT_DIRENT_SIZE - sizeof(PNUT_BLKNUM) - sizeof(uint8_t) - 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.

Definition at line 222 of file pnutfs.c.

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

Definition at line 259 of file pnutfs.c.

#define NUTBANK_SIZE   16384

Size of each memory bank.

Definition at line 304 of file pnutfs.c.

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

Definition at line 318 of file pnutfs.c.

#define BLOCKS_PER_BANK   (NUTBANK_SIZE / PNUT_BLOCK_SIZE)

Definition at line 321 of file pnutfs.c.

Referenced by BankNodePointer(), and BankSelect().

#define NUTBANK_SR   0xFF00

Definition at line 324 of file pnutfs.c.

#define NUTBANK_START   0x8000

Definition at line 328 of file pnutfs.c.

#define NUTBANK_PTR   ((char *)NUTBANK_START)

Definition at line 331 of file pnutfs.c.

Referenced by BankNodePointer().


Typedef Documentation

typedef short PNUT_BLKNUM

Definition at line 177 of file pnutfs.c.

typedef struct _PNUTFILE PNUTFILE

PNUT file descriptor type.

Definition at line 286 of file pnutfs.c.


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.

Definition at line 344 of file pnutfs.c.

References BLOCKS_PER_BANK, and NutSegBufEnable.

Referenced by BankNodePointer().

PNUT_NODE* BankNodePointer ( PNUT_BLKNUM  blk  ) 

Select specified bank and return pointer to block.

Definition at line 359 of file pnutfs.c.

References BankSelect(), BLOCKS_PER_BANK, NUTBANK_PTR, and PNUT_BLOCK_SIZE.

int PnutIOCtl ( NUTDEVICE dev,
int  req,
void *  conf 
)


Variable Documentation

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

Definition at line 1361 of file pnutfs.c.


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