YAFFS Direct Interface (YDI)

Now hear this!

YAFFS code is GPL. The YAFFS Direct Interface(YDI) is really intended to provide a direct interface to YAFFS in an embedded/RTOS environment. Using YAFFS in this way might violate GPL. Aleph One are looking at ways to make YAFFS licensing more flexible to support both GPL and YDI users. For further info, please contact Aleph One.

Purpose

The purpose of the YAFFS Direct Interface is to provide YAFFS to embedded/RTOS environments where full file system support is not available. Typically, therefore, YDI is intended for smaller embedded systems.

Software Modules

The software is designed in a modular fashion to facilitate integration and configuration.

The software comprises the following main sections:



General Notes

Licensing

The YAFFS file system is GPL.

The YAFFS bootloader and header files are LGPL to allow incorporation of these into proprietary code.

nand_ecc.c, copyright SJ Hill, is LGPL.

File names

Multiple partitions are defined by setting up the partition table in yaffscfg.c.

The system has no concept of current directory, therefore all names and paths must be fully specified. eg. "/boot/xxx"

Names are case sensitive.

The divider between path elements is '/'. eg "/ram/dir/file".

Permissions and attributes

The following permissions are supported in mode: S_IREAD, S_IWRITE.

The following opening modes are checked: O_RDONLY, O_WRONLY, O_RDWR, O_EXCL.

Times are just flat 32-bit numbers. The meaning of these numbers is OS dependent and is defined by completing the funbctiuon yaffsfs_CurrentTime() in yaffscfg.c

Attributes are stored as a 32-bit unsigned value. Some of these are reserved. Others are used transparently (and may be used for additional information by the application). Reserved are:



Threading

All yaffs routines are thread safe when called through the specified interface.

All yaffs routines are controlled by a single locking mutex/semaphore by defining yaffsfs_Lock() and yaffsfs_Unlock() in yaffscfg.c.

Thus, only one thread is able to execute yaffs functions at a time. Most yaffs functions execute quickly, so this generally not a limitation.

Compilation Configuration

Configuration is done in four places:

Device Configuration

The device configuration table is set up in yaffscfg.c and specifies what devices are in the system. The order is important since this is the order that is used when searching for files/directories and provides the "switch" mechanism to support multiple "mount points"

The device configuration has the form:

struct {
const char *prefix;
yaffs_Device *dev;
};

eg.

{
{"/ram",ramDevice},
{"/boot",bootDevice},
{"/flash",flashDevice},
{NULL,NULL}
}

Note that multiple yaffs_Devices can share a single physical NAND device by "partitioning". Thus, for instance, /boot and /data may be on the same physical device, just with non-overlapping regions.

Different properties may be attached to the different yaffs_Device entries. For example note that the RAM disk is set up with different NANDECC flags.

API Notes

int yaffs_open(const char *path, int oflag, int mode) ;

Supported flags O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_RDONLY, O_RDWR, O_WRONLY.

int yaffs_read(int fd, void *buf, unsigned int nbyte) ;

int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;

int yaffs_close(int fd) ;

off_t yaffs_lseek(int fd, off_t offset, int whence) ;

int yaffs_unlink(const char *path) ;

int yaffs_rename(const char *old, const char *new) ;

int yaffs_stat(const char *path, struct stat *buf) ;

int yaffs_lstat(const char *path, struct stat *buf) ;

int yaffs_fstat(int fd, struct, struct stat *buf) ;

int yaffs_chmod(const char *path, mode_t mode) ;

int yaffs_fchmod(int fd, struct, mode_t mode) ;

int yaffs_mkdir(const char *path, mode_t mode) ;

int yaffs_rmdir(const char *path) ;

yaffs_DIR *yaffs_opendir(const char *dirname) ;

struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;

void yaffs_rewinddir(yaffs_DIR *dirp) ;

int yaffs_closedir(yaffs_DIR *dirp) ;

int yaffs_mount(const char *path) ;

int yaffs_unmount(const char *path) ;

int yaffs_symlink(const char *oldpath, const char *newpath);

int yaffs_readlink(const char *path, char *buf, size_t bufsiz);

int yaffs_link(const char *oldpath, const char *newpath);

int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev);

off_t yaffs_freespace(const char *path);



$Id: yaffs_direct.html,v 1.1 2003-01-21 03:34:12 charles Exp $