2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
\r
5 * Copyright (C) 2002 Aleph One Ltd.
\r
6 * for Toby Churchill Ltd and Brightstar Engineering
\r
8 * Created by Charles Manning <charles@aleph1.co.uk>
\r
10 * This program is free software; you can redistribute it and/or modify
\r
11 * it under the terms of the GNU Lesser General Public License version 2.1 as
\r
12 * published by the Free Software Foundation.
\r
14 * This file is just holds extra declarations used during development.
\r
15 * Most of these are from kernel includes placed here so we can use them in
\r
20 #ifndef __EXTRAS_H__
\r
21 #define __EXTRAS_H__
\r
24 #define __inline__ __inline
\r
28 #if !(defined __KERNEL__) || (defined WIN32)
\r
30 // User space defines
\r
32 typedef unsigned char __u8;
\r
33 typedef unsigned short __u16;
\r
34 typedef unsigned __u32;
\r
38 * Simple doubly linked list implementation.
\r
40 * Some of the internal functions ("__xxx") are useful when
\r
41 * manipulating whole lists rather than single entries, as
\r
42 * sometimes we already know the next/prev entries and we can
\r
43 * generate better code by using them directly rather than
\r
44 * using the generic single-entry routines.
\r
47 #define prefetch(x) 1
\r
51 struct list_head *next, *prev;
\r
54 #define LIST_HEAD_INIT(name) { &(name), &(name) }
\r
56 #define LIST_HEAD(name) \
\r
57 struct list_head name = LIST_HEAD_INIT(name)
\r
59 #define INIT_LIST_HEAD(ptr) do { \
\r
60 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
\r
64 * Insert a new entry between two known consecutive entries.
\r
66 * This is only for internal list manipulation where we know
\r
67 * the prev/next entries already!
\r
69 static __inline__ void __list_add(struct list_head * new,
\r
70 struct list_head * prev,
\r
71 struct list_head * next)
\r
80 * list_add - add a new entry
\r
81 * @new: new entry to be added
\r
82 * @head: list head to add it after
\r
84 * Insert a new entry after the specified head.
\r
85 * This is good for implementing stacks.
\r
87 static __inline__ void list_add(struct list_head *new, struct list_head *head)
\r
89 __list_add(new, head, head->next);
\r
93 * list_add_tail - add a new entry
\r
94 * @new: new entry to be added
\r
95 * @head: list head to add it before
\r
97 * Insert a new entry before the specified head.
\r
98 * This is useful for implementing queues.
\r
100 static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
\r
102 __list_add(new, head->prev, head);
\r
106 * Delete a list entry by making the prev/next entries
\r
107 * point to each other.
\r
109 * This is only for internal list manipulation where we know
\r
110 * the prev/next entries already!
\r
112 static __inline__ void __list_del(struct list_head * prev,
\r
113 struct list_head * next)
\r
120 * list_del - deletes entry from list.
\r
121 * @entry: the element to delete from the list.
\r
122 * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
\r
124 static __inline__ void list_del(struct list_head *entry)
\r
126 __list_del(entry->prev, entry->next);
\r
130 * list_del_init - deletes entry from list and reinitialize it.
\r
131 * @entry: the element to delete from the list.
\r
133 static __inline__ void list_del_init(struct list_head *entry)
\r
135 __list_del(entry->prev, entry->next);
\r
136 INIT_LIST_HEAD(entry);
\r
140 * list_empty - tests whether a list is empty
\r
141 * @head: the list to test.
\r
143 static __inline__ int list_empty(struct list_head *head)
\r
145 return head->next == head;
\r
149 * list_splice - join two lists
\r
150 * @list: the new list to add.
\r
151 * @head: the place to add it in the first list.
\r
153 static __inline__ void list_splice(struct list_head *list, struct list_head *head)
\r
155 struct list_head *first = list->next;
\r
157 if (first != list) {
\r
158 struct list_head *last = list->prev;
\r
159 struct list_head *at = head->next;
\r
161 first->prev = head;
\r
162 head->next = first;
\r
170 * list_entry - get the struct for this entry
\r
171 * @ptr: the &struct list_head pointer.
\r
172 * @type: the type of the struct this is embedded in.
\r
173 * @member: the name of the list_struct within the struct.
\r
175 #define list_entry(ptr, type, member) \
\r
176 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
\r
179 * list_for_each - iterate over a list
\r
180 * @pos: the &struct list_head to use as a loop counter.
\r
181 * @head: the head for your list.
\r
183 #define list_for_each(pos, head) \
\r
184 for (pos = (head)->next, prefetch(pos->next); pos != (head); \
\r
185 pos = pos->next, prefetch(pos->next))
\r
188 * list_for_each_safe - iterate over a list safe against removal of list entry
\r
189 * @pos: the &struct list_head to use as a loop counter.
\r
190 * @n: another &struct list_head to use as temporary storage
\r
191 * @head: the head for your list.
\r
193 #define list_for_each_safe(pos, n, head) \
\r
194 for (pos = (head)->next, n = pos->next; pos != (head); \
\r
195 pos = n, n = pos->next)
\r
203 #define DT_UNKNOWN 0
\r
214 #include <sys/stat.h>
\r
218 * Attribute flags. These should be or-ed together to figure out what
\r
219 * has been changed!
\r
221 #define ATTR_MODE 1
\r
224 #define ATTR_SIZE 8
\r
225 #define ATTR_ATIME 16
\r
226 #define ATTR_MTIME 32
\r
227 #define ATTR_CTIME 64
\r
228 #define ATTR_ATIME_SET 128
\r
229 #define ATTR_MTIME_SET 256
\r
230 #define ATTR_FORCE 512 /* Not a change, but a change it */
\r
231 #define ATTR_ATTR_FLAG 1024
\r
235 unsigned int ia_valid;
\r
243 unsigned int ia_attr_flags;
\r
252 #include <linux/types.h>
\r
253 #include <linux/list.h>
\r
254 #include <linux/fs.h>
\r
255 #include <linux/stat.h>
\r