1#ifndef _NFS_ADD_ON_H
2#define _NFS_ADD_ON_H
3
4#include "fsproto.h"
5#include "betalk.h"
6
7#include <Errors.h>
8#include <sys/stat.h>
9#include <SupportDefs.h>
10
11struct mount_bt_params
12{
13	unsigned int serverIP;
14	char *server;
15	char *_export;
16	uid_t uid;
17	gid_t gid;
18	char *hostname;
19	char *folder;
20	char user[MAX_USERNAME_LENGTH + 1];
21	char password[BT_AUTH_TOKEN_LENGTH * 2 + 1];
22};
23
24struct fs_node
25{
26	vnode_id vnid;
27	struct fs_node *next;
28};
29
30struct fs_nspace
31{
32	nspace_id nsid;
33
34	thread_id tid;
35	bool quit;
36	int s;
37
38	struct sockaddr_in mountAddr,nfsAddr;
39
40	int32 xid;
41
42	vnode_id rootid;
43
44	sem_id sem;
45	struct fs_node *first;
46
47	struct mount_bt_params params;
48};
49
50struct fs_file_cookie
51{
52	int omode;
53	off_t original_size;
54	struct stat st;
55};
56
57typedef struct fs_nspace fs_nspace;
58typedef struct fs_node fs_node;
59typedef struct fs_file_cookie fs_file_cookie;
60
61int	fs_read_vnode(fs_nspace *ns, vnode_id vnid, char r, fs_node **node);
62int	fs_write_vnode(fs_nspace *ns, fs_node *node, char r);
63
64int	fs_walk(fs_nspace *ns, fs_node *base, const char *file, char **newpath,
65					vnode_id *vnid);
66
67int fs_opendir(fs_nspace *ns, fs_node *node, btCookie **cookie);
68int	fs_closedir(fs_nspace *ns, fs_node *node, btCookie *cookie);
69int	fs_rewinddir(fs_nspace *ns, fs_node *node, btCookie *cookie);
70int	fs_readdir(fs_nspace *ns, fs_node *node, btCookie *cookie, long *num,
71					struct dirent *buf, size_t bufsize);
72
73int fs_free_dircookie(fs_nspace *ns, fs_node *node, btCookie *cookie);
74int	fs_rstat(fs_nspace *ns, fs_node *node, struct stat *);
75int	fs_mount(nspace_id nsid, const char *devname, ulong flags,
76					struct mount_bt_params *parms, size_t len, fs_nspace **data, vnode_id *vnid);
77int	fs_unmount(fs_nspace *ns);
78int fs_rfsstat(fs_nspace *ns, struct fs_info *);
79
80int	fs_open(fs_nspace *ns, fs_node *node, int omode, fs_file_cookie **cookie);
81int	fs_close(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie);
82int fs_free_cookie(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie);
83int fs_read(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos, void *buf,
84					size_t *len);
85
86int fs_write(fs_nspace *ns, fs_node *node, fs_file_cookie *cookie, off_t pos,
87					const void *buf, size_t *len);
88
89int fs_wstat(fs_nspace *ns, fs_node *node, struct stat *, long mask);
90int fs_wfsstat(fs_nspace *ns, struct fs_info *, long mask);
91int	fs_create(fs_nspace *ns, fs_node *dir, const char *name,
92					int omode, int perms, vnode_id *vnid, fs_file_cookie **cookie);
93
94int	fs_unlink(fs_nspace *ns, fs_node *dir, const char *name);
95int	fs_remove_vnode(fs_nspace *ns, fs_node *node, char r);
96int	fs_secure_vnode(fs_nspace *ns, fs_node *node);
97
98int	fs_mkdir(fs_nspace *ns, fs_node *dir, const char *name,	int perms);
99
100int	fs_rename(fs_nspace *ns, fs_node *olddir, const char *oldname,
101					fs_node *newdir, const char *newname);
102
103int	fs_rmdir(fs_nspace *ns, fs_node *dir, const char *name);
104int	fs_readlink(fs_nspace *ns, fs_node *node, char *buf, size_t *bufsize);
105
106int	fs_symlink(fs_nspace *ns, fs_node *dir, const char *name,
107					const char *path);
108
109extern void insert_node(fs_nspace *ns, fs_node *node);
110extern void remove_node(fs_nspace *ns, vnode_id vnid);
111
112extern int fs_access(void *ns, void *node, int mode);
113
114extern int fs_read_attrib(fs_nspace *ns, fs_node *node, const char *name, int type, void *buf, size_t *len, off_t pos);
115extern int fs_write_attrib(fs_nspace *ns, fs_node *node, const char *name, int type, const void *buf, size_t *len, off_t pos);
116extern int fs_open_attribdir(fs_nspace *ns, fs_node *node, btCookie **cookie);
117extern int fs_close_attribdir(fs_nspace *ns, fs_node *node, btCookie *cookie);
118extern int fs_rewind_attribdir(fs_nspace *ns, fs_node *node, btCookie *cookie);
119extern int fs_read_attribdir(fs_nspace *ns, fs_node *node, btCookie *cookie, long *num, struct dirent *buf, size_t bufsize);
120extern int fs_remove_attrib(fs_nspace *ns, fs_node *node, const char *name);
121extern int fs_stat_attrib(fs_nspace *ns, fs_node *node, const char *name, struct attr_info *buf);
122
123extern int fs_open_indexdir(fs_nspace *ns, btCookie **cookie);
124extern int fs_close_indexdir(fs_nspace *ns, btCookie *cookie);
125extern int fs_rewind_indexdir(fs_nspace *ns, btCookie *cookie);
126extern int fs_read_indexdir(fs_nspace *ns, btCookie *cookie, long *num, struct dirent *buf, size_t bufsize);
127extern int fs_free_indexdircookie(fs_nspace *ns, btCookie *cookie);
128extern int fsCreateIndex(fs_nspace *ns, const char *name, int type, int flags);
129extern int fsRemoveIndex(fs_nspace *ns, const char *name);
130extern int fsStatIndex(fs_nspace *ns, const char *name, struct index_info *buf);
131
132enum
133{
134	C_ERROR_STALE=B_ERRORS_END+1
135};
136
137#define USE_SYSTEM_AUTHENTICATION 1
138
139#endif
140