2 * Copyright 2004-2008, Haiku Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _FSSH_FS_CACHE_H
6 #define _FSSH_FS_CACHE_H
8 //! File System File and Block Caches
11 #include "fssh_fs_interface.h"
15 FSSH_TRANSACTION_WRITTEN
= 0x01,
16 FSSH_TRANSACTION_ABORTED
= 0x02,
17 FSSH_TRANSACTION_ENDED
= 0x04,
18 FSSH_TRANSACTION_IDLE
= 0x08
23 FSSH_FILE_MAP_CACHE_ON_DEMAND
= 0x01, /* default mode */
24 FSSH_FILE_MAP_CACHE_ALL
= 0x02
27 typedef void (*fssh_transaction_notification_hook
)(int32_t id
, int32_t event
,
35 extern int32_t fssh_cache_start_transaction(void *_cache
);
36 extern fssh_status_t
fssh_cache_sync_transaction(void *_cache
, int32_t id
);
37 extern fssh_status_t
fssh_cache_end_transaction(void *_cache
, int32_t id
,
38 fssh_transaction_notification_hook hook
,
40 extern fssh_status_t
fssh_cache_abort_transaction(void *_cache
, int32_t id
);
41 extern int32_t fssh_cache_detach_sub_transaction(void *_cache
,
42 int32_t id
, fssh_transaction_notification_hook hook
,
44 extern fssh_status_t
fssh_cache_abort_sub_transaction(void *_cache
,
46 extern fssh_status_t
fssh_cache_start_sub_transaction(void *_cache
,
48 extern fssh_status_t
fssh_cache_add_transaction_listener(void *_cache
,
49 int32_t id
, int32_t events
,
50 fssh_transaction_notification_hook hook
,
52 extern fssh_status_t
fssh_cache_remove_transaction_listener(void *_cache
,
53 int32_t id
, fssh_transaction_notification_hook hook
,
55 extern fssh_status_t
fssh_cache_next_block_in_transaction(void *_cache
,
56 int32_t id
, bool mainOnly
, long *_cookie
,
57 fssh_off_t
*_blockNumber
, void **_data
,
58 void **_unchangedData
);
59 extern int32_t fssh_cache_blocks_in_transaction(void *_cache
,
61 extern int32_t fssh_cache_blocks_in_main_transaction(void *_cache
,
63 extern int32_t fssh_cache_blocks_in_sub_transaction(void *_cache
,
65 extern bool fssh_cache_has_block_in_transaction(void *_cache
,
66 int32_t id
, fssh_off_t blockNumber
);
69 extern void fssh_block_cache_delete(void *_cache
, bool allowWrites
);
70 extern void * fssh_block_cache_create(int fd
, fssh_off_t numBlocks
,
71 fssh_size_t blockSize
, bool readOnly
);
72 extern fssh_status_t
fssh_block_cache_sync(void *_cache
);
73 extern fssh_status_t
fssh_block_cache_sync_etc(void *_cache
,
74 fssh_off_t blockNumber
, fssh_size_t numBlocks
);
75 extern void fssh_block_cache_discard(void *_cache
,
76 fssh_off_t blockNumber
, fssh_size_t numBlocks
);
77 extern fssh_status_t
fssh_block_cache_make_writable(void *_cache
,
78 fssh_off_t blockNumber
, int32_t transaction
);
79 extern void * fssh_block_cache_get_writable_etc(void *_cache
,
80 fssh_off_t blockNumber
, fssh_off_t base
,
81 fssh_off_t length
, int32_t transaction
);
82 extern void * fssh_block_cache_get_writable(void *_cache
,
83 fssh_off_t blockNumber
, int32_t transaction
);
84 extern void * fssh_block_cache_get_empty(void *_cache
,
85 fssh_off_t blockNumber
, int32_t transaction
);
86 extern const void * fssh_block_cache_get_etc(void *_cache
,
87 fssh_off_t blockNumber
, fssh_off_t base
,
89 extern const void * fssh_block_cache_get(void *_cache
,
90 fssh_off_t blockNumber
);
91 extern fssh_status_t
fssh_block_cache_set_dirty(void *_cache
,
92 fssh_off_t blockNumber
, bool isDirty
,
94 extern void fssh_block_cache_put(void *_cache
,
95 fssh_off_t blockNumber
);
98 extern void * fssh_file_cache_create(fssh_mount_id mountID
,
99 fssh_vnode_id vnodeID
, fssh_off_t size
);
100 extern void fssh_file_cache_delete(void *_cacheRef
);
101 extern void fssh_file_cache_enable(void *_cacheRef
);
102 extern fssh_status_t
fssh_file_cache_disable(void *_cacheRef
);
103 extern bool fssh_file_cache_is_enabled(void *_cacheRef
);
104 extern fssh_status_t
fssh_file_cache_set_size(void *_cacheRef
,
106 extern fssh_status_t
fssh_file_cache_sync(void *_cache
);
108 extern fssh_status_t
fssh_file_cache_read(void *_cacheRef
, void *cookie
,
109 fssh_off_t offset
, void *bufferBase
,
111 extern fssh_status_t
fssh_file_cache_write(void *_cacheRef
, void *cookie
,
112 fssh_off_t offset
, const void *buffer
,
116 extern void * fssh_file_map_create(fssh_mount_id mountID
,
117 fssh_vnode_id vnodeID
, fssh_off_t size
);
118 extern void fssh_file_map_delete(void *_map
);
119 extern void fssh_file_map_set_size(void *_map
, fssh_off_t size
);
120 extern void fssh_file_map_invalidate(void *_map
, fssh_off_t offset
,
122 extern fssh_status_t
fssh_file_map_set_mode(void *_map
, uint32_t mode
);
123 extern fssh_status_t
fssh_file_map_translate(void *_map
, fssh_off_t offset
,
124 fssh_size_t size
, struct fssh_file_io_vec
*vecs
,
125 fssh_size_t
*_count
, fssh_size_t align
);
128 extern fssh_status_t
fssh_entry_cache_add(fssh_dev_t mountID
,
129 fssh_ino_t dirID
, const char* name
,
131 extern fssh_status_t
fssh_entry_cache_add_missing(fssh_dev_t mountID
,
132 fssh_ino_t dirID
, const char* name
);
133 extern fssh_status_t
fssh_entry_cache_remove(fssh_dev_t mountID
,
134 fssh_ino_t dirID
, const char* name
);
140 #endif /* _FSSH_FS_CACHE_H */