xref: /minix/minix/include/minix/vtreefs.h (revision 7f5f010b)
1 #ifndef _MINIX_VTREEFS_H
2 #define _MINIX_VTREEFS_H
3 
4 struct inode;
5 typedef int index_t;
6 typedef void *cbdata_t;
7 
8 #define NO_INDEX	((index_t) -1)
9 
10 /* Maximum file name length, excluding terminating null character. It is set
11  * to a low value to limit memory usage, but can be changed to any value.
12  */
13 #define PNAME_MAX	24
14 
15 struct inode_stat {
16 	mode_t mode;		/* file mode (type and permissions) */
17 	uid_t uid;		/* user ID */
18 	gid_t gid;		/* group ID */
19 	off_t size;		/* file size */
20 	dev_t dev;		/* device number (for char/block type files) */
21 };
22 
23 struct fs_hooks {
24 	void (*init_hook)(void);
25 	void (*cleanup_hook)(void);
26 	int (*lookup_hook)(struct inode *inode, char *name, cbdata_t cbdata);
27 	int (*getdents_hook)(struct inode *inode, cbdata_t cbdata);
28 	int (*read_hook)(struct inode *inode, off_t offset, char **ptr,
29 		size_t *len, cbdata_t cbdata);
30 	int (*rdlink_hook)(struct inode *inode, char *ptr, size_t max,
31 		cbdata_t cbdata);
32 	int (*message_hook)(message *m);
33 };
34 
35 extern struct inode *add_inode(struct inode *parent, char *name, index_t index,
36 	struct inode_stat *stat, index_t nr_indexed_entries, cbdata_t cbdata);
37 extern void delete_inode(struct inode *inode);
38 
39 extern struct inode *get_inode_by_name(struct inode *parent, char *name);
40 extern struct inode *get_inode_by_index(struct inode *parent, index_t index);
41 
42 extern char const *get_inode_name(struct inode *inode);
43 extern index_t get_inode_index(struct inode *inode);
44 extern cbdata_t get_inode_cbdata(struct inode *inode);
45 
46 extern struct inode *get_root_inode(void);
47 extern struct inode *get_parent_inode(struct inode *inode);
48 extern struct inode *get_first_inode(struct inode *parent);
49 extern struct inode *get_next_inode(struct inode *previous);
50 
51 extern void get_inode_stat(struct inode *inode, struct inode_stat *stat);
52 extern void set_inode_stat(struct inode *inode, struct inode_stat *stat);
53 
54 extern void start_vtreefs(struct fs_hooks *hooks, unsigned int nr_inodes,
55 	struct inode_stat *stat, index_t nr_indexed_entries);
56 
57 #endif /* _MINIX_VTREEFS_H */
58