1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef __LINUX_JFFS_FM_H__
21#define __LINUX_JFFS_FM_H__
22
23#include <linux/types.h>
24#include <linux/jffs.h>
25#include <linux/mtd/mtd.h>
26#include <linux/config.h>
27
28
29#define JFFS_ALIGN_SIZE 4
30
31
32#define JFFS_MARK_OBSOLETE 0
33
34#ifndef CONFIG_JFFS_FS_VERBOSE
35#define CONFIG_JFFS_FS_VERBOSE 1
36#endif
37
38#if CONFIG_JFFS_FS_VERBOSE > 0
39#define D(x) x
40#define D1(x) D(x)
41#else
42#define D(x)
43#define D1(x)
44#endif
45
46#if CONFIG_JFFS_FS_VERBOSE > 1
47#define D2(x) D(x)
48#else
49#define D2(x)
50#endif
51
52#if CONFIG_JFFS_FS_VERBOSE > 2
53#define D3(x) D(x)
54#else
55#define D3(x)
56#endif
57
58#define ASSERT(x) x
59
60
61
62#define JFFS_GET_PAD_BYTES(size) ( (JFFS_ALIGN_SIZE-1) & -(__u32)(size) )
63#define JFFS_PAD(size) ( (size + (JFFS_ALIGN_SIZE-1)) & ~(JFFS_ALIGN_SIZE-1) )
64
65
66
67void jffs_free_fm(struct jffs_fm *n);
68struct jffs_fm *jffs_alloc_fm(void);
69
70
71struct jffs_node_ref
72{
73 struct jffs_node *node;
74 struct jffs_node_ref *next;
75};
76
77
78
79struct jffs_fm
80{
81 __u32 offset;
82 __u32 size;
83 struct jffs_fm *prev;
84 struct jffs_fm *next;
85 struct jffs_node_ref *nodes;
86};
87
88struct jffs_fmcontrol
89{
90 __u32 flash_size;
91 __u32 used_size;
92 __u32 dirty_size;
93 __u32 free_size;
94 __u32 sector_size;
95 __u32 min_free_size;
96
97 __u32 max_chunk_size;
98 struct mtd_info *mtd;
99 struct jffs_control *c;
100 struct jffs_fm *head;
101 struct jffs_fm *tail;
102 struct jffs_fm *head_extra;
103 struct jffs_fm *tail_extra;
104 struct semaphore biglock;
105};
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125struct jffs_fmcontrol *jffs_build_begin(struct jffs_control *c, kdev_t dev);
126void jffs_build_end(struct jffs_fmcontrol *fmc);
127void jffs_cleanup_fmcontrol(struct jffs_fmcontrol *fmc);
128
129int jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size,
130 struct jffs_node *node, struct jffs_fm **result);
131int jffs_fmfree(struct jffs_fmcontrol *fmc, struct jffs_fm *fm,
132 struct jffs_node *node);
133
134__u32 jffs_free_size1(struct jffs_fmcontrol *fmc);
135__u32 jffs_free_size2(struct jffs_fmcontrol *fmc);
136void jffs_sync_erase(struct jffs_fmcontrol *fmc, int erased_size);
137struct jffs_fm *jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size);
138struct jffs_node *jffs_get_oldest_node(struct jffs_fmcontrol *fmc);
139long jffs_erasable_size(struct jffs_fmcontrol *fmc);
140struct jffs_fm *jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset,
141 __u32 size, struct jffs_node *node);
142int jffs_add_node(struct jffs_node *node);
143void jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm,
144 __u32 size);
145
146void jffs_print_fmcontrol(struct jffs_fmcontrol *fmc);
147void jffs_print_fm(struct jffs_fm *fm);
148void jffs_print_node_ref(struct jffs_node_ref *ref);
149
150#endif
151