2
libparted - a library for manipulating disk partitions
3
Copyright (C) 2004-2005, 2007, 2009-2010 Free Software Foundation,
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 3 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include <parted/parted.h>
24
#include <parted/endian.h>
25
#include <parted/debug.h>
30
#define CR_NULL 0 /* reserved */
33
#define CR_PRIM_ATTR 3
34
#define CR_PRIM_ALLOC 4
35
#define CR_PRIM_START 5
36
#define CR_BTREE_CAT 6
37
#define CR_BTREE_ATTR 7
38
#define CR_BTREE_EXT_0 8
39
#define CR_BTREE_EXT_CAT 9
40
#define CR_BTREE_EXT_EXT 10 /* should not happen ! */
41
#define CR_BTREE_EXT_ATTR 11
42
#define CR_BTREE_EXT_ALLOC 12
43
#define CR_BTREE_EXT_START 13 /* unneeded in current code */
44
#define CR_BTREE_CAT_JIB 14 /* journal info block */
45
#define CR_BTREE_CAT_JL 15 /* journal */
46
/* 16 -> 31 || high order bit */ /* reserved */
49
#define CR_SHIFT 8 /* number of bits to shift start_block by */
50
/* to get the index of the linked list */
51
#define CR_OVER_DIV 16 /* alloc a table for (1+1/CR_OVER_DIV) *
52
file_number + CR_ADD_CST */
54
#define CR_NEW_ALLOC_DIV 4 /* divide the size of the first alloc table
55
by this value to allocate next tables */
57
/* See DOC for an explaination of this structure */
58
/* Access read only from outside cache.c */
59
struct _HfsCPrivateExtent {
60
struct _HfsCPrivateExtent* next;
65
uint8_t sect_by_block;
67
unsigned ref_index : 3; /* 0 -> 7 */
69
typedef struct _HfsCPrivateExtent HfsCPrivateExtent;
71
/* Internaly used by cache.c for custom memory managment only */
72
struct _HfsCPrivateCacheTable {
73
struct _HfsCPrivateCacheTable* next_cache;
74
HfsCPrivateExtent* table;
75
unsigned int table_size;
76
unsigned int table_first_free;
79
typedef struct _HfsCPrivateCacheTable HfsCPrivateCacheTable;
81
/* Internaly used by cache.c for custom memory managment
82
and cache handling only */
83
struct _HfsCPrivateCache {
84
HfsCPrivateCacheTable* table_list;
85
HfsCPrivateCacheTable* last_table;
86
HfsCPrivateExtent** linked_ref;
87
unsigned int linked_ref_size;
88
unsigned int block_number;
89
unsigned int first_cachetable_size;
90
unsigned int needed_alloc_size;
92
typedef struct _HfsCPrivateCache HfsCPrivateCache;
95
hfsc_new_cache(unsigned int block_number, unsigned int file_number);
98
hfsc_delete_cache(HfsCPrivateCache* cache);
101
hfsc_cache_add_extent(HfsCPrivateCache* cache, uint32_t start, uint32_t length,
102
uint32_t block, uint16_t offset, uint8_t sbb,
103
uint8_t where, uint8_t index);
106
hfsc_cache_search_extent(HfsCPrivateCache* cache, uint32_t start);
109
hfsc_cache_move_extent(HfsCPrivateCache* cache, uint32_t old_start,
112
static __inline__ unsigned int
113
hfsc_cache_needed_buffer(HfsCPrivateCache* cache)
115
return cache->needed_alloc_size;
118
#endif /* _CACHE_H */