1 #ifndef __LINUX_JFFS2PORT_H__
2 #define __LINUX_JFFS2PORT_H__
6 #include <pkgconf/system.h>
7 #include <pkgconf/hal.h>
8 //#include <pkgconf/kernel.h>
9 #include <pkgconf/io_fileio.h>
10 //#include <pkgconf/fs_ram.h>
12 #include <cyg/infra/cyg_trac.h> // tracing macros
13 #include <cyg/infra/cyg_ass.h> // assertion macros
16 #include <sys/types.h>
25 #include <cyg/fileio/fileio.h>
27 #include <cyg/hal/drv_api.h>
28 #include <cyg/infra/diag.h>
30 #include <cyg/io/flash.h>
32 #include <pkgconf/fs_jffs2.h>
33 #include <linux/types.h>
34 #include <linux/list.h>
37 #define printf diag_printf
39 // Structures used by VFS
41 typedef unsigned short kdev_t;
44 const unsigned char * name;
49 #define DNAME_INLINE_LEN 16
54 struct inode * d_inode; /* Where the name belongs to - NULL is negative */
55 struct dentry * d_parent; /* parent directory */
56 struct list_head d_hash; /* lookup hash list */
57 struct list_head d_child; /* child of parent list */
58 struct list_head d_subdirs; /* our children */
59 struct list_head d_alias; /* inode alias list */
61 struct dentry_operations *d_op;
62 struct super_block * d_sb; /* The root of the dentry tree */
63 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
67 struct dentry *f_dentry;
71 unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
81 #define ATTR_ATIME_SET 128
82 #define ATTR_MTIME_SET 256
83 #define ATTR_FORCE 512 /* Not a change, but a change it */
84 #define ATTR_ATTR_FLAG 1024
86 typedef unsigned short umode_t;
89 unsigned int ia_valid;
105 struct dentry *dentry;
111 struct file_operations {
112 //struct module *owner;
113 //loff_t (*llseek) (struct file *, loff_t, int);
114 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
115 //ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
116 int (*readdir) (struct file *, char *, int);
117 //unsigned int (*poll) (struct file *, struct poll_table_struct *);
118 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
119 //int (*mmap) (struct file *, struct vm_area_struct *);
120 //int (*open) (struct inode *, struct file *);
121 //int (*flush) (struct file *);
122 //int (*release) (struct inode *, struct file *);
123 int (*fsync) (struct file *, struct dentry *, int datasync);
124 //int (*fasync) (int, struct file *, int);
125 //int (*lock) (struct file *, int, struct file_lock *);
126 //ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
127 //ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
130 struct inode_operations {
131 int (*create) (struct inode *,struct dentry *,int);
132 struct dentry * (*lookup) (struct inode *,struct dentry *);
133 int (*link) (struct dentry *,struct inode *,struct dentry *);
134 int (*unlink) (struct inode *,struct dentry *);
135 int (*symlink) (struct inode *,struct dentry *,const char *);
136 int (*mkdir) (struct inode *,struct dentry *,int);
137 int (*rmdir) (struct inode *,struct dentry *);
138 int (*mknod) (struct inode *,struct dentry *,int,int);
139 int (*rename) (struct inode *, struct dentry *,
140 struct inode *, struct dentry *);
141 int (*readlink) (struct dentry *, char *,int);
142 int (*follow_link) (struct dentry *, struct nameidata *);
143 //void (*truncate) (struct inode *);
144 int (*permission) (struct inode *, int);
145 //int (*revalidate) (struct dentry *);
146 int (*setattr) (struct dentry *, struct iattr *);
147 //int (*getattr) (struct dentry *, struct iattr *);
159 #define to_kdev_t(rdev) (rdev)
160 #define MAJOR(rdev) (rdev)>>8
161 #define MINOR(rdev) (rdev)
163 #define page_address(page) ((page)->virtual)
165 static __inline__ void * kmap(struct page * page) {
166 return page_address(page);
169 #define kunmap(page) do { } while (0)
171 //struct page * read_cache_page(cyg_uint32 start, void * f, struct inode * i);
172 struct page *read_cache_page(unsigned long index, int (*filler)(void *,struct page*), void *data);
173 void page_cache_release(struct page * pg);
175 struct inode * new_inode(struct super_block *sb);
176 struct inode * iget(struct super_block *sb, cyg_uint32 ino);
177 void iput(struct inode * i);
178 void make_bad_inode(struct inode * inode);
179 int is_bad_inode(struct inode * inode);
181 #define insert_inode_hash(inode) do { } while (0)
183 #define d_alloc_root(root_inode) root_inode
185 #define flush_dcache_page(page) do { } while (0)
187 struct jffs2_sb_info;
188 struct jffs2_eraseblock;
190 cyg_bool jffs2_flash_read(struct jffs2_sb_info *c, cyg_uint32 read_buffer_offset, const size_t size, size_t * return_size, char * write_buffer);
191 cyg_bool jffs2_flash_write(struct jffs2_sb_info *c, cyg_uint32 write_buffer_offset, const size_t size, size_t * return_size, char * read_buffer);
192 int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen);
193 cyg_bool jffs2_flash_erase(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
199 struct inode *jffs2_lookup(struct inode *dir_i, struct qstr *name);
200 int jffs2_readdir (struct inode *d_inode, unsigned long f_pos, char *nbuf, int nlen);
201 int jffs2_create(struct inode *dir_i, struct qstr *d_name, int mode, struct inode **new_i);
202 int jffs2_mkdir (struct inode *dir_i, struct qstr *d_name, int mode, struct inode **new_i);
203 int jffs2_link (struct inode *old_d_inode, struct inode *dir_i, struct qstr *d_name);
204 int jffs2_unlink(struct inode *dir_i, struct inode *d_inode, struct qstr *d_name);
205 int jffs2_rmdir (struct inode *dir_i, struct inode *d_inode, struct qstr *d_name);
206 int jffs2_rename (struct inode *old_dir_i, struct inode *d_inode, struct qstr *old_d_name,
207 struct inode *new_dir_i, struct qstr *new_d_name);
209 #define init_name_hash() 0
210 static inline unsigned long partial_name_hash(unsigned long c, unsigned long prevhash)
212 prevhash = (prevhash << 4) | (prevhash >> (8*sizeof(unsigned long)-4));
216 static inline unsigned long end_name_hash(unsigned long hash)
218 if (sizeof(hash) > sizeof(unsigned int))
219 hash += hash >> 4*sizeof(hash);
220 return (unsigned int) hash;
223 static inline unsigned int full_name_hash(const unsigned char * name, unsigned int len) {
225 unsigned long hash = init_name_hash();
227 hash = partial_name_hash(*name++, hash);
228 return end_name_hash(hash);
231 #endif /* __LINUX_JFFS2PORT_H__ */