xref: /haiku/headers/private/kernel/file_cache.h (revision 909af08f4328301fbdef1ffb41f566c3b5bec0c7)
1 /*
2  * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _KERNEL_FILE_CACHE_H
6 #define _KERNEL_FILE_CACHE_H
7 
8 
9 #include <vfs.h>
10 #include <vm/vm_types.h>
11 #include <module.h>
12 
13 
14 // temporary/optional cache syscall API
15 #define CACHE_SYSCALLS "cache"
16 
17 #define CACHE_CLEAR			1	// takes no parameters
18 #define CACHE_SET_MODULE	2	// gets the module name as parameter
19 
20 #define CACHE_MODULES_NAME	"file_cache"
21 
22 #define FILE_CACHE_SEQUENTIAL_ACCESS	0x01
23 #define FILE_CACHE_LOADED_COMPLETELY	0x02
24 #define FILE_CACHE_NO_IO				0x04
25 
26 struct cache_module_info {
27 	module_info	info;
28 
29 	void (*node_opened)(struct vnode *vnode, dev_t mountID,
30 				ino_t parentID, ino_t vnodeID, const char *name, off_t size);
31 	void (*node_closed)(struct vnode *vnode, dev_t mountID,
32 				ino_t vnodeID, int32 accessType);
33 	void (*node_launched)(size_t argCount, char * const *args);
34 };
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 extern void cache_node_opened(struct vnode *vnode, VMCache *cache,
41 				dev_t mountID, ino_t parentID, ino_t vnodeID, const char *name);
42 extern void cache_node_closed(struct vnode *vnode, VMCache *cache,
43 				dev_t mountID, ino_t vnodeID);
44 extern void cache_node_launched(size_t argCount, char * const *args);
45 extern void cache_prefetch_vnode(struct vnode *vnode, off_t offset, size_t size);
46 extern void cache_prefetch(dev_t mountID, ino_t vnodeID, off_t offset, size_t size);
47 
48 extern status_t file_map_init(void);
49 extern status_t file_cache_init_post_boot_device(void);
50 extern status_t file_cache_init(void);
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 #endif	/* _KRENEL_FILE_CACHE_H */
57