15c03270bSAxel Dörfler /* 25c03270bSAxel Dörfler * Copyright 2004-2007, Haiku Inc. All Rights Reserved. 39de65b05SAxel Dörfler * Distributed under the terms of the MIT License. 4a1978b5cSAxel Dörfler */ 5a1978b5cSAxel Dörfler #ifndef _FS_CACHE_H 6a1978b5cSAxel Dörfler #define _FS_CACHE_H 7a1978b5cSAxel Dörfler 87a1b4ef3SAxel Dörfler /*! File System File and Block Caches */ 95c03270bSAxel Dörfler 10a1978b5cSAxel Dörfler 11a1978b5cSAxel Dörfler #include <fs_interface.h> 12a1978b5cSAxel Dörfler 13a1978b5cSAxel Dörfler 149de65b05SAxel Dörfler typedef void (*transaction_notification_hook)(int32 id, void *data); 15060b0282SAxel Dörfler 16a1978b5cSAxel Dörfler #ifdef __cplusplus 17a1978b5cSAxel Dörfler extern "C" { 18a1978b5cSAxel Dörfler #endif 19a1978b5cSAxel Dörfler 20060b0282SAxel Dörfler /* transactions */ 2186c3e70cSAxel Dörfler extern int32 cache_start_transaction(void *_cache); 2286c3e70cSAxel Dörfler extern status_t cache_sync_transaction(void *_cache, int32 id); 231fbe3ccdSIngo Weinhold extern status_t cache_end_transaction(void *_cache, int32 id, 241fbe3ccdSIngo Weinhold transaction_notification_hook hook, void *data); 2586c3e70cSAxel Dörfler extern status_t cache_abort_transaction(void *_cache, int32 id); 261fbe3ccdSIngo Weinhold extern int32 cache_detach_sub_transaction(void *_cache, int32 id, 271fbe3ccdSIngo Weinhold transaction_notification_hook hook, void *data); 2886c3e70cSAxel Dörfler extern status_t cache_abort_sub_transaction(void *_cache, int32 id); 2986c3e70cSAxel Dörfler extern status_t cache_start_sub_transaction(void *_cache, int32 id); 301fbe3ccdSIngo Weinhold extern status_t cache_next_block_in_transaction(void *_cache, int32 id, 311fbe3ccdSIngo Weinhold uint32 *_cookie, off_t *_blockNumber, void **_data, 321fbe3ccdSIngo Weinhold void **_unchangedData); 33ca7c5a9eSAxel Dörfler extern int32 cache_blocks_in_transaction(void *_cache, int32 id); 34ca7c5a9eSAxel Dörfler extern int32 cache_blocks_in_sub_transaction(void *_cache, int32 id); 35060b0282SAxel Dörfler 36060b0282SAxel Dörfler /* block cache */ 37060b0282SAxel Dörfler extern void block_cache_delete(void *_cache, bool allowWrites); 381fbe3ccdSIngo Weinhold extern void *block_cache_create(int fd, off_t numBlocks, size_t blockSize, 391fbe3ccdSIngo Weinhold bool readOnly); 40060b0282SAxel Dörfler extern status_t block_cache_sync(void *_cache); 415c03270bSAxel Dörfler extern status_t block_cache_sync_etc(void *_cache, off_t blockNumber, 425c03270bSAxel Dörfler size_t numBlocks); 431fbe3ccdSIngo Weinhold extern status_t block_cache_make_writable(void *_cache, off_t blockNumber, 441fbe3ccdSIngo Weinhold int32 transaction); 451fbe3ccdSIngo Weinhold extern void *block_cache_get_writable_etc(void *_cache, off_t blockNumber, 461fbe3ccdSIngo Weinhold off_t base, off_t length, int32 transaction); 471fbe3ccdSIngo Weinhold extern void *block_cache_get_writable(void *_cache, off_t blockNumber, 481fbe3ccdSIngo Weinhold int32 transaction); 491fbe3ccdSIngo Weinhold extern void *block_cache_get_empty(void *_cache, off_t blockNumber, 501fbe3ccdSIngo Weinhold int32 transaction); 511fbe3ccdSIngo Weinhold extern const void *block_cache_get_etc(void *_cache, off_t blockNumber, 521fbe3ccdSIngo Weinhold off_t base, off_t length); 53060b0282SAxel Dörfler extern const void *block_cache_get(void *_cache, off_t blockNumber); 541fbe3ccdSIngo Weinhold extern status_t block_cache_set_dirty(void *_cache, off_t blockNumber, 551fbe3ccdSIngo Weinhold bool isDirty, int32 transaction); 56060b0282SAxel Dörfler extern void block_cache_put(void *_cache, off_t blockNumber); 57060b0282SAxel Dörfler 58a1978b5cSAxel Dörfler /* file cache */ 59*3d268edaSAxel Dörfler extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size); 60a1978b5cSAxel Dörfler extern void file_cache_delete(void *_cacheRef); 61a1978b5cSAxel Dörfler extern status_t file_cache_set_size(void *_cacheRef, off_t size); 6286c3e70cSAxel Dörfler extern status_t file_cache_sync(void *_cache); 63a1978b5cSAxel Dörfler 64*3d268edaSAxel Dörfler extern status_t file_cache_read(void *_cacheRef, void *cookie, off_t offset, 65*3d268edaSAxel Dörfler void *bufferBase, size_t *_size); 66*3d268edaSAxel Dörfler extern status_t file_cache_write(void *_cacheRef, void *cookie, off_t offset, 671fbe3ccdSIngo Weinhold const void *buffer, size_t *_size); 68a1978b5cSAxel Dörfler 69*3d268edaSAxel Dörfler /* file map */ 70*3d268edaSAxel Dörfler extern void *file_map_create(dev_t mountID, ino_t vnodeID); 71*3d268edaSAxel Dörfler extern void file_map_delete(void *_map); 72*3d268edaSAxel Dörfler extern void file_map_set_size(void *_map, off_t size); 73*3d268edaSAxel Dörfler extern void file_map_invalidate(void *_map, off_t offset, off_t size); 74*3d268edaSAxel Dörfler extern status_t file_map_translate(void *_map, off_t offset, size_t size, 75*3d268edaSAxel Dörfler struct file_io_vec *vecs, size_t *_count); 76*3d268edaSAxel Dörfler 77a1978b5cSAxel Dörfler #ifdef __cplusplus 78a1978b5cSAxel Dörfler } 79a1978b5cSAxel Dörfler #endif 80a1978b5cSAxel Dörfler 81a1978b5cSAxel Dörfler #endif /* _FS_CACHE_H */ 82