Hi Charles,
please ignore the previous patch which was not complete for linux
compilation.
I splitted it and did some more modifications:
1. Minor fixes:
- some inlines
- extern "C" to include yaffsfs.h from C++
- u32/unsigned type mismatch in yaffs_query_init_block_state() prototype
- int yaffsfs_GetLastError(void) should be defined is yaffs_osglue.h
- struct yaffsfs_DeviceConfiguration no longer needed in yaffscfg.h
- remove invalid state value in trace message in yaffs2_checkpt_find_block()
- some redundant includes in yaffsfs.c
2. string functions macros with yaffs_ prefix
3. Patch for more customization of ydirectenv.h from user defined
configuration in yaffscg.h, and remove debug functions
--
Stephane Lesage
>From 54ee5eaa158496963cc5f65bff28a4a39aff8bcd Mon Sep 17 00:00:00 2001
From: unknown <lesages@.ATEIS>
Date: Mon, 11 Jun 2012 14:02:38 +0200
Subject: [PATCH 1/3] Minor fixes
- some inlines
- extern "C" to include yaffsfs.h from C++
- u32/unsigned type mismatch in yaffs_query_init_block_state() prototype
- int yaffsfs_GetLastError(void) should be defined is yaffs_osglue.h
- struct yaffsfs_DeviceConfiguration no longer needed in yaffscfg.h
- remove invalid state value in trace message in yaffs2_checkpt_find_block()
- some redundant includes in yaffsfs.c
---
direct/yaffs_osglue.h | 1 +
direct/yaffscfg.h | 6 ------
direct/yaffsfs.c | 10 +++-------
direct/yaffsfs.h | 13 +++++++++++--
direct/yportenv.h | 2 +-
yaffs_checkptrw.c | 4 ++--
yaffs_guts.c | 7 +++++--
yaffs_nand.h | 2 +-
8 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/direct/yaffs_osglue.h b/direct/yaffs_osglue.h
index bb008f9..cec1c86 100644
--- a/direct/yaffs_osglue.h
+++ b/direct/yaffs_osglue.h
@@ -31,6 +31,7 @@ void yaffsfs_Unlock(void);
u32 yaffsfs_CurrentTime(void);
void yaffsfs_SetError(int err);
+int yaffsfs_GetLastError(void);
void *yaffsfs_malloc(size_t size);
void yaffsfs_free(void *ptr);
diff --git a/direct/yaffscfg.h b/direct/yaffscfg.h
index 1ffaae9..671496b 100644
--- a/direct/yaffscfg.h
+++ b/direct/yaffscfg.h
@@ -29,11 +29,5 @@
#define YAFFSFS_N_DSC 20
-struct yaffsfs_DeviceConfiguration {
- const YCHAR *prefix;
- struct yaffs_dev *dev;
-};
-
-
#endif
diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c
index 9f1397b..0538ce6 100644
--- a/direct/yaffsfs.c
+++ b/direct/yaffsfs.c
@@ -13,12 +13,8 @@
#include "yaffsfs.h"
#include "yaffs_guts.h"
-#include "yaffscfg.h"
-#include "yportenv.h"
#include "yaffs_trace.h"
-#include "string.h"
-
#define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
#ifndef NULL
@@ -386,7 +382,7 @@ static void yaffsfs_BreakDeviceHandles(struct yaffs_dev *dev)
*/
#ifdef CONFIG_YAFFS_CASE_INSENSITIVE
-static int yaffs_toupper(YCHAR a)
+static inline int yaffs_toupper(YCHAR a)
{
if (a >= 'a' && a <= 'z')
return (a - 'a') + 'A';
@@ -394,12 +390,12 @@ static int yaffs_toupper(YCHAR a)
return a;
}
-int yaffsfs_Match(YCHAR a, YCHAR b)
+static inline int yaffsfs_Match(YCHAR a, YCHAR b)
{
return (yaffs_toupper(a) == yaffs_toupper(b));
}
#else
-int yaffsfs_Match(YCHAR a, YCHAR b)
+static inline int yaffsfs_Match(YCHAR a, YCHAR b)
{
/* case sensitive */
return (a == b);
diff --git a/direct/yaffsfs.h b/direct/yaffsfs.h
index c20da16..eda547f 100644
--- a/direct/yaffsfs.h
+++ b/direct/yaffsfs.h
@@ -34,6 +34,12 @@
( (sizeof(loff_t) < 8) ? YAFFS_MAX_FILE_SIZE_32 : (0x800000000LL - 1) )
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
struct yaffs_dirent {
long d_ino; /* inode number */
off_t d_off; /* offset to this dirent */
@@ -46,7 +52,6 @@ struct yaffs_dirent {
typedef struct opaque_structure yaffs_DIR;
-
struct yaffs_stat {
int st_dev; /* device */
int st_ino; /* inode */
@@ -189,7 +194,6 @@ struct yaffs_dev;
void yaffs_add_device(struct yaffs_dev *dev);
int yaffs_start_up(void);
-int yaffsfs_GetLastError(void);
/* Functions to iterate through devices. NB Use with extreme care! */
void yaffs_dev_rewind(void);
@@ -207,4 +211,9 @@ int yaffs_set_error(int error);
/* Trace control functions */
unsigned yaffs_set_trace(unsigned tm);
unsigned yaffs_get_trace(void);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/direct/yportenv.h b/direct/yportenv.h
index b47a4d6..abc761b 100644
--- a/direct/yportenv.h
+++ b/direct/yportenv.h
@@ -22,7 +22,7 @@
#ifdef CONFIG_YAFFS_DEFINES_TYPES
typedef unsigned char u8;
typedef unsigned short u16;
-typedef unsigned u32;
+typedef unsigned int u32;
#endif
diff --git a/yaffs_checkptrw.c b/yaffs_checkptrw.c
index d897044..926f90c 100644
--- a/yaffs_checkptrw.c
+++ b/yaffs_checkptrw.c
@@ -149,8 +149,8 @@ static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
dev->param.read_chunk_tags_fn(dev, realigned_chunk,
NULL, &tags);
yaffs_trace(YAFFS_TRACE_CHECKPOINT,
- "find next checkpt block: search: block %d state %d oid %d seq %d eccr %d",
- i, (int) state,
+ "find next checkpt block: search: block %d oid %d seq %d eccr %d",
+ i,
tags.obj_id, tags.seq_number,
tags.ecc_result);
diff --git a/yaffs_guts.c b/yaffs_guts.c
index f3bc419..0f1b471 100644
--- a/yaffs_guts.c
+++ b/yaffs_guts.c
@@ -4326,7 +4326,7 @@ static void yaffs_del_dir_contents(struct yaffs_obj *dir)
}
}
-static void yaffs_empty_l_n_f(struct yaffs_dev *dev)
+static inline void yaffs_empty_l_n_f(struct yaffs_dev *dev)
{
yaffs_del_dir_contents(dev->lost_n_found);
}
@@ -5018,7 +5018,10 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev)
void yaffs_oh_size_load(struct yaffs_obj_hdr *oh, loff_t fsize)
{
oh->file_size_low = (fsize & 0xFFFFFFFF);
- oh->file_size_high = ((fsize >> 32) & 0xFFFFFFFF);
+ if (sizeof(loff_t) >= 8)
+ oh->file_size_high = ((fsize >> 32) & 0xFFFFFFFF);
+ else
+ oh->file_size_high = 0;
}
loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh)
diff --git a/yaffs_nand.h b/yaffs_nand.h
index 7134662..4f206c7 100644
--- a/yaffs_nand.h
+++ b/yaffs_nand.h
@@ -29,7 +29,7 @@ int yaffs_mark_bad(struct yaffs_dev *dev, int block_no);
int yaffs_query_init_block_state(struct yaffs_dev *dev,
int block_no,
enum yaffs_block_state *state,
- unsigned *seq_number);
+ u32 *seq_number);
int yaffs_erase_block(struct yaffs_dev *dev, int flash_block);
--
1.7.10
>From a155ba68fad01ed30f287d384d6cd044d287e0ea Mon Sep 17 00:00:00 2001
From: unknown <lesages@.ATEIS>
Date: Mon, 11 Jun 2012 14:12:12 +0200
Subject: [PATCH 2/3] string functions macros with yaffs_ prefix
---
yaffs_guts.c | 38 +++++++++++++++++++-------------------
yaffs_nameval.c | 6 +++---
yportenv_multi.h | 5 +++++
yportenv_single.h | 4 ++++
4 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/yaffs_guts.c b/yaffs_guts.c
index 0f1b471..78554a6 100644
--- a/yaffs_guts.c
+++ b/yaffs_guts.c
@@ -676,9 +676,9 @@ void yaffs_set_obj_name(struct yaffs_obj *obj, const YCHAR * name)
{
memset(obj->short_name, 0, sizeof(obj->short_name));
if (name &&
- strnlen(name, YAFFS_SHORT_NAME_LENGTH + 1) <=
+ yaffs_strnlen(name, YAFFS_SHORT_NAME_LENGTH + 1) <=
YAFFS_SHORT_NAME_LENGTH)
- strcpy(obj->short_name, name);
+ yaffs_strcpy(obj->short_name, name);
else
obj->short_name[0] = _Y('\0');
obj->sum = yaffs_calc_name_sum(name);
@@ -2045,10 +2045,10 @@ YCHAR *yaffs_clone_str(const YCHAR *str)
if (!str)
str = _Y("");
- len = strnlen(str, YAFFS_MAX_ALIAS_LENGTH);
+ len = yaffs_strnlen(str, YAFFS_MAX_ALIAS_LENGTH);
new_str = kmalloc((len + 1) * sizeof(YCHAR), GFP_NOFS);
if (new_str) {
- strncpy(new_str, str, len);
+ yaffs_strncpy(new_str, str, len);
new_str[len] = 0;
}
return new_str;
@@ -3222,14 +3222,14 @@ static void yaffs_load_name_from_oh(struct yaffs_dev *dev, YCHAR *name,
n--;
}
} else {
- strncpy(name, oh_name + 1, buff_size - 1);
+ yaffs_strncpy(name, oh_name + 1, buff_size - 1);
}
} else {
#else
dev = dev;
{
#endif
- strncpy(name, oh_name, buff_size - 1);
+ yaffs_strncpy(name, oh_name, buff_size - 1);
}
}
@@ -3266,14 +3266,14 @@ static void yaffs_load_oh_from_name(struct yaffs_dev *dev, YCHAR *oh_name,
} else {
/* Unicode name, so save starting at the second YCHAR */
*oh_name = 0;
- strncpy(oh_name + 1, name, YAFFS_MAX_NAME_LENGTH - 2);
+ yaffs_strncpy(oh_name + 1, name, YAFFS_MAX_NAME_LENGTH - 2);
}
} else {
#else
dev = dev;
{
#endif
- strncpy(oh_name, name, YAFFS_MAX_NAME_LENGTH - 1);
+ yaffs_strncpy(oh_name, name, YAFFS_MAX_NAME_LENGTH - 1);
}
}
@@ -3298,7 +3298,7 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force,
struct yaffs_obj_hdr *oh = NULL;
loff_t file_size = 0;
- strcpy(old_name, _Y("silly old name"));
+ yaffs_strcpy(old_name, _Y("silly old name"));
if (in->fake && in != dev->root_dir && !force && !xmod)
return ret_val;
@@ -3367,7 +3367,7 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force,
alias = in->variant.symlink_variant.alias;
if (!alias)
alias = _Y("no alias");
- strncpy(oh->alias, alias, YAFFS_MAX_ALIAS_LENGTH);
+ yaffs_strncpy(oh->alias, alias, YAFFS_MAX_ALIAS_LENGTH);
oh->alias[YAFFS_MAX_ALIAS_LENGTH] = 0;
break;
}
@@ -4093,7 +4093,7 @@ int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR *old_name,
force = 1;
#endif
- if (strnlen(new_name, YAFFS_MAX_NAME_LENGTH + 1) >
+ if (yaffs_strnlen(new_name, YAFFS_MAX_NAME_LENGTH + 1) >
YAFFS_MAX_NAME_LENGTH)
/* ENAMETOOLONG */
return YAFFS_FAIL;
@@ -4420,7 +4420,7 @@ static void yaffs_fix_null_name(struct yaffs_obj *obj, YCHAR *name,
int buffer_size)
{
/* Create an object name if we could not find one. */
- if (strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0) {
+ if (yaffs_strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0) {
YCHAR local_name[20];
YCHAR num_string[20];
YCHAR *x = &num_string[19];
@@ -4432,9 +4432,9 @@ static void yaffs_fix_null_name(struct yaffs_obj *obj, YCHAR *name,
v /= 10;
}
/* make up a name */
- strcpy(local_name, YAFFS_LOSTNFOUND_PREFIX);
- strcat(local_name, x);
- strncpy(name, local_name, buffer_size - 1);
+ yaffs_strcpy(local_name, YAFFS_LOSTNFOUND_PREFIX);
+ yaffs_strcat(local_name, x);
+ yaffs_strncpy(name, local_name, buffer_size - 1);
}
}
@@ -4443,9 +4443,9 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size)
memset(name, 0, buffer_size * sizeof(YCHAR));
yaffs_check_obj_details_loaded(obj);
if (obj->obj_id == YAFFS_OBJECTID_LOSTNFOUND) {
- strncpy(name, YAFFS_LOSTNFOUND_NAME, buffer_size - 1);
+ yaffs_strncpy(name, YAFFS_LOSTNFOUND_NAME, buffer_size - 1);
} else if (obj->short_name[0]) {
- strcpy(name, obj->short_name);
+ yaffs_strcpy(name, obj->short_name);
} else if (obj->hdr_chunk > 0) {
int result;
u8 *buffer = yaffs_get_temp_buffer(obj->my_dev);
@@ -4467,7 +4467,7 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size)
yaffs_fix_null_name(obj, name, buffer_size);
- return strnlen(name, YAFFS_MAX_NAME_LENGTH);
+ return yaffs_strnlen(name, YAFFS_MAX_NAME_LENGTH);
}
loff_t yaffs_get_obj_length(struct yaffs_obj *obj)
@@ -4480,7 +4480,7 @@ loff_t yaffs_get_obj_length(struct yaffs_obj *obj)
if (obj->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) {
if (!obj->variant.symlink_variant.alias)
return 0;
- return strnlen(obj->variant.symlink_variant.alias,
+ return yaffs_strnlen(obj->variant.symlink_variant.alias,
YAFFS_MAX_ALIAS_LENGTH);
} else {
/* Only a directory should drop through to here */
diff --git a/yaffs_nameval.c b/yaffs_nameval.c
index 4bdf4ed..362f046 100644
--- a/yaffs_nameval.c
+++ b/yaffs_nameval.c
@@ -90,7 +90,7 @@ int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf,
int bsize, int flags)
{
int pos;
- int namelen = strnlen(name, xb_size);
+ int namelen = yaffs_strnlen(name, xb_size);
int reclen;
int size_exist = 0;
int space;
@@ -120,7 +120,7 @@ int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf,
memcpy(xb + pos, &reclen, sizeof(int));
pos += sizeof(int);
- strncpy((YCHAR *) (xb + pos), name, reclen);
+ yaffs_strncpy((YCHAR *) (xb + pos), name, reclen);
pos += (namelen + 1);
memcpy(xb + pos, buf, bsize);
return 0;
@@ -179,7 +179,7 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize)
!filled) {
pos += sizeof(int);
size -= sizeof(int);
- name_len = strnlen((YCHAR *) (xb + pos), size);
+ name_len = yaffs_strnlen((YCHAR *) (xb + pos), size);
if (ncopied + name_len + 1 < bsize) {
memcpy(buf, xb + pos, name_len * sizeof(YCHAR));
buf += name_len;
diff --git a/yportenv_multi.h b/yportenv_multi.h
index 666d909..10f0755 100644
--- a/yportenv_multi.h
+++ b/yportenv_multi.h
@@ -54,6 +54,11 @@
#define YUCHAR unsigned char
#define _Y(x) x
+#define yaffs_strcat(a, b) strcat(a, b)
+#define yaffs_strcpy(a, b) strcpy(a, b)
+#define yaffs_strncpy(a, b, c) strncpy(a, b, c)
+#define yaffs_strnlen(s, m) strnlen(s, m)
+
#define YAFFS_LOSTNFOUND_NAME "lost+found"
#define YAFFS_LOSTNFOUND_PREFIX "obj"
diff --git a/yportenv_single.h b/yportenv_single.h
index d819475..817db84 100644
--- a/yportenv_single.h
+++ b/yportenv_single.h
@@ -35,6 +35,10 @@
#define YCHAR char
#define YUCHAR unsigned char
#define _Y(x) x
+#define yaffs_strcat(a, b) strcat(a, b)
+#define yaffs_strcpy(a, b) strcpy(a, b)
+#define yaffs_strncpy(a, b, c) strncpy(a, b, c)
+#define yaffs_strnlen(s, m) strnlen(s, m)
#define YAFFS_LOSTNFOUND_NAME "lost+found"
#define YAFFS_LOSTNFOUND_PREFIX "obj"
--
1.7.10
>From c9b27f41dd1555ff10f7833391e85f85041c78cf Mon Sep 17 00:00:00 2001
From: unknown <lesages@lesages>
Date: Mon, 11 Jun 2012 14:16:34 +0200
Subject: [PATCH 3/3] Patch for more customization of ydirectenv.h from user
defined configuration in yaffscg.h, and remove debug
functions
---
direct/yaffscfg.h | 16 +++++++-
direct/yaffsfs.c | 26 +++++++------
direct/yaffsfs.h | 6 ++-
direct/ydirectenv.h | 105 +++++++++++++++++++++++++++++++++++----------------
direct/yportenv.h | 20 +++++++---
5 files changed, 121 insertions(+), 52 deletions(-)
diff --git a/direct/yaffscfg.h b/direct/yaffscfg.h
index 671496b..7170f33 100644
--- a/direct/yaffscfg.h
+++ b/direct/yaffscfg.h
@@ -22,12 +22,24 @@
#ifndef __YAFFSCFG_H__
#define __YAFFSCFG_H__
-
-#include "yportenv.h"
+/* YAFFS File System Settings */
#define YAFFSFS_N_HANDLES 100
#define YAFFSFS_N_DSC 20
+/*
+ * Configure YAFFS for your platform here.
+ *
+ * insert your includes
+ * define mode_t, dev_t, off_t and loff_t types
+ * define inline for your compiler
+ * define hweight8(x) and hweight32(x) if you have intrinsics to count "one" bits
+ * you may want to place column_parity_table[] in a fast memory section
+ * customize Y_CURRENT_TIME, YAFFS_PATH_DIVIDERS, BUG()
+ * ...
+ * look at ydirectenv.h for more information on what you can customize
+ *
+ */
#endif
diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c
index 0538ce6..7c16340 100644
--- a/direct/yaffsfs.c
+++ b/direct/yaffsfs.c
@@ -96,17 +96,6 @@ static struct yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES];
static int yaffsfs_handlesInitialised;
-unsigned yaffs_set_trace(unsigned tm)
-{
- yaffs_trace_mask = tm;
- return yaffs_trace_mask;
-}
-
-unsigned yaffs_get_trace(void)
-{
- return yaffs_trace_mask;
-}
-
/*
* yaffsfs_InitHandle
* Inilitalise handle management on start-up.
@@ -3141,6 +3130,8 @@ int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev)
return -1;
}
+#ifdef CONFIG_YAFFS_DEBUG
+
/*
* D E B U G F U N C T I O N S
*/
@@ -3171,6 +3162,17 @@ int yaffs_n_handles(const YCHAR *path)
return -1;
}
+unsigned yaffs_set_trace(unsigned tm)
+{
+ yaffs_trace_mask = tm;
+ return yaffs_trace_mask;
+}
+
+unsigned yaffs_get_trace(void)
+{
+ return yaffs_trace_mask;
+}
+
int yaffs_get_error(void)
{
return yaffsfs_GetLastError();
@@ -3212,3 +3214,5 @@ int yaffs_dump_dev(const YCHAR *path)
#endif
return 0;
}
+
+#endif
diff --git a/direct/yaffsfs.h b/direct/yaffsfs.h
index eda547f..8655104 100644
--- a/direct/yaffsfs.h
+++ b/direct/yaffsfs.h
@@ -22,10 +22,8 @@
#ifndef __YAFFSFS_H__
#define __YAFFSFS_H__
-#include "yaffscfg.h"
#include "yportenv.h"
-
#ifndef NAME_MAX
#define NAME_MAX 256
#endif
@@ -203,6 +201,8 @@ struct yaffs_dev *yaffs_next_dev(void);
int yaffs_get_error(void);
const char *yaffs_error_to_str(int err);
+#ifdef CONFIG_YAFFS_DEBUG
+
/* Function only for debugging */
void *yaffs_getdev(const YCHAR *path);
int yaffs_dump_dev(const YCHAR *path);
@@ -212,6 +212,8 @@ int yaffs_set_error(int error);
unsigned yaffs_set_trace(unsigned tm);
unsigned yaffs_get_trace(void);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/direct/ydirectenv.h b/direct/ydirectenv.h
index eff8ff9..2cf27e5 100644
--- a/direct/ydirectenv.h
+++ b/direct/ydirectenv.h
@@ -23,74 +23,115 @@
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
+
+#include "yaffscfg.h"
#include "yaffs_osglue.h"
-#include "yaffs_hweight.h"
-void yaffs_bug_fn(const char *file_name, int line_no);
+#ifdef NO_inline
+#define inline
+#else
+#ifndef inline
+#define inline __inline__
+#endif
+#endif
+#ifndef BUG
+void yaffs_bug_fn(const char *file_name, int line_no);
#define BUG() do { yaffs_bug_fn(__FILE__, __LINE__); } while (0)
+#endif
-
+#ifndef YCHAR
#define YCHAR char
+#endif
+#ifndef YUCHAR
#define YUCHAR unsigned char
+#endif
+#ifndef _Y
#define _Y(x) x
+#endif
-#define yaffs_strcat(a, b) strcat(a, b)
-#define yaffs_strcpy(a, b) strcpy(a, b)
+#ifndef yaffs_strcat
+#define yaffs_strcat(a, b) strcat(a, b)
+#endif
+#ifndef yaffs_strcpy
+#define yaffs_strcpy(a, b) strcpy(a, b)
+#endif
+#ifndef yaffs_strncpy
#define yaffs_strncpy(a, b, c) strncpy(a, b, c)
-#define yaffs_strnlen(s, m) strnlen(s, m)
+#endif
+#ifndef yaffs_strnlen
+#define yaffs_strnlen(s, m) strnlen(s, m)
+#endif
+
#ifdef CONFIG_YAFFS_CASE_INSENSITIVE
-#define yaffs_strcmp(a, b) strcasecmp(a, b)
+#ifndef yaffs_strcmp
+#define yaffs_strcmp(a, b) strcasecmp(a, b)
+#endif
+#ifndef yaffs_strncmp
#define yaffs_strncmp(a, b, c) strncasecmp(a, b, c)
+#endif
#else
-#define yaffs_strcmp(a, b) strcmp(a, b)
+#ifndef yaffs_strcmp
+#define yaffs_strcmp(a, b) strcmp(a, b)
+#endif
+#ifndef yaffs_strncmp
#define yaffs_strncmp(a, b, c) strncmp(a, b, c)
#endif
+#endif
-#define hweight8(x) yaffs_hweight8(x)
+#ifndef hweight8
+#include "yaffs_hweight.h"
+#define hweight8(x) yaffs_hweight8(x)
+#endif
+#ifndef hweight32
+#include "yaffs_hweight.h"
#define hweight32(x) yaffs_hweight32(x)
+#endif
void yaffs_qsort(void *aa, size_t n, size_t es,
int (*cmp)(const void *, const void *));
#define sort(base, n, sz, cmp_fn, swp) yaffs_qsort(base, n, sz, cmp_fn)
-#define YAFFS_PATH_DIVIDERS "/"
+#ifndef YAFFS_PATH_DIVIDERS
+#define YAFFS_PATH_DIVIDERS "/"
+#endif
+#ifndef YAFFS_LOSTNFOUND_NAME
+#define YAFFS_LOSTNFOUND_NAME "lost+found"
+#endif
+#ifndef YAFFS_LOSTNFOUND_PREFIX
+#define YAFFS_LOSTNFOUND_PREFIX "obj"
+#endif
-#ifdef NO_inline
-#define inline
-#else
-#define inline __inline__
+#ifndef Y_CURRENT_TIME
+#define Y_CURRENT_TIME yaffsfs_CurrentTime()
#endif
+#ifndef Y_TIME_CONVERT
+#define Y_TIME_CONVERT(x) x
+#endif
+
+#define YAFFS_ROOT_MODE 0666
+#define YAFFS_LOSTNFOUND_MODE 0666
-#define kmalloc(x, flags) yaffsfs_malloc(x)
-#define kfree(x) yaffsfs_free(x)
-#define vmalloc(x) yaffsfs_malloc(x)
-#define vfree(x) yaffsfs_free(x)
+#define kmalloc(x, flags) yaffsfs_malloc(x)
+#define kfree(x) yaffsfs_free(x)
+#define vmalloc(x) yaffsfs_malloc(x)
+#define vfree(x) yaffsfs_free(x)
#define cond_resched() do {} while (0)
+#ifdef CONFIG_YAFFS_DEBUG
#define yaffs_trace(msk, fmt, ...) do { \
if (yaffs_trace_mask & (msk)) \
printf("yaffs: " fmt "\n", ##__VA_ARGS__); \
} while (0)
-
-
-#define YAFFS_LOSTNFOUND_NAME "lost+found"
-#define YAFFS_LOSTNFOUND_PREFIX "obj"
-
-#include "yaffscfg.h"
-
-#define Y_CURRENT_TIME yaffsfs_CurrentTime()
-#define Y_TIME_CONVERT(x) x
-
-#define YAFFS_ROOT_MODE 0666
-#define YAFFS_LOSTNFOUND_MODE 0666
+#else
+#define yaffs_trace(msk, fmt, ...) do { \
+} while (0)
+#endif
#include "yaffs_list.h"
#include "yaffsfs.h"
#endif
-
-
diff --git a/direct/yportenv.h b/direct/yportenv.h
index abc761b..88806d8 100644
--- a/direct/yportenv.h
+++ b/direct/yportenv.h
@@ -19,6 +19,7 @@
/* Definition of types */
+
#ifdef CONFIG_YAFFS_DEFINES_TYPES
typedef unsigned char u8;
typedef unsigned short u16;
@@ -26,9 +27,11 @@ typedef unsigned int u32;
#endif
+/* Definitions */
+
#ifdef CONFIG_YAFFS_PROVIDE_DEFS
-/* File types */
+/* File types */
#define DT_UNKNOWN 0
#define DT_FIFO 1
@@ -40,7 +43,6 @@ typedef unsigned int u32;
#define DT_SOCK 12
#define DT_WHT 14
-
/*
* Attribute flags.
* These are or-ed together to select what has been changed.
@@ -68,15 +70,14 @@ struct iattr {
#endif
+/* Configuration */
#if defined CONFIG_YAFFS_WINCE
#include "ywinceenv.h"
-
#elif defined CONFIG_YAFFS_DIRECT
-/* Direct interface */
#include "ydirectenv.h"
#elif defined CONFIG_YAFFS_UTIL
@@ -84,15 +85,20 @@ struct iattr {
#include "yutilsenv.h"
#else
-/* Should have specified a configuration type */
+
#error Unknown configuration
#endif
+
+/* Provide flags/error/mode values */
+
#if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
#ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
+/* Open flags */
+
#ifndef O_RDONLY
#define O_RDONLY 00
#endif
@@ -133,6 +139,8 @@ struct iattr {
#define SEEK_END 2
#endif
+/* Errors */
+
#ifndef EBUSY
#define EBUSY 16
#endif
@@ -285,9 +293,11 @@ struct iattr {
#endif
#else
+
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
+
#endif
#endif
--
1.7.10