2004-09-04 21:15:22 +04:00
|
|
|
/* File System File and Block Caches
|
2004-11-12 19:35:24 +03:00
|
|
|
*
|
2005-07-13 20:33:05 +04:00
|
|
|
* Copyright 2004-2005, Haiku Inc. All Rights Reserved.
|
2004-11-12 19:35:24 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2004-09-04 21:15:22 +04:00
|
|
|
#ifndef _FS_CACHE_H
|
|
|
|
#define _FS_CACHE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <fs_interface.h>
|
|
|
|
|
|
|
|
|
2004-11-12 19:35:24 +03:00
|
|
|
typedef void (*transaction_notification_hook)(int32 id, void *data);
|
2004-11-10 04:57:38 +03:00
|
|
|
|
2004-09-04 21:15:22 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-11-10 04:57:38 +03:00
|
|
|
/* transactions */
|
2004-11-19 23:23:58 +03:00
|
|
|
extern int32 cache_start_transaction(void *_cache);
|
|
|
|
extern status_t cache_sync_transaction(void *_cache, int32 id);
|
|
|
|
extern status_t cache_end_transaction(void *_cache, int32 id, transaction_notification_hook hook, void *data);
|
|
|
|
extern status_t cache_abort_transaction(void *_cache, int32 id);
|
2005-10-19 20:46:17 +04:00
|
|
|
extern int32 cache_detach_sub_transaction(void *_cache, int32 id, transaction_notification_hook hook, void *data);
|
2004-11-19 23:23:58 +03:00
|
|
|
extern status_t cache_abort_sub_transaction(void *_cache, int32 id);
|
|
|
|
extern status_t cache_start_sub_transaction(void *_cache, int32 id);
|
|
|
|
extern status_t cache_next_block_in_transaction(void *_cache, int32 id, uint32 *_cookie,
|
2004-11-12 19:35:24 +03:00
|
|
|
off_t *_blockNumber, void **_data, void **_unchangedData);
|
2005-10-19 20:46:17 +04:00
|
|
|
extern int32 cache_blocks_in_transaction(void *_cache, int32 id);
|
|
|
|
extern int32 cache_blocks_in_sub_transaction(void *_cache, int32 id);
|
2004-11-10 04:57:38 +03:00
|
|
|
|
|
|
|
/* block cache */
|
|
|
|
extern void block_cache_delete(void *_cache, bool allowWrites);
|
2006-08-31 03:18:31 +04:00
|
|
|
extern void *block_cache_create(int fd, off_t numBlocks, size_t blockSize, bool readOnly);
|
2004-11-10 04:57:38 +03:00
|
|
|
extern status_t block_cache_sync(void *_cache);
|
|
|
|
|
2004-11-12 19:35:24 +03:00
|
|
|
extern status_t block_cache_make_writable(void *_cache, off_t blockNumber, int32 transaction);
|
|
|
|
extern void *block_cache_get_writable_etc(void *_cache, off_t blockNumber, off_t base,
|
|
|
|
off_t length, int32 transaction);
|
2004-11-10 04:57:38 +03:00
|
|
|
extern void *block_cache_get_writable(void *_cache, off_t blockNumber, int32 transaction);
|
|
|
|
extern void *block_cache_get_empty(void *_cache, off_t blockNumber, int32 transaction);
|
|
|
|
extern const void *block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length);
|
|
|
|
extern const void *block_cache_get(void *_cache, off_t blockNumber);
|
2004-11-12 19:35:24 +03:00
|
|
|
extern status_t block_cache_set_dirty(void *_cache, off_t blockNumber, bool isDirty, int32 transaction);
|
2004-11-10 04:57:38 +03:00
|
|
|
extern void block_cache_put(void *_cache, off_t blockNumber);
|
|
|
|
|
2004-09-04 21:15:22 +04:00
|
|
|
/* file cache */
|
2004-09-07 01:53:36 +04:00
|
|
|
extern void *file_cache_create(mount_id mountID, vnode_id vnodeID, off_t size, int fd);
|
2004-09-04 21:15:22 +04:00
|
|
|
extern void file_cache_delete(void *_cacheRef);
|
|
|
|
extern status_t file_cache_set_size(void *_cacheRef, off_t size);
|
2004-11-19 23:23:58 +03:00
|
|
|
extern status_t file_cache_sync(void *_cache);
|
2005-07-13 20:33:05 +04:00
|
|
|
extern status_t file_cache_invalidate_file_map(void *_cacheRef, off_t offset, off_t size);
|
2004-09-04 21:15:22 +04:00
|
|
|
|
|
|
|
extern status_t file_cache_read_pages(void *_cacheRef, off_t offset,
|
|
|
|
const iovec *vecs, size_t count, size_t *_numBytes);
|
|
|
|
extern status_t file_cache_write_pages(void *_cacheRef, off_t offset,
|
|
|
|
const iovec *vecs, size_t count, size_t *_numBytes);
|
|
|
|
extern status_t file_cache_read(void *_cacheRef, off_t offset, void *bufferBase, size_t *_size);
|
|
|
|
extern status_t file_cache_write(void *_cacheRef, off_t offset, const void *buffer, size_t *_size);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _FS_CACHE_H */
|