xref: /minix3/minix/include/minix/vtreefs.h (revision c21aa858e206a580693d3705485ebfc26ae29170)
1433d6423SLionel Sambuc #ifndef _MINIX_VTREEFS_H
2433d6423SLionel Sambuc #define _MINIX_VTREEFS_H
3433d6423SLionel Sambuc 
4433d6423SLionel Sambuc struct inode;
5433d6423SLionel Sambuc typedef int index_t;
6433d6423SLionel Sambuc typedef void *cbdata_t;
7433d6423SLionel Sambuc 
8433d6423SLionel Sambuc #define NO_INDEX	((index_t) -1)
9433d6423SLionel Sambuc 
10*c21aa858SCristiano Giuffrida /* Maximum file name length, excluding terminating null character, for which
11*c21aa858SCristiano Giuffrida  * the name will be allocated statically. Longer names will be allocated
12*c21aa858SCristiano Giuffrida  * dynamically, and should not be used for system-critical file systems.
13433d6423SLionel Sambuc  */
14433d6423SLionel Sambuc #define PNAME_MAX	24
15433d6423SLionel Sambuc 
16433d6423SLionel Sambuc struct inode_stat {
17433d6423SLionel Sambuc 	mode_t mode;		/* file mode (type and permissions) */
18433d6423SLionel Sambuc 	uid_t uid;		/* user ID */
19433d6423SLionel Sambuc 	gid_t gid;		/* group ID */
20433d6423SLionel Sambuc 	off_t size;		/* file size */
21433d6423SLionel Sambuc 	dev_t dev;		/* device number (for char/block type files) */
22433d6423SLionel Sambuc };
23433d6423SLionel Sambuc 
24433d6423SLionel Sambuc struct fs_hooks {
25433d6423SLionel Sambuc 	void (*init_hook)(void);
26433d6423SLionel Sambuc 	void (*cleanup_hook)(void);
27433d6423SLionel Sambuc 	int (*lookup_hook)(struct inode *inode, char *name, cbdata_t cbdata);
28433d6423SLionel Sambuc 	int (*getdents_hook)(struct inode *inode, cbdata_t cbdata);
295eefd0feSDavid van Moolenbroek 	ssize_t (*read_hook)(struct inode *inode, char *ptr, size_t len,
305eefd0feSDavid van Moolenbroek 	    off_t off, cbdata_t cbdata);
315eefd0feSDavid van Moolenbroek 	ssize_t (*write_hook)(struct inode *inode, char *ptr, size_t max,
325eefd0feSDavid van Moolenbroek 	    off_t off, cbdata_t cbdata);
335eefd0feSDavid van Moolenbroek 	int (*trunc_hook)(struct inode *inode, off_t offset, cbdata_t cbdata);
345eefd0feSDavid van Moolenbroek 	int (*mknod_hook)(struct inode *inode, char *name,
355eefd0feSDavid van Moolenbroek 	    struct inode_stat *stat, cbdata_t cbdata);
365eefd0feSDavid van Moolenbroek 	int (*unlink_hook)(struct inode *inode, cbdata_t cbdata);
375eefd0feSDavid van Moolenbroek 	int (*slink_hook)(struct inode *inode, char *name,
385eefd0feSDavid van Moolenbroek 	    struct inode_stat *stat, char *path, cbdata_t cbdata);
39433d6423SLionel Sambuc 	int (*rdlink_hook)(struct inode *inode, char *ptr, size_t max,
40433d6423SLionel Sambuc 	    cbdata_t cbdata);
415eefd0feSDavid van Moolenbroek 	int (*chstat_hook)(struct inode *inode, struct inode_stat *stat,
425eefd0feSDavid van Moolenbroek 	    cbdata_t cbdata);
435eefd0feSDavid van Moolenbroek 	void (*message_hook)(message *m, int ipc_status);
44433d6423SLionel Sambuc };
45433d6423SLionel Sambuc 
46693ad767SDavid van Moolenbroek extern struct inode *add_inode(struct inode *parent, const char *name,
47693ad767SDavid van Moolenbroek 	index_t index, const struct inode_stat *stat,
4852be5c0aSDavid van Moolenbroek 	index_t nr_indexed_slots, cbdata_t cbdata);
49433d6423SLionel Sambuc extern void delete_inode(struct inode *inode);
50433d6423SLionel Sambuc 
51693ad767SDavid van Moolenbroek extern struct inode *get_inode_by_name(const struct inode *parent,
52693ad767SDavid van Moolenbroek 	const char *name);
53693ad767SDavid van Moolenbroek extern struct inode *get_inode_by_index(const struct inode *parent,
54693ad767SDavid van Moolenbroek 	index_t index);
55433d6423SLionel Sambuc 
56693ad767SDavid van Moolenbroek extern const char *get_inode_name(const struct inode *inode);
57693ad767SDavid van Moolenbroek extern index_t get_inode_index(const struct inode *inode);
5852be5c0aSDavid van Moolenbroek extern index_t get_inode_slots(const struct inode *inode);
59693ad767SDavid van Moolenbroek extern cbdata_t get_inode_cbdata(const struct inode *inode);
6052be5c0aSDavid van Moolenbroek extern void *get_inode_extra(const struct inode *inode);
61433d6423SLionel Sambuc 
62433d6423SLionel Sambuc extern struct inode *get_root_inode(void);
63693ad767SDavid van Moolenbroek extern struct inode *get_parent_inode(const struct inode *inode);
64693ad767SDavid van Moolenbroek extern struct inode *get_first_inode(const struct inode *parent);
65693ad767SDavid van Moolenbroek extern struct inode *get_next_inode(const struct inode *previous);
66433d6423SLionel Sambuc 
67693ad767SDavid van Moolenbroek extern void get_inode_stat(const struct inode *inode, struct inode_stat *stat);
68433d6423SLionel Sambuc extern void set_inode_stat(struct inode *inode, struct inode_stat *stat);
69433d6423SLionel Sambuc 
7052be5c0aSDavid van Moolenbroek extern void run_vtreefs(struct fs_hooks *hooks, unsigned int nr_inodes,
7152be5c0aSDavid van Moolenbroek 	size_t inode_extra, struct inode_stat *stat, index_t nr_indexed_slots,
7252be5c0aSDavid van Moolenbroek 	size_t buf_size);
73433d6423SLionel Sambuc 
74433d6423SLionel Sambuc #endif /* _MINIX_VTREEFS_H */
75