Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | /* * JFFS -- Journaling Flash File System, Linux implementation. * * Copyright (C) 1999, 2000 Axis Communications AB. * * Created by Finn Hakansson <finn@axis.com>. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * $Id: jffs_fm.h,v 1.10 2000/08/17 15:42:44 dwmw2 Exp $ * * Ported to Linux 2.3.x and MTD: * Copyright (C) 2000 Alexander Larsson (alex@cendio.se), Cendio Systems AB * */ #ifndef __LINUX_JFFS_FM_H__ #define __LINUX_JFFS_FM_H__ #include <linux/types.h> #include <linux/jffs.h> #include <linux/mtd/mtd.h> #include <linux/config.h> /* The alignment between two nodes in the flash memory. */ #define JFFS_ALIGN_SIZE 4 /* Mark the on-flash space as obsolete when appropriate. */ #define JFFS_MARK_OBSOLETE 0 #ifndef CONFIG_JFFS_FS_VERBOSE #define CONFIG_JFFS_FS_VERBOSE 1 #endif #if CONFIG_JFFS_FS_VERBOSE > 0 #define D(x) x #define D1(x) D(x) #else #define D(x) #define D1(x) #endif #if CONFIG_JFFS_FS_VERBOSE > 1 #define D2(x) D(x) #else #define D2(x) #endif #if CONFIG_JFFS_FS_VERBOSE > 2 #define D3(x) D(x) #else #define D3(x) #endif #define ASSERT(x) x /* How many padding bytes should be inserted between two chunks of data on the flash? */ #define JFFS_GET_PAD_BYTES(size) ((JFFS_ALIGN_SIZE \ - ((__u32)(size) % JFFS_ALIGN_SIZE)) \ % JFFS_ALIGN_SIZE) #define JFFS_PAD(size) ( (size + (JFFS_ALIGN_SIZE-1)) & ~(JFFS_ALIGN_SIZE-1) ) struct jffs_node_ref { struct jffs_node *node; struct jffs_node_ref *next; }; /* The struct jffs_fm represents a chunk of data in the flash memory. */ struct jffs_fm { __u32 offset; __u32 size; struct jffs_fm *prev; struct jffs_fm *next; struct jffs_node_ref *nodes; /* USED if != 0. */ }; struct jffs_fmcontrol { __u32 flash_start; __u32 flash_size; __u32 used_size; __u32 dirty_size; __u32 free_size; __u32 sector_size; __u32 min_free_size; /* The minimum free space needed to be able to perform garbage collections. */ __u32 max_chunk_size; /* The maximum size of a chunk of data. */ struct mtd_info *mtd; struct jffs_control *c; struct jffs_fm *head; struct jffs_fm *tail; struct jffs_fm *head_extra; struct jffs_fm *tail_extra; struct semaphore biglock; }; /* Notice the two members head_extra and tail_extra in the jffs_control structure above. Those are only used during the scanning of the flash memory; while the file system is being built. If the data in the flash memory is organized like +----------------+------------------+----------------+ | USED / DIRTY | FREE | USED / DIRTY | +----------------+------------------+----------------+ then the scan is split in two parts. The first scanned part of the flash memory is organized through the members head and tail. The second scanned part is organized with head_extra and tail_extra. When the scan is completed, the two lists are merged together. The jffs_fm struct that head_extra references is the logical beginning of the flash memory so it will be referenced by the head member. */ struct jffs_fmcontrol *jffs_build_begin(struct jffs_control *c, kdev_t dev); void jffs_build_end(struct jffs_fmcontrol *fmc); void jffs_cleanup_fmcontrol(struct jffs_fmcontrol *fmc); int jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size, struct jffs_node *node, struct jffs_fm **result); int jffs_fmfree(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, struct jffs_node *node); __u32 jffs_free_size1(struct jffs_fmcontrol *fmc); __u32 jffs_free_size2(struct jffs_fmcontrol *fmc); void jffs_sync_erase(struct jffs_fmcontrol *fmc, int erased_size); struct jffs_fm *jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size); struct jffs_node *jffs_get_oldest_node(struct jffs_fmcontrol *fmc); long jffs_erasable_size(struct jffs_fmcontrol *fmc); struct jffs_fm *jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset, __u32 size, struct jffs_node *node); int jffs_add_node(struct jffs_node *node); void jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, __u32 size); void jffs_print_fmcontrol(struct jffs_fmcontrol *fmc); void jffs_print_fm(struct jffs_fm *fm); void jffs_print_node_ref(struct jffs_node_ref *ref); #endif /* __LINUX_JFFS_FM_H__ */ |