FreeCalypso > hg > freecalypso-sw
diff gsm-fw/services/ffs/ffs.c @ 217:30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 06 Jan 2014 08:07:36 +0000 |
parents | ef7d7da61c56 |
children |
line wrap: on
line diff
--- a/gsm-fw/services/ffs/ffs.c Mon Jan 06 07:23:36 2014 +0000 +++ b/gsm-fw/services/ffs/ffs.c Mon Jan 06 08:07:36 2014 +0000 @@ -8,12 +8,10 @@ * f ******************************************************************************/ -#ifndef TARGET -#include "ffs.cfg" -#endif +#include "ffs.h" #if ((TARGET == 1) || (RIV_ENV== 1)) -#include "ffs/board/task.h" +#include "task.h" #endif #if (TARGET == 0) @@ -23,9 +21,8 @@ #include <string.h> #include <limits.h> -#include "ffs/ffs.h" -#include "ffs/board/core.h" -#include "ffs/board/ffstrace.h" +#include "core.h" +#include "ffstrace.h" /****************************************************************************** * @@ -95,7 +92,7 @@ else { // Object found, continue like fupdate() if (is_open_option(option, (FFS_O_CREATE)) - && is_open_option(option, (FFS_O_EXCL))) + && is_open_option(option, (FFS_O_EXCL))) return EFFS_EXISTS; if (get_fdi(i) >= 0) @@ -143,7 +140,7 @@ chunk_size = (size_remaining > fs.chunk_size_max ? fs.chunk_size_max : size_remaining); - + journal_begin(0); if ((i = segment_create((char*) src + size - size_remaining, @@ -279,7 +276,7 @@ iref_t i; tw(tr(TR_FUNC, TrApi, "ffs_stat('%s', ?) ?\n", name)); - ttw(ttr(TTrApi, "ffs_stat('%s', ?) ?" NL, name)); + ttw(ttr(TTrApi, "ffs_stat('%s', ?) ?" NL, name)); if (name == NULL) return EFFS_BADNAME; @@ -298,7 +295,7 @@ iref_t i; tw(tr(TR_FUNC, TrApi, "ffs_lstat('%s', ?) ?\n", name)); - ttw(ttr(TTrApi, "ffs_lstat('%s', ?) ?" NL, name)); + ttw(ttr(TTrApi, "ffs_lstat('%s', ?) ?" NL, name)); if ((i = ffs_begin()) == EFFS_OK) { if ((i = object_stat(name, (struct xstat_s*)stat, 1, 0, 0)) > 0) @@ -313,7 +310,7 @@ iref_t i; tw(tr(TR_FUNC, TrApi, "ffs_xlstat('%s', ?) ?\n", name)); - ttw(ttr(TTrApi, "ffs_xlstat('%s', ?) ?" NL, name)); + ttw(ttr(TTrApi, "ffs_xlstat('%s', ?) ?" NL, name)); if ((i = ffs_begin()) == EFFS_OK) { if ((i = object_stat(name, stat, 1, 0, 1)) > 0) @@ -328,7 +325,7 @@ iref_t i; tw(tr(TR_FUNC, TrApi, "ffs_fstat('%d', ?) ?\n", fdi)); - ttw(ttr(TTrApi, "ffs_fstat('%d', ?) ?" NL, fdi)); + ttw(ttr(TTrApi, "ffs_fstat('%d', ?) ?" NL, fdi)); if ((i = ffs_begin()) == EFFS_OK) { if ((i = object_stat( 0, (struct xstat_s*) stat, 0, fdi, 0)) > 0) @@ -346,7 +343,7 @@ int size; tw(tr(TR_FUNC, TrApi, "ffs_symlink('%s', '%s') ?\n", pathname, src)); - ttw(ttr(TTrApi, "ffs_symlink('%s', '%s') ?" NL, pathname, src)); + ttw(ttr(TTrApi, "ffs_symlink('%s', '%s') ?" NL, pathname, src)); // TASKBEGIN effs_t SYMLINK(path=pathname, src=src) iref_t i, dir; int size; char *name; @@ -414,7 +411,7 @@ iref_t i; tw(tr(TR_FUNC, TrApi, "ffs_remove('%s')\n", pathname)); - ttw(ttr(TTrApi, "ffs_remove('%s') ?" NL, pathname)); + ttw(ttr(TTrApi, "ffs_remove('%s') ?" NL, pathname)); // TASKBEGIN effs_t REMOVE(path=pathname) iref_t i; @@ -463,8 +460,8 @@ tw(tr(TR_FUNC, TrApi, "ffs_fcontrol('%s', %d, 0x%x) ?\n", pathname, action, param)); - ttw(ttr(TTrApi, "ffs_fcontrol('%s', %d, 0x%x) ?" NL, - pathname, action, param)); + ttw(ttr(TTrApi, "ffs_fcontrol('%s', %d, 0x%x) ?" NL, + pathname, action, param)); // TASKBEGIN effs_t FCONTROL(path=pathname, value16=action, size=param) iref_t i; @@ -518,7 +515,7 @@ struct inode_s *ip; tw(tr(TR_FUNC, TrApi, "ffs_rename('%s', '%s') ?\n", pathname, newname)); - ttw(ttr(TTrApi, "ffs_rename('%s', '%s') ?" NL, pathname, newname)); + ttw(ttr(TTrApi, "ffs_rename('%s', '%s') ?" NL, pathname, newname)); // TASKBEGIN effs_t RENAME(path=pathname, src=newname) iref_t i, oldi, dir; char *name; struct inode_s *ip; @@ -600,8 +597,8 @@ char *name; tw(tr(TR_FUNC, TrApi, "ffs_mkdir('%s')\n", pathname)); - ttw(ttr(TTrApi, "ffs_mkdir('%s') ?" NL, pathname)); - + ttw(ttr(TTrApi, "ffs_mkdir('%s') ?" NL, pathname)); + // TASKBEGIN effs_t MKDIR(path=pathname) iref_t i, dir; char *name; if (fs.initerror) @@ -648,7 +645,7 @@ int i; tw(tr(TR_FUNC, TrApi, "ffs_opendir('%s', ?)\n", name)); - ttw(ttr(TTrApi, "ffs_opendir('%s', ?) ?" NL, name)); + ttw(ttr(TTrApi, "ffs_opendir('%s', ?) ?" NL, name)); if (dir == NULL) return EFFS_INVALID; @@ -672,7 +669,7 @@ iref_t i; tw(tr(TR_BEGIN, TrApi, "ffs_readdir(?, ?, ?) {\n")); - ttw(ttr(TTrApi, "ffs_readdir(?, ?, ?) ?" NL)); + ttw(ttr(TTrApi, "ffs_readdir(?, ?, ?) ?" NL)); if (dir == NULL || name == NULL || size < 0) { tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); @@ -700,20 +697,20 @@ struct ffs_blocking_s *fb) { effs_t i; - + tw(tr(TR_BEGIN, TrApi, "ffs_format('%s', 0x%x) {\n", name, magic)); - ttw(ttr(TTrApi, "ffs_format('%s', 0x%x) ?" NL, name, magic)); + ttw(ttr(TTrApi, "ffs_format('%s', 0x%x) ?" NL, name, magic)); // TASKBEGIN effs_t FORMAT(path=name, size=magic) iref_t i; - + if (magic != 0x2BAD) { tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); return EFFS_INVALID; } - if (name == NULL) { + if (name == NULL) { name = "/ffs-5.54"; - } + } if (*name != '/') { tw(tr(TR_END, TrApi, "} %d\n", EFFS_BADNAME)); @@ -759,7 +756,7 @@ effs_t i; tw(tr(TR_BEGIN, TrApi, "ffs_preformat(0x%x) {\n", magic)); - ttw(ttr(TTrApi, "ffs_preformat(0x%x) ?" NL, magic)); + ttw(ttr(TTrApi, "ffs_preformat(0x%x) ?" NL, magic)); // TASKBEGIN effs_t PREFORMAT(path="/", size=magic) effs_t i; @@ -819,7 +816,7 @@ struct inode_s *ip; tw(tr(TR_FUNC, TrApi, "ffs_open('%s', 0x%x) ?\n", pathname, option)); - ttw(ttr(TTrApi, "ffs_open('%s', 0x%x) ?" NL, pathname, option)); + ttw(ttr(TTrApi, "ffs_open('%s', 0x%x) ?" NL, pathname, option)); // TASKBEGIN fd_t OPEN(path=pathname, value16=option) iref_t i, dir, dummy; char *name; fd_t other_fdi, fdi = 0; int error; struct inode_s *ip; @@ -854,7 +851,7 @@ // Open one file several times in RD is okay but only one time in WR if (i != EFFS_NOTFOUND && (other_fdi = get_fdi(i)) >= 0) { if (is_open_option(fs.fd[other_fdi].options, FFS_O_WRONLY) || - is_open_option(option, FFS_O_WRONLY)) + is_open_option(option, FFS_O_WRONLY)) return EFFS_LOCKED; } @@ -907,7 +904,7 @@ fs.link_child = 0; journal_end(0); - // If any further segments exist then remove them now + // If any further segments exist then remove them now if (fs.i_backup > 0) if ((error = object_remove(fs.i_backup)) < 0) return error; @@ -936,9 +933,9 @@ } // Save data in file descriptor - fs.fd[fdi].seghead = i; - fs.fd[fdi].options = option; - + fs.fd[fdi].seghead = i; + fs.fd[fdi].options = option; + return fdi + FFS_FD_OFFSET; // TASKEND @@ -967,7 +964,7 @@ int error; tw(tr(TR_FUNC, TrApi, "ffs_close(%d) ?\n", fdi)); - ttw(ttr(TTrApi, "ffs_close(%d) ?" NL, fdi)); + ttw(ttr(TTrApi, "ffs_close(%d) ?" NL, fdi)); // TASKBEGIN effs_t CLOSE(fdi=fdi) iref_t i; int error; @@ -1055,9 +1052,9 @@ return error; } - size_done = 0; - size_remaining = amount; - + size_done = 0; + size_remaining = amount; + do { if (!fs.fd[fdi].dirty ) { // Buffer is not dirty so find the chunk that fp points to. @@ -1078,16 +1075,16 @@ } } - fs.fd[fdi].dirty = 1; - fp_offset = fs.fd[fdi].fp - fs.fd[fdi].wfp; + fs.fd[fdi].dirty = 1; + fp_offset = fs.fd[fdi].fp - fs.fd[fdi].wfp; // Fill the buffer to max or just add the rest size = fs.chunk_size_max - fp_offset; - if (size_remaining <= fs.chunk_size_max - fp_offset) + if (size_remaining <= fs.chunk_size_max - fp_offset) size = size_remaining; - - tw(tr(TR_FUNC, TrApi, "Copy data to buffer (size: %d)\n", size)); + + tw(tr(TR_FUNC, TrApi, "Copy data to buffer (size: %d)\n", size)); memcpy(fs.fd[fdi].buf + fp_offset, (uint8*)src + size_done, size); @@ -1152,7 +1149,7 @@ req_id_t ffs_seek_b(fd_t fdi, int offset, int whence, T_RV_RETURN *cp, struct ffs_blocking_s *fb) { - effs_t error; + effs_t error; int fp_new; tw(tr(TR_FUNC, TrApi, "ffs_seek(%d, %d, %d) ?\n", fdi, offset, whence)); @@ -1311,4 +1308,3 @@ { return ffs_fdatasync_b(fdi, cp, 0); } -