2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 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.
27 #if !(defined __KERNEL__)
29 /* Definition of types */
30 typedef unsigned char __u8;
31 typedef unsigned short __u16;
32 typedef unsigned __u32;
37 * This is a simple doubly linked list implementation that matches the
38 * way the Linux kernel doubly linked list implementation works.
42 struct ylist_head *next; /* next in chain */
43 struct ylist_head *prev; /* previous in chain */
47 /* Initialise a static list */
48 #define YLIST_HEAD(name) \
49 struct ylist_head name = { &(name), &(name)}
53 /* Initialise a list head to an empty list */
54 #define YINIT_LIST_HEAD(p) \
61 /* Add an element to a list */
62 static __inline__ void ylist_add(struct ylist_head *newEntry,
63 struct ylist_head *list)
65 struct ylist_head *listNext = list->next;
67 list->next = newEntry;
68 newEntry->prev = list;
69 newEntry->next = listNext;
70 listNext->prev = newEntry;
74 static __inline__ void ylist_add_tail(struct ylist_head *newEntry,
75 struct ylist_head *list)
77 struct ylist_head *listPrev = list->prev;
79 list->prev = newEntry;
80 newEntry->next = list;
81 newEntry->prev = listPrev;
82 listPrev->next = newEntry;
87 /* Take an element out of its current list, with or without
88 * reinitialising the links.of the entry*/
89 static __inline__ void ylist_del(struct ylist_head *entry)
91 struct ylist_head *listNext = entry->next;
92 struct ylist_head *listPrev = entry->prev;
94 listNext->prev = listPrev;
95 listPrev->next = listNext;
99 static __inline__ void ylist_del_init(struct ylist_head *entry)
102 entry->next = entry->prev = entry;
106 /* Test if the list is empty */
107 static __inline__ int ylist_empty(struct ylist_head *entry)
109 return (entry->next == entry);
113 /* ylist_entry takes a pointer to a list entry and offsets it to that
114 * we can find a pointer to the object it is embedded in.
118 #define ylist_entry(entry, type, member) \
119 ((type *)((char *)(entry)-(unsigned long)(&((type *)NULL)->member)))
122 /* ylist_for_each and list_for_each_safe iterate over lists.
123 * ylist_for_each_safe uses temporary storage to make the list delete safe
126 #define ylist_for_each(itervar, list) \
127 for (itervar = (list)->next; itervar != (list); itervar = itervar->next)
129 #define ylist_for_each_safe(itervar, saveVar, list) \
130 for (itervar = (list)->next, saveVar = (list)->next->next; \
131 itervar != (list); itervar = saveVar, saveVar = saveVar->next)
134 #if !(defined __KERNEL__)
138 #include <sys/stat.h>
142 #ifdef CONFIG_YAFFS_PROVIDE_DEFS
158 #include <sys/stat.h>
162 * Attribute flags. These should be or-ed together to figure out what
169 #define ATTR_ATIME 16
170 #define ATTR_MTIME 32
171 #define ATTR_CTIME 64
174 unsigned int ia_valid;
182 unsigned int ia_attr_flags;
189 #include <linux/types.h>
190 #include <linux/fs.h>
191 #include <linux/stat.h>