libparted 3.6
Loading...
Searching...
No Matches
cache.h
Go to the documentation of this file.
1/*
2 libparted - a library for manipulating disk partitions
3 Copyright (C) 2004-2005, 2007, 2009-2014, 2019-2023 Free Software
4 Foundation, Inc.
5
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.
10
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.
15
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/>.
18*/
19
20#ifndef _CACHE_H
21#define _CACHE_H
22
23#include <parted/parted.h>
24#include <parted/endian.h>
25#include <parted/debug.h>
26
27#include "hfs.h"
28
29/* CR => CACHE REF */
30#define CR_NULL 0 /* reserved */
31#define CR_PRIM_CAT 1
32#define CR_PRIM_EXT 2
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 */
47
48/* tuning */
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 */
53#define CR_ADD_CST 16
54#define CR_NEW_ALLOC_DIV 4 /* divide the size of the first alloc table
55 by this value to allocate next tables */
56
57/* See DOC for an explaination of this structure */
58/* Access read only from outside cache.c */
61 uint32_t ext_start;
62 uint32_t ext_length;
63 uint32_t ref_block;
64 uint16_t ref_offset;
66 unsigned where : 5;
67 unsigned ref_index : 3; /* 0 -> 7 */
68};
71/* Internaly used by cache.c for custom memory managment only */
75 unsigned int table_size;
76 unsigned int table_first_free;
77 /* first_elemt ? */
78};
80
81/* Internaly used by cache.c for custom memory managment
82 and cache handling only */
87 unsigned int linked_ref_size;
88 unsigned int block_number;
89 unsigned int first_cachetable_size;
90 unsigned int needed_alloc_size;
91};
93
95hfsc_new_cache(unsigned int block_number, unsigned int file_number);
96
97void
99
102 uint32_t block, uint16_t offset, uint8_t sbb,
103 uint8_t where, uint8_t index);
104
107
110 uint32_t new_start);
111
112static __inline__ unsigned int
113hfsc_cache_needed_buffer(HfsCPrivateCache* cache)
114{
115 return cache->needed_alloc_size;
116}
117
118#endif /* _CACHE_H */
void hfsc_delete_cache(HfsCPrivateCache *cache)
Definition: cache.c:112
HfsCPrivateExtent * hfsc_cache_search_extent(HfsCPrivateCache *cache, uint32_t start)
Definition: cache.c:177
HfsCPrivateExtent * hfsc_cache_move_extent(HfsCPrivateCache *cache, uint32_t old_start, uint32_t new_start)
Definition: cache.c:194
HfsCPrivateExtent * hfsc_cache_add_extent(HfsCPrivateCache *cache, uint32_t start, uint32_t length, uint32_t block, uint16_t offset, uint8_t sbb, uint8_t where, uint8_t index)
Definition: cache.c:120
HfsCPrivateCache * hfsc_new_cache(unsigned int block_number, unsigned int file_number)
Definition: cache.c:60
uint32_t start
Definition: dos.c:4
uint32_t length
Definition: dos.c:5
offset
Definition: fdasd.h:264
unsigned char cache
Definition: fdasd.h:13
Definition: cache.h:70
HfsCPrivateExtent * table
Definition: cache.h:72
unsigned int table_first_free
Definition: cache.h:74
unsigned int table_size
Definition: cache.h:73
struct _HfsCPrivateCacheTable * next_cache
Definition: cache.h:71
Definition: cache.h:81
unsigned int linked_ref_size
Definition: cache.h:85
HfsCPrivateCacheTable * last_table
Definition: cache.h:83
unsigned int needed_alloc_size
Definition: cache.h:88
unsigned int block_number
Definition: cache.h:86
unsigned int first_cachetable_size
Definition: cache.h:87
HfsCPrivateCacheTable * table_list
Definition: cache.h:82
HfsCPrivateExtent ** linked_ref
Definition: cache.h:84
Definition: cache.h:57
uint32_t ref_block
Definition: cache.h:61
unsigned where
Definition: cache.h:64
unsigned ref_index
Definition: cache.h:65
uint32_t ext_start
Definition: cache.h:59
uint16_t ref_offset
Definition: cache.h:62
uint32_t ext_length
Definition: cache.h:60
uint8_t sect_by_block
Definition: cache.h:63
struct _HfsCPrivateExtent * next
Definition: cache.h:58