allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / include / linux / jffs.h
blob9ce6e337e805fea78c68c5332bd46413e436a550
1 /*
2 * JFFS -- Journalling Flash File System, Linux implementation.
4 * Copyright (C) 1999, 2000 Axis Communications AB.
6 * Created by Finn Hakansson <finn@axis.com>.
8 * This is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * $Id: jffs.h,v 1.20 2001/09/18 21:33:37 dwmw2 Exp $
15 * Ported to Linux 2.3.x and MTD:
16 * Copyright (C) 2000 Alexander Larsson (alex@cendio.se), Cendio Systems AB
20 #ifndef __LINUX_JFFS_H__
21 #define __LINUX_JFFS_H__
23 #include <linux/types.h>
24 #include <linux/completion.h>
26 #define JFFS_VERSION_STRING "1.4"
28 /* This is a magic number that is used as an identification number for
29 this file system. It is written to the super_block structure. */
30 #define JFFS_MAGIC_SB_BITMASK 0x07c0 /* 1984 */
32 /* This is a magic number that every on-flash raw inode begins with. */
33 #define JFFS_MAGIC_BITMASK 0x34383931 /* "1984" */
35 /* These two bitmasks are the valid ones for the flash memories we have
36 for the moment. */
37 #define JFFS_EMPTY_BITMASK 0xffffffff
38 #define JFFS_DIRTY_BITMASK 0x00000000
40 /* This is the inode number of the root node. */
41 #define JFFS_MIN_INO 1
43 /* How many slots in the file hash table should we have? */
44 #define JFFS_HASH_SIZE 41 /* 41 is prime */
46 /* Don't use more than 254 bytes as the maximum allowed length of a file's
47 name due to errors that could occur during the scanning of the flash
48 memory. In fact, a name length of 255 or 0xff, could be the result of
49 an uncompleted write. For instance, if a raw inode is written to the
50 flash memory and there is a power lossage just before the length of
51 the name is written, the length 255 would be interpreted as an illegal
52 value. */
53 #define JFFS_MAX_NAME_LEN 254
55 /* Commands for ioctl(). */
56 #define JFFS_IOCTL_MAGIC 't'
58 /* XXX: This is something that we should try to get rid of in the future. */
59 #define JFFS_MODIFY_INODE 0x01
60 #define JFFS_MODIFY_NAME 0x02
61 #define JFFS_MODIFY_DATA 0x04
62 #define JFFS_MODIFY_EXIST 0x08
64 struct jffs_control;
66 /* The JFFS raw inode structure: Used for storage on physical media. */
67 /* Perhaps the uid, gid, atime, mtime and ctime members should have
68 more space due to future changes in the Linux kernel. Anyhow, since
69 a user of this filesystem probably have to fix a large number of
70 other things, we have decided to not be forward compatible. */
71 struct jffs_raw_inode
73 __u32 magic; /* A constant magic number. */
74 __u32 ino; /* Inode number. */
75 __u32 pino; /* Parent's inode number. */
76 __u32 version; /* Version number. */
77 __u32 mode; /* The file's type or mode. */
78 __u16 uid; /* The file's owner. */
79 __u16 gid; /* The file's group. */
80 __u32 atime; /* Last access time. */
81 __u32 mtime; /* Last modification time. */
82 __u32 ctime; /* Creation time. */
83 __u32 offset; /* Where to begin to write. */
84 __u32 dsize; /* Size of the node's data. */
85 __u32 rsize; /* How much are going to be replaced? */
86 __u8 nsize; /* Name length. */
87 __u8 nlink; /* Number of links. */
88 __u8 spare : 6; /* For future use. */
89 __u8 rename : 1; /* Rename to a name of an already existing file? */
90 __u8 deleted : 1; /* Has this file been deleted? */
91 __u8 accurate; /* The inode is obsolete if accurate == 0. */
92 /***** The 3 fields are written at once!! With hardcoded sizes. */
93 __u32 dchksum; /* Checksum for the data. */
94 __u16 nchksum; /* Checksum for the name. */
95 __u16 ichksum; /* Checksum for the raw inode. */
98 /* The inode checksum goes only up to the ichksum byte.
99 * It assume that accurate = 0xff and dchksum and nchksum have been set.
102 #define INODE_CHK_SIZ offsetof(struct jffs_raw_inode, ichksum)
106 /* The RAM representation of the node. The names of pointers to
107 jffs_nodes are very often just called `n' in the source code. */
108 struct jffs_node
110 __u32 ino; /* Inode number. */
111 __u32 version; /* Version number. */
112 __u32 data_offset; /* Logic location of the data to insert. */
113 __u32 data_size; /* The amount of data this node inserts. */
114 __u32 removed_size; /* The amount of data that this node removes. */
115 __u32 fm_offset; /* Physical location of the data in the actual
116 flash memory data chunk. */
117 __u8 name_size; /* Size of the name. */
118 struct jffs_fm *fm; /* Physical memory information. */
119 struct jffs_node *version_prev;
120 struct jffs_node *version_next;
121 struct jffs_node *range_prev;
122 struct jffs_node *range_next;
126 /* The RAM representation of a file (plain files, directories,
127 links, etc.). Pointers to jffs_files are normally named `f'
128 in the JFFS source code. */
129 struct jffs_file
131 __u32 ino; /* Inode number. */
132 __u32 pino; /* Parent's inode number. */
133 __u32 mode; /* file_type, mode */
134 __u16 uid; /* owner */
135 __u16 gid; /* group */
136 __u32 atime; /* Last access time. */
137 __u32 mtime; /* Last modification time. */
138 __u32 ctime; /* Creation time. */
139 __u8 nsize; /* Name length. */
140 __u8 nlink; /* Number of links. */
141 __u8 deleted; /* Has this file been deleted? */
142 char *name; /* The name of this file; NULL-terminated. */
143 __u32 size; /* The total size of the file's data. */
144 __u32 highest_version; /* The highest version number of this file. */
145 struct jffs_control *c;
146 struct jffs_file *parent; /* Reference to the parent directory. */
147 struct jffs_file *children; /* Always NULL for plain files. */
148 struct jffs_file *sibling_prev; /* Siblings in the same directory. */
149 struct jffs_file *sibling_next;
150 struct list_head hash; /* hash list. */
151 struct jffs_node *range_head; /* The final data. */
152 struct jffs_node *range_tail; /* The first data. */
153 struct jffs_node *version_head; /* The youngest node. */
154 struct jffs_node *version_tail; /* The oldest node. */
158 /* This is just a definition of a simple list used for keeping track of
159 files deleted due to a rename. This list is only used during the
160 mounting of the file system and only if there have been rename operations
161 earlier. */
162 struct jffs_delete_list
164 __u32 ino;
165 struct jffs_delete_list *next;
169 /* A struct for the overall file system control. Pointers to
170 jffs_control structs are named `c' in the source code. */
171 struct jffs_control
173 struct super_block *sb; /* Reference to the VFS super block. */
174 struct jffs_file *root; /* The root directory file. */
175 struct list_head *hash; /* Hash table for finding files by ino*/
176 struct jffs_fmcontrol *fmc; /* Flash memory control structure. */
177 __u32 hash_len; /* The size of the hash table. */
178 __u32 next_ino; /* Next inode number */
179 int gc_sleep_time; /* jiffies to sleep before next round. */
180 __u16 building_fs; /* Is the file system being built now */
181 struct jffs_delete_list *delete_list; /* Track deleted files. */
182 pid_t thread_pid; /* GC thread's PID */
183 struct task_struct *gc_task; /* GC task struct */
184 struct completion gc_thread_init; /* GC thread init mutex */
185 struct completion gc_thread_comp; /* GC thread exit mutex */
186 __u32 gc_minfree_threshold; /* GC trigger thresholds */
187 __u32 gc_maxdirty_threshold;
191 /* Used to inform about flash status. */
192 struct jffs_flash_status
194 __u32 size;
195 __u32 used;
196 __u32 dirty;
197 __u32 begin;
198 __u32 end;
201 /* This stuff could be used for finding memory leaks. */
202 #define JFFS_MEMORY_DEBUG 0
204 extern long no_jffs_node;
205 #if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG
206 extern long no_jffs_control;
207 extern long no_jffs_raw_inode;
208 extern long no_jffs_node_ref;
209 extern long no_jffs_fm;
210 extern long no_jffs_fmcontrol;
211 extern long no_hash;
212 extern long no_name;
213 #define DJM(x) x
214 #else
215 #define DJM(x)
216 #endif
218 #endif /* __LINUX_JFFS_H__ */