OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [linux/] [jffs.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * JFFS -- Journalling Flash File System, Linux implementation.
3
 *
4
 * Copyright (C) 1999, 2000  Finn Hakansson, Axis Communications, Inc.
5
 *
6
 * This is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * $Id: jffs.h,v 1.1 2005-12-20 11:32:24 jcastillo Exp $
12
 *
13
 */
14
 
15
#ifndef __LINUX_JFFS_H__
16
#define __LINUX_JFFS_H__
17
 
18
#define JFFS_VERSION_STRING "1.0"
19
 
20
/* This is a magic number that is used as an identification number for
21
   this file system.  It is written to the super_block structure.  */
22
#define JFFS_MAGIC_SB_BITMASK 0x07c0  /* 1984 */
23
 
24
/* This is a magic number that every on-flash raw inode begins with.  */
25
#define JFFS_MAGIC_BITMASK 0x34383931 /* "1984" */
26
 
27
/* These two bitmasks are the valid ones for the flash memories we have
28
   for the moment.  */
29
#define JFFS_EMPTY_BITMASK 0xffffffff
30
#define JFFS_DIRTY_BITMASK 0x00000000
31
 
32
/* This is the inode number of the root node.  */
33
#define JFFS_MIN_INO 1
34
 
35
/* How many slots in the file hash table should we have?  */
36
#define JFFS_HASH_SIZE 40
37
 
38
/* Don't use more than 254 bytes as the maximum allowed length of a file's
39
   name due to errors that could occur during the scanning of the flash
40
   memory. In fact, a name length of 255 or 0xff, could be the result of
41
   an uncompleted write.  For instance, if a raw inode is written to the
42
   flash memory and there is a power lossage just before the length of
43
   the name is written, the length 255 would be interpreted as an illegal
44
   value.  */
45
#define JFFS_MAX_NAME_LEN 254
46
 
47
/* Commands for ioctl().  */
48
#define JFFS_IOCTL_MAGIC 't'
49
#define JFFS_PRINT_HASH _IO(JFFS_IOCTL_MAGIC, 90)
50
#define JFFS_PRINT_TREE _IO(JFFS_IOCTL_MAGIC, 91)
51
#define JFFS_GET_STATUS _IO(JFFS_IOCTL_MAGIC, 92)
52
 
53
/* XXX: This is something that we should try to get rid of in the future.  */
54
#define JFFS_MODIFY_INODE 0x01
55
#define JFFS_MODIFY_NAME  0x02
56
#define JFFS_MODIFY_DATA  0x04
57
#define JFFS_MODIFY_EXIST 0x08
58
 
59
/* Using the garbage collection mechanism.  */
60
#define USE_GC
61
 
62
struct jffs_control;
63
 
64
/* The JFFS raw inode structure: Used for storage on physical media.  */
65
/* Perhaps the uid, gid, atime, mtime and ctime members should have
66
   more space due to future changes in the Linux kernel. Anyhow, since
67
   a user of this filesystem probably have to fix a large number of
68
   other things, we have decided to not be forward compatible.  */
69
struct jffs_raw_inode
70
{
71
        __u32 magic;      /* A constant magic number.  */
72
        __u32 ino;        /* Inode number.  */
73
        __u32 pino;       /* Parent's inode number.  */
74
        __u32 version;    /* Version number.  */
75
        __u32 mode;       /* The file's type or mode.  */
76
        __u16 uid;        /* The file's owner.  */
77
        __u16 gid;        /* The file's group.  */
78
        __u32 atime;      /* Last access time.  */
79
        __u32 mtime;      /* Last modification time.  */
80
        __u32 ctime;      /* Creation time.  */
81
        __u32 offset;     /* Where to begin to write.  */
82
        __u32 dsize;      /* Size of the node's data.  */
83
        __u32 rsize;      /* How much are going to be replaced?  */
84
        __u8 nsize;       /* Name length.  */
85
        __u8 nlink;       /* Number of links.  */
86
        __u8 spare : 6;   /* For future use.  */
87
        __u8 rename : 1;  /* Is this a special rename?  */
88
        __u8 deleted : 1; /* Has this file been deleted?  */
89
        __u8 accurate;    /* The inode is obsolete if accurate == 0.  */
90
        __u32 dchksum;    /* Checksum for the data.  */
91
        __u16 nchksum;    /* Checksum for the name.  */
92
        __u16 chksum;     /* Checksum for the raw inode.  */
93
};
94
 
95
/* Define the offset of the accurate byte in struct jffs_raw_inode.  */
96
#define JFFS_RAW_INODE_ACCURATE_OFFSET (sizeof(struct jffs_raw_inode) \
97
                                        - 2 * sizeof(__u32) - sizeof(__u8))
98
 
99
/* Define the offset of the chksum member in struct jffs_raw_inode.  */
100
#define JFFS_RAW_INODE_CHKSUM_OFFSET (sizeof(struct jffs_raw_inode) \
101
                                      - sizeof(__u16))
102
 
103
/* Define the offset of the dchksum member in struct jffs_raw_inode.  */
104
#define JFFS_RAW_INODE_DCHKSUM_OFFSET (sizeof(struct jffs_raw_inode)   \
105
                                       - sizeof(__u16) - sizeof(__u16) \
106
                                       - sizeof(__u32))
107
 
108
 
109
/* The RAM representation of the node.  The names of pointers to
110
   jffs_nodes are very often just called `n' in the source code.  */
111
struct jffs_node
112
{
113
        __u32 ino;          /* Inode number.  */
114
        __u32 version;      /* Version number.  */
115
        __u32 data_offset;  /* Logic location of the data to insert.  */
116
        __u32 data_size;    /* The amount of data this node inserts.  */
117
        __u32 removed_size; /* The amount of data that this node removes.  */
118
        __u32 fm_offset;    /* Physical location of the data in the actual
119
                               flash memory data chunk.  */
120
        __u8 name_size;     /* Size of the name.  */
121
        struct jffs_fm *fm; /* Physical memory information.  */
122
        struct jffs_node *version_prev;
123
        struct jffs_node *version_next;
124
        struct jffs_node *range_prev;
125
        struct jffs_node *range_next;
126
};
127
 
128
 
129
/* The RAM representation of a file (plain files, directories,
130
   links, etc.).  Pointers to jffs_files are normally named `f'
131
   in the JFFS source code.  */
132
struct jffs_file
133
{
134
        __u32 ino;    /* Inode number.  */
135
        __u32 pino;   /* Parent's inode number.  */
136
        __u32 mode;   /* file_type, mode  */
137
        __u16 uid;    /* owner  */
138
        __u16 gid;    /* group  */
139
        __u32 atime;  /* Last access time.  */
140
        __u32 mtime;  /* Last modification time.  */
141
        __u32 ctime;  /* Creation time.  */
142
        __u8 nsize;   /* Name length.  */
143
        __u8 nlink;   /* Number of links.  */
144
        __u8 deleted; /* Has this file been deleted?  */
145
        char *name;   /* The name of this file; NULL-terminated.  */
146
        __u32 size;   /* The total size of the file's data.  */
147
        __u32 highest_version; /* The highest version number of this file.  */
148
        struct jffs_control *c;
149
        struct jffs_file *parent;   /* Reference to the parent directory.  */
150
        struct jffs_file *children; /* Always NULL for plain files.  */
151
        struct jffs_file *sibling_prev; /* Siblings in the same directory.  */
152
        struct jffs_file *sibling_next;
153
        struct jffs_file *hash_prev;    /* Previous file in hash list.  */
154
        struct jffs_file *hash_next;    /* Next file in hash list.  */
155
        struct jffs_node *range_head;   /* The final data.  */
156
        struct jffs_node *range_tail;   /* The first data.  */
157
        struct jffs_node *version_head; /* The youngest node.  */
158
        struct jffs_node *version_tail; /* The oldest node.  */
159
};
160
 
161
 
162
/* A struct for the overall file system control.  Pointers to
163
   jffs_control structs are named `c' in the source code.  */
164
struct jffs_control
165
{
166
        struct super_block *sb;  /* Reference to the VFS super block.  */
167
        struct jffs_file *root;  /* The root directory file.  */
168
        struct jffs_file **hash; /* Hash table for finding files by ino.  */
169
        struct jffs_fmcontrol *fmc; /* Flash memory control structure.  */
170
        __u32 hash_len;    /* The size of the hash table.  */
171
        __u32 next_ino;    /* Next inode number to use for new files.  */
172
        __u16 building_fs; /* Is the file system being built right now?  */
173
        int rename_lock;   /* Used by jffs_rename().  */
174
        struct wait_queue *rename_wait; /* Likewise.  */
175
};
176
 
177
 
178
/* Used to inform about flash status.  */
179
struct jffs_flash_status
180
{
181
        __u32 size;
182
        __u32 used;
183
        __u32 dirty;
184
        __u32 begin;
185
        __u32 end;
186
};
187
 
188
/* This stuff could be used for finding memory leaks.  */
189
#define JFFS_MEMORY_DEBUG 0
190
 
191
#if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG
192
extern long no_jffs_file;
193
extern long no_jffs_node;
194
extern long no_jffs_control;
195
extern long no_jffs_raw_inode;
196
extern long no_jffs_node_ref;
197
extern long no_jffs_fm;
198
extern long no_jffs_fmcontrol;
199
extern long no_hash;
200
extern long no_name;
201
#define DJM(x) x
202
#else
203
#define DJM(x)
204
#endif
205
 
206
 
207
#ifdef __KERNEL__
208
extern int init_jffs_fs(void);
209
#endif /* __KERNEL__ */
210
 
211
#endif /* __LINUX_JFFS_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.