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 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
\r
16 * This file is just holds extra declarations used during development.
\r
17 * Most of these are from kernel includes placed here so we can use them in
\r
22 #ifndef __EXTRAS_H__
\r
23 #define __EXTRAS_H__
\r
26 #define __inline__ __inline
\r
30 #if !(defined __KERNEL__) || (defined WIN32)
\r
32 // User space defines
\r
34 typedef unsigned char __u8;
\r
35 typedef unsigned short __u16;
\r
36 typedef unsigned __u32;
\r
40 * Simple doubly linked list implementation.
\r
42 * Some of the internal functions ("__xxx") are useful when
\r
43 * manipulating whole lists rather than single entries, as
\r
44 * sometimes we already know the next/prev entries and we can
\r
45 * generate better code by using them directly rather than
\r
46 * using the generic single-entry routines.
\r
49 #define prefetch(x) 1
\r
53 struct list_head *next, *prev;
\r
56 #define LIST_HEAD_INIT(name) { &(name), &(name) }
\r
58 #define LIST_HEAD(name) \
\r
59 struct list_head name = LIST_HEAD_INIT(name)
\r
61 #define INIT_LIST_HEAD(ptr) do { \
\r
62 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
\r
66 * Insert a new entry between two known consecutive entries.
\r
68 * This is only for internal list manipulation where we know
\r
69 * the prev/next entries already!
\r
71 static __inline__ void __list_add(struct list_head * new,
\r
72 struct list_head * prev,
\r
73 struct list_head * next)
\r
82 * list_add - add a new entry
\r
83 * @new: new entry to be added
\r
84 * @head: list head to add it after
\r
86 * Insert a new entry after the specified head.
\r
87 * This is good for implementing stacks.
\r
89 static __inline__ void list_add(struct list_head *new, struct list_head *head)
\r
91 __list_add(new, head, head->next);
\r
95 * list_add_tail - add a new entry
\r
96 * @new: new entry to be added
\r
97 * @head: list head to add it before
\r
99 * Insert a new entry before the specified head.
\r
100 * This is useful for implementing queues.
\r
102 static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
\r
104 __list_add(new, head->prev, head);
\r
108 * Delete a list entry by making the prev/next entries
\r
109 * point to each other.
\r
111 * This is only for internal list manipulation where we know
\r
112 * the prev/next entries already!
\r
114 static __inline__ void __list_del(struct list_head * prev,
\r
115 struct list_head * next)
\r
122 * list_del - deletes entry from list.
\r
123 * @entry: the element to delete from the list.
\r
124 * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
\r
126 static __inline__ void list_del(struct list_head *entry)
\r
128 __list_del(entry->prev, entry->next);
\r
132 * list_del_init - deletes entry from list and reinitialize it.
\r
133 * @entry: the element to delete from the list.
\r
135 static __inline__ void list_del_init(struct list_head *entry)
\r
137 __list_del(entry->prev, entry->next);
\r
138 INIT_LIST_HEAD(entry);
\r
142 * list_empty - tests whether a list is empty
\r
143 * @head: the list to test.
\r
145 static __inline__ int list_empty(struct list_head *head)
\r
147 return head->next == head;
\r
151 * list_splice - join two lists
\r
152 * @list: the new list to add.
\r
153 * @head: the place to add it in the first list.
\r
155 static __inline__ void list_splice(struct list_head *list, struct list_head *head)
\r
157 struct list_head *first = list->next;
\r
159 if (first != list) {
\r
160 struct list_head *last = list->prev;
\r
161 struct list_head *at = head->next;
\r
163 first->prev = head;
\r
164 head->next = first;
\r
172 * list_entry - get the struct for this entry
\r
173 * @ptr: the &struct list_head pointer.
\r
174 * @type: the type of the struct this is embedded in.
\r
175 * @member: the name of the list_struct within the struct.
\r
177 #define list_entry(ptr, type, member) \
\r
178 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
\r
181 * list_for_each - iterate over a list
\r
182 * @pos: the &struct list_head to use as a loop counter.
\r
183 * @head: the head for your list.
\r
185 #define list_for_each(pos, head) \
\r
186 for (pos = (head)->next, prefetch(pos->next); pos != (head); \
\r
187 pos = pos->next, prefetch(pos->next))
\r
190 * list_for_each_safe - iterate over a list safe against removal of list entry
\r
191 * @pos: the &struct list_head to use as a loop counter.
\r
192 * @n: another &struct list_head to use as temporary storage
\r
193 * @head: the head for your list.
\r
195 #define list_for_each_safe(pos, n, head) \
\r
196 for (pos = (head)->next, n = pos->next; pos != (head); \
\r
197 pos = n, n = pos->next)
\r
205 #define DT_UNKNOWN 0
\r
216 #include <sys/stat.h>
\r
220 * Attribute flags. These should be or-ed together to figure out what
\r
221 * has been changed!
\r
223 #define ATTR_MODE 1
\r
226 #define ATTR_SIZE 8
\r
227 #define ATTR_ATIME 16
\r
228 #define ATTR_MTIME 32
\r
229 #define ATTR_CTIME 64
\r
230 #define ATTR_ATIME_SET 128
\r
231 #define ATTR_MTIME_SET 256
\r
232 #define ATTR_FORCE 512 /* Not a change, but a change it */
\r
233 #define ATTR_ATTR_FLAG 1024
\r
237 unsigned int ia_valid;
\r
245 unsigned int ia_attr_flags;
\r
254 #include <linux/types.h>
\r
255 #include <linux/list.h>
\r
256 #include <linux/fs.h>
\r
257 #include <linux/stat.h>
\r