2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
4 * Copyright (C) 2002-2007 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Charles Manning <charles@aleph1.co.uk>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License version 2.1 as
11 * published by the Free Software Foundation.
13 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
17 * This file is just holds extra declarations of macros that would normally
18 * be providesd in the Linux kernel. These macros have been written from
19 * scratch but are functionally equivalent to the Linux ones.
23 #ifndef __EXTRAS_H__
\r
24 #define __EXTRAS_H__
\r
27 #if !(defined __KERNEL__)
\r
29 /* Definition of types */
30 typedef unsigned char __u8;
\r
31 typedef unsigned short __u16;
\r
32 typedef unsigned __u32;
\r
37 * This is a simple doubly linked list implementation that matches the
\r
38 * way the Linux kernel doubly linked list implementation works.
\r
42 struct ylist_head *next; /* next in chain */
43 struct ylist_head *prev; /* previous in chain */
47 /* Initialise a list head to an empty list */
\r
48 #define YINIT_LIST_HEAD(p) \
55 /* Add an element to a list */
\r
56 static __inline__ void ylist_add(struct ylist_head *newEntry,
57 struct ylist_head *list)
59 struct ylist_head *listNext = list->next;
61 list->next = newEntry;
\r
62 newEntry->prev = list;
\r
63 newEntry->next = listNext;
64 listNext->prev = newEntry;
69 /* Take an element out of its current list, with or without
\r
70 * reinitialising the links.of the entry*/
\r
71 static __inline__ void ylist_del(struct ylist_head *entry)
73 struct ylist_head *listNext = entry->next;
74 struct ylist_head *listPrev = entry->prev;
76 listNext->prev = listPrev;
\r
77 listPrev->next = listNext;
\r
81 static __inline__ void ylist_del_init(struct ylist_head *entry)
84 entry->next = entry->prev = entry;
\r
88 /* Test if the list is empty */
\r
89 static __inline__ int ylist_empty(struct ylist_head *entry)
91 return (entry->next == entry);
\r
95 /* ylist_entry takes a pointer to a list entry and offsets it to that
96 * we can find a pointer to the object it is embedded in.
\r
100 #define ylist_entry(entry, type, member) \
101 ((type *)((char *)(entry)-(unsigned long)(&((type *)NULL)->member)))
\r
104 /* ylist_for_each and list_for_each_safe iterate over lists.
105 * ylist_for_each_safe uses temporary storage to make the list delete safe
108 #define ylist_for_each(itervar, list) \
109 for (itervar = (list)->next; itervar != (list); itervar = itervar->next )
\r
111 #define ylist_for_each_safe(itervar,saveVar, list) \
112 for (itervar = (list)->next, saveVar = (list)->next->next; itervar != (list); \
\r
113 itervar = saveVar, saveVar = saveVar->next)
\r
116 #if !(defined __KERNEL__)
120 #include <sys/stat.h>
124 #ifdef CONFIG_YAFFS_PROVIDE_DEFS
128 #define DT_UNKNOWN 0
\r
140 #include <sys/stat.h>
\r
144 * Attribute flags. These should be or-ed together to figure out what
\r
145 * has been changed!
\r
147 #define ATTR_MODE 1
\r
151 #define ATTR_ATIME 16
152 #define ATTR_MTIME 32
153 #define ATTR_CTIME 64
156 unsigned int ia_valid;
164 unsigned int ia_attr_flags;
\r
174 #include <linux/types.h>
\r
175 #include <linux/fs.h>
\r
176 #include <linux/stat.h>
\r