Chapter 29. writing a new filesystem, Writing a new filesystem – Comtrol eCos User Manual

Page 435

Advertising
background image

Chapter 29. Writing a New Filesystem

To create a new filesystem it is necessary to define the fstab entry and the file IO operations. The easiest way to
do this is to copy an existing filesystem: either the test filesystem in the FILEIO package, or the RAM or ROM
filesystem packages.

To make this clearer, the following is a brief tour of the FILEIO relevant parts of the RAM filesystem.

First, it is necessary to provide forward definitions of the functions that constitute the filesystem interface:

//==========================================================================

// Forward definitions

// Filesystem operations

static int ramfs_mount

( cyg_fstab_entry *fste, cyg_mtab_entry *mte );

static int ramfs_umount

( cyg_mtab_entry *mte );

static int ramfs_open

( cyg_mtab_entry *mte, cyg_dir dir, const char *name,

int mode,

cyg_file *fte );

static int ramfs_unlink

( cyg_mtab_entry *mte, cyg_dir dir, const char *name );

static int ramfs_mkdir

( cyg_mtab_entry *mte, cyg_dir dir, const char *name );

static int ramfs_rmdir

( cyg_mtab_entry *mte, cyg_dir dir, const char *name );

static int ramfs_rename

( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1,

cyg_dir dir2, const char *name2 );

static int ramfs_link

( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1,

cyg_dir dir2, const char *name2, int type );

static int ramfs_opendir

( cyg_mtab_entry *mte, cyg_dir dir, const char *name,

cyg_file *fte );

static int ramfs_chdir

( cyg_mtab_entry *mte, cyg_dir dir, const char *name,

cyg_dir *dir_out );

static int ramfs_stat

( cyg_mtab_entry *mte, cyg_dir dir, const char *name,

struct stat *buf);

static int ramfs_getinfo

( cyg_mtab_entry *mte, cyg_dir dir, const char *name,

int key, void *buf, int len );

static int ramfs_setinfo

( cyg_mtab_entry *mte, cyg_dir dir, const char *name,

int key, void *buf, int len );

// File operations

static int ramfs_fo_read

(struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);

static int ramfs_fo_write

(struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);

static int ramfs_fo_lseek

(struct CYG_FILE_TAG *fp, off_t *pos, int whence );

static int ramfs_fo_ioctl

(struct CYG_FILE_TAG *fp, CYG_ADDRWORD com,

CYG_ADDRWORD data);

static int ramfs_fo_fsync

(struct CYG_FILE_TAG *fp, int mode );

static int ramfs_fo_close

(struct CYG_FILE_TAG *fp);

static int ramfs_fo_fstat

(struct CYG_FILE_TAG *fp, struct stat *buf );

static int ramfs_fo_getinfo

(struct CYG_FILE_TAG *fp, int key, void *buf, int len );

static int ramfs_fo_setinfo

(struct CYG_FILE_TAG *fp, int key, void *buf, int len );

// Directory operations

331

Advertising