1 /* 2 * JFFS2 -- Journalling Flash File System, Version 2. 3 * 4 * Copyright (C) 2002-2003 Free Software Foundation, Inc. 5 * 6 * Created by David Woodhouse <dwmw2@cambridge.redhat.com> 7 * 8 * For licensing information, see the file 'LICENCE' in this directory. 9 * 10 * $Id: os-ecos.h,v 1.24 2005/02/09 09:23:55 pavlov Exp $ 11 * 12 */ 13 14 #ifndef __JFFS2_OS_ECOS_H__ 15 #define __JFFS2_OS_ECOS_H__ 16 #include <asm/atomic.h> 17 #include <linux/compiler.h> 18 #include <string.h> 19 #include <linux/types.h> 20 #include "jffs2_config.h" 21 #include "los_event.h" 22 #include "los_mux.h" 23 #include "los_task.h" 24 #include "errno.h" 25 #include "jffs2_fs_i.h" 26 #include "jffs2_fs_sb.h" 27 #include "fileio.h" 28 #include "sys/uio.h" 29 30 #ifdef __cplusplus 31 #if __cplusplus 32 extern "C" { 33 #endif /* __cplusplus */ 34 #endif /* __cplusplus */ 35 36 struct jffs2_dirent { 37 #ifdef CYGPKG_FILEIO_DIRENT_DTYPE 38 39 unsigned long d_type; // Only supported with FATFS, RAMFS, ROMFS, 40 // and JFFS2. 41 // d_type is not part of POSIX so 42 // should be used with caution. 43 #endif 44 char d_name[JFFS2_NAME_MAX+1]; 45 }; 46 47 struct _inode; 48 struct super_block; 49 full_name_hash(const unsigned char * name,unsigned int len)50static inline unsigned int full_name_hash(const unsigned char * name, unsigned int len) { 51 52 unsigned hash = 0; 53 while (len--) { 54 hash = (hash << 4) | (hash >> 28); 55 hash ^= *(name++); 56 } 57 return hash; 58 } 59 60 #ifdef CYGOPT_FS_JFFS2_WRITE 61 #define jffs2_is_readonly(c) (0) 62 #else 63 #define jffs2_is_readonly(c) (1) 64 #endif 65 66 #define JFFS2_INODE_INFO(i) (&(i)->jffs2_i) 67 #define OFNI_EDONI_2SFFJ(f) \ 68 ((struct _inode *) ( ((char *)f) - ((char *)(&((struct _inode *)NULL)->jffs2_i)) ) ) 69 70 #define JFFS2_F_I_SIZE(f) (OFNI_EDONI_2SFFJ(f)->i_size) 71 #define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode) 72 #define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid) 73 #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid) 74 #define JFFS2_F_I_CTIME(f) (OFNI_EDONI_2SFFJ(f)->i_ctime) 75 #define JFFS2_F_I_MTIME(f) (OFNI_EDONI_2SFFJ(f)->i_mtime) 76 #define JFFS2_F_I_ATIME(f) (OFNI_EDONI_2SFFJ(f)->i_atime) 77 78 #define JFFS2_F_I_RDEV_MIN(f) ((OFNI_EDONI_2SFFJ(f)->i_rdev)&0xff) 79 #define JFFS2_F_I_RDEV_MAJ(f) ((OFNI_EDONI_2SFFJ(f)->i_rdev)>>8) 80 81 #define get_seconds jffs2_get_timestamp 82 83 struct _inode { 84 uint32_t i_ino; 85 int i_count; 86 mode_t i_mode; 87 nlink_t i_nlink; // Could we dispense with this? 88 uid_t i_uid; 89 gid_t i_gid; 90 time_t i_atime; 91 time_t i_mtime; 92 time_t i_ctime; 93 // union { 94 unsigned short i_rdev; // For devices only 95 struct _inode * i_parent; // For directories only 96 off_t i_size; // For files only 97 // }; 98 struct super_block * i_sb; 99 100 struct jffs2_inode_info jffs2_i; 101 102 struct _inode * i_cache_prev; // We need doubly-linked? 103 struct _inode * i_cache_next; 104 }; 105 106 #define JFFS2_SB_INFO(sb) (&(sb)->jffs2_sb) 107 #define OFNI_BS_2SFFJ(c) \ 108 ((struct super_block *) ( ((char *)c) - ((char *)(&((struct super_block *)NULL)->jffs2_sb)) ) ) 109 typedef void* cyg_io_handle_t; 110 111 struct super_block { 112 struct jffs2_sb_info jffs2_sb; 113 struct _inode * s_root; 114 unsigned long s_mount_count; 115 cyg_io_handle_t s_dev; 116 117 #ifdef CYGOPT_FS_JFFS2_GCTHREAD 118 UINT32 s_lock; // Lock the inode cache 119 EVENT_CB_S s_gc_thread_flags; // Communication with the gcthread 120 unsigned int s_gc_thread; 121 #endif 122 123 }; 124 125 #ifndef BUG_ON 126 #define BUG_ON(x) do {if (unlikely(x)) BUG();} while (0) 127 #endif 128 129 // fs-ecos.c 130 131 int jffs2_oflag_to_accmode(int oflags); 132 133 134 #ifdef __cplusplus 135 #if __cplusplus 136 } 137 #endif /* __cplusplus */ 138 #endif /* __cplusplus */ 139 140 #endif /* __JFFS2_OS_ECOS_H__ */ 141