source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/jffs.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 8.0 KB
RevLine 
[2]1/*
2 * JFFS -- Journalling Flash File System, Linux implementation.
3 *
4 * Copyright (C) 1999, 2000  Axis Communications AB.
5 *
6 * Created by Finn Hakansson <finn@axis.com>.
7 *
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.
12 *
13 *
14 * Ported to Linux 2.3.x and MTD:
15 * Copyright (C) 2000  Alexander Larsson (alex@cendio.se), Cendio Systems AB
16 *
17 */
18
19#ifndef __LINUX_JFFS_H__
20#define __LINUX_JFFS_H__
21
22#include <linux/types.h>
23
24#define JFFS_VERSION_STRING "1.0"
25
26/* This is a magic number that is used as an identification number for
27   this file system.  It is written to the super_block structure.  */
28#define JFFS_MAGIC_SB_BITMASK 0x07c0  /* 1984 */
29
30/* This is a magic number that every on-flash raw inode begins with.  */
31#define JFFS_MAGIC_BITMASK 0x34383931 /* "1984" */
32
33/* These two bitmasks are the valid ones for the flash memories we have
34   for the moment.  */
35#define JFFS_EMPTY_BITMASK 0xffffffff
36#define JFFS_DIRTY_BITMASK 0x00000000
37
38/* This is the inode number of the root node.  */
39#define JFFS_MIN_INO 1
40
41/* How many slots in the file hash table should we have?  */
42#define JFFS_HASH_SIZE 40
43
44/* Don't use more than 254 bytes as the maximum allowed length of a file's
45   name due to errors that could occur during the scanning of the flash
46   memory. In fact, a name length of 255 or 0xff, could be the result of
47   an uncompleted write.  For instance, if a raw inode is written to the
48   flash memory and there is a power lossage just before the length of
49   the name is written, the length 255 would be interpreted as an illegal
50   value.  */
51#define JFFS_MAX_NAME_LEN 254
52
53/* Commands for ioctl().  */
54#define JFFS_IOCTL_MAGIC 't'
55#define JFFS_PRINT_HASH _IO(JFFS_IOCTL_MAGIC, 90)
56#define JFFS_PRINT_TREE _IO(JFFS_IOCTL_MAGIC, 91)
57#define JFFS_GET_STATUS _IO(JFFS_IOCTL_MAGIC, 92)
58
59/* XXX: This is something that we should try to get rid of in the future.  */
60#define JFFS_MODIFY_INODE 0x01
61#define JFFS_MODIFY_NAME  0x02
62#define JFFS_MODIFY_DATA  0x04
63#define JFFS_MODIFY_EXIST 0x08
64
65struct jffs_control;
66
67/* The JFFS raw inode structure: Used for storage on physical media.  */
68/* Perhaps the uid, gid, atime, mtime and ctime members should have
69   more space due to future changes in the Linux kernel. Anyhow, since
70   a user of this filesystem probably have to fix a large number of
71   other things, we have decided to not be forward compatible.  */
72struct jffs_raw_inode
73{
74        __u32 magic;      /* A constant magic number.  */
75        __u32 ino;        /* Inode number.  */
76        __u32 pino;       /* Parent's inode number.  */
77        __u32 version;    /* Version number.  */
78        __u32 mode;       /* The file's type or mode.  */
79        __u16 uid;        /* The file's owner.  */
80        __u16 gid;        /* The file's group.  */
81        __u32 atime;      /* Last access time.  */
82        __u32 mtime;      /* Last modification time.  */
83        __u32 ctime;      /* Creation time.  */
84        __u32 offset;     /* Where to begin to write.  */
85        __u32 dsize;      /* Size of the node's data.  */
86        __u32 rsize;      /* How much are going to be replaced?  */
87        __u8 nsize;       /* Name length.  */
88        __u8 nlink;       /* Number of links.  */
89        __u8 spare : 6;   /* For future use.  */
90        __u8 rename : 1;  /* Rename to a name of an already existing file?  */
91        __u8 deleted : 1; /* Has this file been deleted?  */
92        __u8 accurate;    /* The inode is obsolete if accurate == 0.  */
93        __u32 dchksum;    /* Checksum for the data.  */
94        __u16 nchksum;    /* Checksum for the name.  */
95        __u16 chksum;     /* Checksum for the raw inode.  */
96};
97
98/* Define the offset of the accurate byte in struct jffs_raw_inode.  */
99#define JFFS_RAW_INODE_ACCURATE_OFFSET (sizeof(struct jffs_raw_inode) \
100                                        - 2 * sizeof(__u32) - sizeof(__u8))
101
102/* Define the offset of the chksum member in struct jffs_raw_inode.  */
103#define JFFS_RAW_INODE_CHKSUM_OFFSET (sizeof(struct jffs_raw_inode) \
104                                      - sizeof(__u16))
105
106/* Define the offset of the dchksum member in struct jffs_raw_inode.  */
107#define JFFS_RAW_INODE_DCHKSUM_OFFSET (sizeof(struct jffs_raw_inode)   \
108                                       - sizeof(__u16) - sizeof(__u16) \
109                                       - sizeof(__u32))
110
111
112/* The RAM representation of the node.  The names of pointers to
113   jffs_nodes are very often just called `n' in the source code.  */
114struct jffs_node
115{
116        __u32 ino;          /* Inode number.  */
117        __u32 version;      /* Version number.  */
118        __u32 data_offset;  /* Logic location of the data to insert.  */
119        __u32 data_size;    /* The amount of data this node inserts.  */
120        __u32 removed_size; /* The amount of data that this node removes.  */
121        __u32 fm_offset;    /* Physical location of the data in the actual
122                               flash memory data chunk.  */
123        __u8 name_size;     /* Size of the name.  */
124        struct jffs_fm *fm; /* Physical memory information.  */
125        struct jffs_node *version_prev;
126        struct jffs_node *version_next;
127        struct jffs_node *range_prev;
128        struct jffs_node *range_next;
129};
130
131
132/* The RAM representation of a file (plain files, directories,
133   links, etc.).  Pointers to jffs_files are normally named `f'
134   in the JFFS source code.  */
135struct jffs_file
136{
137        __u32 ino;    /* Inode number.  */
138        __u32 pino;   /* Parent's inode number.  */
139        __u32 mode;   /* file_type, mode  */
140        __u16 uid;    /* owner  */
141        __u16 gid;    /* group  */
142        __u32 atime;  /* Last access time.  */
143        __u32 mtime;  /* Last modification time.  */
144        __u32 ctime;  /* Creation time.  */
145        __u8 nsize;   /* Name length.  */
146        __u8 nlink;   /* Number of links.  */
147        __u8 deleted; /* Has this file been deleted?  */
148        char *name;   /* The name of this file; NULL-terminated.  */
149        __u32 size;   /* The total size of the file's data.  */
150        __u32 highest_version; /* The highest version number of this file.  */
151        struct jffs_control *c;
152        struct jffs_file *parent;   /* Reference to the parent directory.  */
153        struct jffs_file *children; /* Always NULL for plain files.  */
154        struct jffs_file *sibling_prev; /* Siblings in the same directory.  */
155        struct jffs_file *sibling_next;
156        struct list_head hash;    /* hash list.  */
157        struct jffs_node *range_head;   /* The final data.  */
158        struct jffs_node *range_tail;   /* The first data.  */
159        struct jffs_node *version_head; /* The youngest node.  */
160        struct jffs_node *version_tail; /* The oldest node.  */
161};
162
163
164/* This is just a definition of a simple list used for keeping track of
165   files deleted due to a rename.  This list is only used during the
166   mounting of the file system and only if there have been rename operations
167   earlier.  */
168struct jffs_delete_list
169{
170        __u32 ino;
171        struct jffs_delete_list *next;
172};
173
174
175/* A struct for the overall file system control.  Pointers to
176   jffs_control structs are named `c' in the source code.  */
177struct jffs_control
178{
179        struct super_block *sb;         /* Reference to the VFS super block.  */
180        struct jffs_file *root;         /* The root directory file.  */
181        struct list_head *hash;         /* Hash table for finding files by ino.  */
182        struct jffs_fmcontrol *fmc;     /* Flash memory control structure.  */
183        __u32 hash_len;                 /* The size of the hash table.  */
184        __u32 next_ino;                 /* Next inode number to use for new files.  */
185        __u16 building_fs;              /* Is the file system being built right now?  */
186        struct jffs_delete_list *delete_list; /* Track deleted files.  */
187        pid_t thread_pid;               /* GC thread's PID */
188        struct task_struct *gc_task;    /* GC task struct */
189        struct completion gc_thread_comp; /* GC thread exit mutex */
190        __u32 gc_minfree_threshold;     /* GC trigger thresholds */
191        __u32 gc_maxdirty_threshold;
192};
193
194
195/* Used to inform about flash status.  */
196struct jffs_flash_status
197{
198        __u32 size;
199        __u32 used;
200        __u32 dirty;
201        __u32 begin;
202        __u32 end;
203};
204
205/* This stuff could be used for finding memory leaks.  */
206#define JFFS_MEMORY_DEBUG 0
207
208#if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG
209extern long no_jffs_node;
210extern long no_jffs_file;
211extern long no_jffs_control;
212extern long no_jffs_raw_inode;
213extern long no_jffs_node_ref;
214extern long no_jffs_fm;
215extern long no_jffs_fmcontrol;
216extern long no_hash;
217extern long no_name;
218#define DJM(x) x
219#else
220#define DJM(x)
221#endif
222
223#endif /* __LINUX_JFFS_H__ */
Note: See TracBrowser for help on using the repository browser.