~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/linux/jffs.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.