yaffs Clean up WinCE compilation issues
authorCharles Manning <cdhmanning@gmail.com>
Thu, 22 Jul 2010 00:13:33 +0000 (12:13 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 22 Jul 2010 00:13:33 +0000 (12:13 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/basic-test/yramsim.c
direct/yaffs_nandif.c
direct/yaffsfs.c
yaffs_guts.c
yaffs_guts.h
yaffs_nameval.c
yaffs_nameval.h
yaffs_verify.c

index a791791bb49bfdd221069c31ba6bc179eb6e23b5..69b5b78368a06e5165b9d8882b3fc2cc7ce54026 100644 (file)
@@ -7,13 +7,6 @@
 #include "yaffs_nandif.h"\r
 \r
 \r
 #include "yaffs_nandif.h"\r
 \r
 \r
-#ifdef __WINCE__\r
-#include <windows.h>\r
-#else\r
-#define DebugBreak() do { } while(0)\r
-#endif\r
-\r
-\r
 #define DATA_SIZE      2048\r
 #define SPARE_SIZE     64\r
 #define PAGE_SIZE      (DATA_SIZE + SPARE_SIZE)\r
 #define DATA_SIZE      2048\r
 #define SPARE_SIZE     64\r
 #define PAGE_SIZE      (DATA_SIZE + SPARE_SIZE)\r
@@ -47,17 +40,14 @@ static void CheckInitialised(void)
 static int yramsim_EraseBlockInternal(SymData *sym, unsigned blockId,int force)\r
 {\r
        if(blockId < 0 || blockId >= sym->nBlocks){\r
 static int yramsim_EraseBlockInternal(SymData *sym, unsigned blockId,int force)\r
 {\r
        if(blockId < 0 || blockId >= sym->nBlocks){\r
-               DebugBreak();\r
                return 0;\r
        }\r
 \r
        if(!sym->blockList[blockId]){\r
                return 0;\r
        }\r
 \r
        if(!sym->blockList[blockId]){\r
-               DebugBreak();\r
                return 0;\r
        }\r
 \r
        if(!force && !sym->blockList[blockId]->blockOk){\r
                return 0;\r
        }\r
 \r
        if(!force && !sym->blockList[blockId]->blockOk){\r
-               DebugBreak();\r
                return 0;\r
        }\r
 \r
                return 0;\r
        }\r
 \r
@@ -101,7 +91,6 @@ static int yramsim_ReadChunk (yaffs_Device *dev, unsigned pageId,
           spareLength > SPARE_SIZE ||\r
           !eccStatus ||\r
           !blockList[blockId]->blockOk){\r
           spareLength > SPARE_SIZE ||\r
           !eccStatus ||\r
           !blockList[blockId]->blockOk){\r
-                  DebugBreak();\r
                   return 0;\r
        }\r
 \r
                   return 0;\r
        }\r
 \r
@@ -136,7 +125,6 @@ static int yramsim_WriteChunk (yaffs_Device *dev,unsigned pageId,
           dataLength >DATA_SIZE ||\r
           spareLength > SPARE_SIZE ||\r
           !blockList[blockId]->blockOk){\r
           dataLength >DATA_SIZE ||\r
           spareLength > SPARE_SIZE ||\r
           !blockList[blockId]->blockOk){\r
-                  DebugBreak();\r
                   return 0;\r
        }\r
 \r
                   return 0;\r
        }\r
 \r
@@ -167,7 +155,6 @@ static int yramsim_CheckBlockOk(yaffs_Device *dev,unsigned blockId)
        SymData *sym = DevToSym(dev);\r
        Block **blockList = sym->blockList;\r
        if(blockId >= sym->nBlocks){\r
        SymData *sym = DevToSym(dev);\r
        Block **blockList = sym->blockList;\r
        if(blockId >= sym->nBlocks){\r
-               DebugBreak();\r
                return 0;\r
        }\r
 \r
                return 0;\r
        }\r
 \r
@@ -179,7 +166,6 @@ static int yramsim_MarkBlockBad(yaffs_Device *dev,unsigned blockId)
        SymData *sym = DevToSym(dev);\r
        Block **blockList = sym->blockList;\r
        if(blockId >= sym->nBlocks){\r
        SymData *sym = DevToSym(dev);\r
        Block **blockList = sym->blockList;\r
        if(blockId >= sym->nBlocks){\r
-               DebugBreak();\r
                return 0;\r
        }\r
 \r
                return 0;\r
        }\r
 \r
index 6f36eb7d3eb5d708aa6cf650ff155db82c7470e3..e5358a1bb983be3e8d997bae883f8f114a35bbc1 100644 (file)
@@ -22,7 +22,7 @@
 #include "yramsim.h"
 
 #include "yaffs_trace.h"
 #include "yramsim.h"
 
 #include "yaffs_trace.h"
-
+#include "yaffsfs.h"
 
 
 /* NB For use with inband tags....
 
 
 /* NB For use with inband tags....
index 9fc4417eb958954b448558eb4b45a294332c520b..fc68b969e017c9a82af5b66452f95cfdfae87408 100644 (file)
@@ -1186,7 +1186,7 @@ int yaffs_fstat(int fd, struct yaffs_stat *buf)
        return retVal;
 }
 
        return retVal;
 }
 
-
+#ifndef CONFIG_YAFFS_WINCE
 /* xattrib functions */
 
 
 /* xattrib functions */
 
 
@@ -1440,6 +1440,7 @@ int yaffs_fremovexattr(int fd, const char *name)
 
        return retVal;
 }
 
        return retVal;
 }
+#endif
 
 #ifdef CONFIG_YAFFS_WINCE
 int yaffs_get_wince_times(int fd, unsigned *wctime, unsigned *watime, unsigned *wmtime)
 
 #ifdef CONFIG_YAFFS_WINCE
 int yaffs_get_wince_times(int fd, unsigned *wctime, unsigned *watime, unsigned *wmtime)
index d65c0caa93f377f44c05ba49a7fe7f502d5207ca..b8a11b5d7cbe4dc189a837f72d1273a5c007f371 100644 (file)
@@ -4896,7 +4896,7 @@ int yaffs_GetAttributes(yaffs_Object *obj, struct iattr *attr)
 #endif
 
 
 #endif
 
 
-static int yaffs_DoXMod(yaffs_Object *obj, int set, const char *name, const void *value, int size, int flags)
+static int yaffs_DoXMod(yaffs_Object *obj, int set, const YCHAR *name, const void *value, int size, int flags)
 {
        yaffs_XAttrMod xmod;
 
 {
        yaffs_XAttrMod xmod;
 
@@ -4935,7 +4935,7 @@ static int yaffs_ApplyXMod(yaffs_Device *dev, char *buffer, yaffs_XAttrMod *xmod
        return retval;
 }
 
        return retval;
 }
 
-static int yaffs_DoXFetch(yaffs_Object *obj, const char *name, void *value, int size)
+static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int size)
 {
        char *buffer = NULL;
        int result;
 {
        char *buffer = NULL;
        int result;
@@ -4971,17 +4971,17 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const char *name, void *value, int
        return retval;
 }
 
        return retval;
 }
 
-int yaffs_SetXAttribute(yaffs_Object *obj, const char *name, const void * value, int size, int flags)
+int yaffs_SetXAttribute(yaffs_Object *obj, const YCHAR *name, const void * value, int size, int flags)
 {
        return yaffs_DoXMod(obj, 1, name, value, size, flags);
 }
 
 {
        return yaffs_DoXMod(obj, 1, name, value, size, flags);
 }
 
-int yaffs_RemoveXAttribute(yaffs_Object *obj, const char *name)
+int yaffs_RemoveXAttribute(yaffs_Object *obj, const YCHAR *name)
 {
        return yaffs_DoXMod(obj, 0, name, NULL, 0, 0);
 }
 
 {
        return yaffs_DoXMod(obj, 0, name, NULL, 0, 0);
 }
 
-int yaffs_GetXAttribute(yaffs_Object *obj, const char *name, void *value, int size)
+int yaffs_GetXAttribute(yaffs_Object *obj, const YCHAR *name, void *value, int size)
 {
        return yaffs_DoXFetch(obj, name, value, size);
 }
 {
        return yaffs_DoXFetch(obj, name, value, size);
 }
index b7e2f4bcc569e087069f1f6398f6008712273730..90c3022e2b82b9cd3b10df68a465e9ddf734bf7e 100644 (file)
@@ -517,7 +517,7 @@ typedef struct {
 
 
 struct yaffs_DeviceParamStruct {
 
 
 struct yaffs_DeviceParamStruct {
-       const char *name;
+       const YCHAR *name;
 
        /*
          * Entry parameters set up way early. Yaffs sets up the rest.
 
        /*
          * Entry parameters set up way early. Yaffs sets up the rest.
@@ -822,7 +822,7 @@ struct yaffs_ShadowFixerStruct {
 /* Structure for doing xattr modifications */
 typedef struct {
        int set; /* If 0 then this is a deletion */
 /* Structure for doing xattr modifications */
 typedef struct {
        int set; /* If 0 then this is a deletion */
-       const char *name;
+       const YCHAR *name;
        const void *data;
        int size;
        int flags;
        const void *data;
        int size;
        int flags;
index 4835ccfeff6dd99c9629c75d872acbf072141fcc..4b285130a6f4a1b808c6d1398519ac2939d8071b 100644 (file)
@@ -21,6 +21,8 @@
  *  nbytes    value.
  *  ----------
  *  total size  stored in record size 
  *  nbytes    value.
  *  ----------
  *  total size  stored in record size 
+ *
+ * This code has not been tested with unicode yet.
  */
 
 
  */
 
 
@@ -28,7 +30,7 @@
 
 #include "yportenv.h"
  
 
 #include "yportenv.h"
  
-static int nval_find(const char *xb, int xb_size, const char *name,
+static int nval_find(const char *xb, int xb_size, const YCHAR *name,
                int *exist_size)
 {
        int pos=0;
                int *exist_size)
 {
        int pos=0;
@@ -36,7 +38,7 @@ static int nval_find(const char *xb, int xb_size, const char *name,
 
        memcpy(&size,xb,sizeof(int));
        while(size > 0 && (size < xb_size) && (pos + size < xb_size)){
 
        memcpy(&size,xb,sizeof(int));
        while(size > 0 && (size < xb_size) && (pos + size < xb_size)){
-               if(strncmp(xb+pos+sizeof(int),name,size) == 0){
+               if(yaffs_strncmp((YCHAR *)(xb+pos+sizeof(int)),name,size) == 0){
                        if(exist_size)
                                *exist_size = size;
                        return pos;
                        if(exist_size)
                                *exist_size = size;
                        return pos;
@@ -68,7 +70,7 @@ static int nval_used(const char *xb, int xb_size)
        return pos;
 }
 
        return pos;
 }
 
-int nval_del(char *xb, int xb_size, const char *name)
+int nval_del(char *xb, int xb_size, const YCHAR *name)
 {
        int pos  = nval_find(xb, xb_size, name, NULL);
        int size;
 {
        int pos  = nval_find(xb, xb_size, name, NULL);
        int size;
@@ -83,10 +85,10 @@ int nval_del(char *xb, int xb_size, const char *name)
                return -ENODATA;
 }
 
                return -ENODATA;
 }
 
-int nval_set(char *xb, int xb_size, const char *name, const char *buf, int bsize, int flags)
+int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf, int bsize, int flags)
 {
        int pos;
 {
        int pos;
-       int namelen = strnlen(name,xb_size);
+       int namelen = yaffs_strnlen(name,xb_size);
        int reclen;
        int size_exist = 0;
        int space;
        int reclen;
        int size_exist = 0;
        int space;
@@ -116,13 +118,13 @@ int nval_set(char *xb, int xb_size, const char *name, const char *buf, int bsize
 
        memcpy(xb + pos,&reclen,sizeof(int));
        pos +=sizeof(int);
 
        memcpy(xb + pos,&reclen,sizeof(int));
        pos +=sizeof(int);
-       strncpy(xb + pos, name, reclen);
+       yaffs_strncpy((YCHAR *)(xb + pos), name, reclen);
        pos+= (namelen+1);
        memcpy(xb + pos,buf,bsize);
        return 0;
 }
 
        pos+= (namelen+1);
        memcpy(xb + pos,buf,bsize);
        return 0;
 }
 
-int nval_get(const char *xb, int xb_size, const char *name, char *buf, int bsize)
+int nval_get(const char *xb, int xb_size, const YCHAR *name, char *buf, int bsize)
 {
        int pos = nval_find(xb,xb_size,name,NULL);
        int size;
 {
        int pos = nval_find(xb,xb_size,name,NULL);
        int size;
@@ -166,12 +168,16 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize)
        while(size > sizeof(int) && size <= xb_size && (pos + size) < xb_size && !filled){
                pos+= sizeof(int);
                size-=sizeof(int);
        while(size > sizeof(int) && size <= xb_size && (pos + size) < xb_size && !filled){
                pos+= sizeof(int);
                size-=sizeof(int);
-               name_len = strnlen(xb + pos, size);
+               name_len = yaffs_strnlen((YCHAR *)(xb + pos), size);
                if(ncopied + name_len + 1 < bsize){
                if(ncopied + name_len + 1 < bsize){
-                       memcpy(buf,xb+pos,name_len);
+                       memcpy(buf,xb+pos,name_len * sizeof(YCHAR));
                        buf+= name_len;
                        *buf = '\0';
                        buf++;
                        buf+= name_len;
                        *buf = '\0';
                        buf++;
+                       if(sizeof(YCHAR) > 1){
+                               *buf = '\0';
+                               buf++;
+                       }
                        ncopied += (name_len+1);
                } else
                        filled = 1;
                        ncopied += (name_len+1);
                } else
                        filled = 1;
index 102c1c06998999746293f3b0e329694bd681510f..a9d4a0ae2384693c5a13e2b8587abc002d0b828b 100644 (file)
@@ -1,9 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
 #ifndef __NAMEVAL_H__
 #define __NAMEVAL_H__
 
 #ifndef __NAMEVAL_H__
 #define __NAMEVAL_H__
 
-int nval_del(char *xb, int xb_size, const char *name);
-int nval_set(char *xb, int xb_size, const char *name, const char *buf, int bsize, int flags);
-int nval_get(const char *xb, int xb_size, const char *name, char *buf, int bsize);
+#include "yportenv.h"
+
+int nval_del(char *xb, int xb_size, const YCHAR *name);
+int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf, int bsize, int flags);
+int nval_get(const char *xb, int xb_size, const YCHAR *name, char *buf, int bsize);
 int nval_list(const char *xb, int xb_size, char *buf, int bsize);
 int nval_load(char *xb, int xb_size, const char *src, int src_size);
 int nval_save(const char *xb, int xb_size, char *dest, int dest_size);
 int nval_list(const char *xb, int xb_size, char *buf, int bsize);
 int nval_load(char *xb, int xb_size, const char *src, int src_size);
 int nval_save(const char *xb, int xb_size, char *dest, int dest_size);
index b8083ad07b23b3235727e0dcd9e115bf6d422d0d..4511c0f5871d1196f8a4a57a1db51595f78ad44a 100644 (file)
@@ -621,6 +621,7 @@ int yaffs_VerifyFileSanity(yaffs_Object *in)
 
        return failed ? YAFFS_FAIL : YAFFS_OK;
 #else
 
        return failed ? YAFFS_FAIL : YAFFS_OK;
 #else
+       in=in;
        return YAFFS_OK;
 #endif
 }
        return YAFFS_OK;
 #endif
 }