>From c9b27f41dd1555ff10f7833391e85f85041c78cf Mon Sep 17 00:00:00 2001 From: unknown 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 #include #include + #endif #endif -- 1.7.10