Changed Contiki File System (cfs) from a service to a plain library.
This change means that one needs to select _ONE_ cfs implementation at Contiki library link time. But this doesn't appear to be an issue as all platforms have their "favorite" implementation anyway.
This commit is contained in:
parent
67ae9fbcb7
commit
9f97290665
14 changed files with 94 additions and 545 deletions
|
@ -30,12 +30,11 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: cfs-posix.c,v 1.2 2006/08/13 14:05:20 oliverschmidt Exp $
|
||||
* $Id: cfs-posix.c,v 1.3 2007/05/19 21:05:49 oliverschmidt Exp $
|
||||
*/
|
||||
#include "contiki.h"
|
||||
|
||||
#include "cfs/cfs.h"
|
||||
#include "cfs/cfs-service.h"
|
||||
|
||||
#undef LITTLE_ENDIAN
|
||||
#undef BIG_ENDIAN
|
||||
|
@ -51,41 +50,13 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static int s_open(const char *n, int f);
|
||||
static void s_close(int f);
|
||||
static int s_read(int f, char *b, unsigned int l);
|
||||
static int s_write(int f, char *b, unsigned int l);
|
||||
static int s_seek(int f, unsigned int offset);
|
||||
static int s_opendir(struct cfs_dir *p, const char *n);
|
||||
static int s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
|
||||
static int s_closedir(struct cfs_dir *p);
|
||||
|
||||
SERVICE(cfs_posix_service, cfs_service,
|
||||
{ s_open, s_close, s_read, s_write, s_seek,
|
||||
s_opendir, s_readdir, s_closedir });
|
||||
|
||||
struct cfs_posix_dir {
|
||||
DIR *dirp;
|
||||
};
|
||||
|
||||
PROCESS(cfs_posix_process, "CFS POSIX service");
|
||||
|
||||
PROCESS_THREAD(cfs_posix_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
SERVICE_REGISTER(cfs_posix_service);
|
||||
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_SERVICE_REMOVED ||
|
||||
ev == PROCESS_EVENT_EXIT);
|
||||
|
||||
SERVICE_REMOVE(cfs_posix_service);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
s_open(const char *n, int f)
|
||||
int
|
||||
cfs_open(const char *n, int f)
|
||||
{
|
||||
char filename[255];
|
||||
|
||||
|
@ -98,32 +69,32 @@ s_open(const char *n, int f)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_close(int f)
|
||||
void
|
||||
cfs_close(int f)
|
||||
{
|
||||
close(f);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
s_read(int f, char *b, unsigned int l)
|
||||
int
|
||||
cfs_read(int f, char *b, unsigned int l)
|
||||
{
|
||||
return read(f, b, l);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
s_write(int f, char *b, unsigned int l)
|
||||
int
|
||||
cfs_write(int f, char *b, unsigned int l)
|
||||
{
|
||||
return write(f, b, l);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
s_seek(int f, unsigned int o)
|
||||
int
|
||||
cfs_seek(int f, unsigned int o)
|
||||
{
|
||||
return lseek(f, o, SEEK_SET);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
s_opendir(struct cfs_dir *p, const char *n)
|
||||
int
|
||||
cfs_opendir(struct cfs_dir *p, const char *n)
|
||||
{
|
||||
struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
|
||||
char dirname[255];
|
||||
|
@ -141,8 +112,8 @@ s_opendir(struct cfs_dir *p, const char *n)
|
|||
return dir->dirp == NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
|
||||
int
|
||||
cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e)
|
||||
{
|
||||
struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
|
||||
struct dirent *res;
|
||||
|
@ -160,8 +131,8 @@ s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
|
|||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
s_closedir(struct cfs_dir *p)
|
||||
int
|
||||
cfs_closedir(struct cfs_dir *p)
|
||||
{
|
||||
struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
|
||||
if(dir->dirp != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue