xref: /haiku/src/add-ons/kernel/file_systems/nfs/nfs_add_on.h (revision cfc3fa87da824bdf593eb8b817a83b6376e77935)
1 #ifndef _NFS_ADD_ON_H
2 #define _NFS_ADD_ON_H
3 
4 /* wrappers */
5 #ifdef __HAIKU__
6 #	include <fs_interface.h>
7 #	include <fs_info.h>
8 #	include <NodeMonitor.h>
9 typedef dev_t nspace_id;
10 #	define WSTAT_MODE B_STAT_MODE
11 #	define WSTAT_UID B_STAT_UID
12 #	define WSTAT_GID B_STAT_GID
13 #	define WSTAT_SIZE B_STAT_SIZE
14 #	define WSTAT_ATIME B_STAT_ACCESS_TIME
15 #	define WSTAT_MTIME B_STAT_MODIFICATION_TIME
16 #	define WSTAT_CRTIME B_STAT_CREATION_TIME
17 
18 #else
19 #	include "fsproto.h"
20 #	define publish_vnode new_vnode
21 typedef int socklen_t;
22 #endif
23 
24 #include "RPCPendingCalls.h"
25 #include "XDROutPacket.h"
26 #include "XDRInPacket.h"
27 #include "nfs.h"
28 
29 #include <Errors.h>
30 #include <sys/stat.h>
31 #include <SupportDefs.h>
32 
33 
34 struct mount_nfs_params {
35 	unsigned int serverIP;
36 	char *server;
37 	char *_export;
38 	uid_t uid;
39 	gid_t gid;
40 	char *hostname;
41 };
42 
43 struct fs_node {
44 	ino_t vnid;
45 	struct nfs_fhandle fhandle;
46 	struct fs_node *next;
47 };
48 
49 struct fs_nspace {
50 	nspace_id nsid;
51 
52 	thread_id tid;
53 	bool quit;
54 	int s;
55 	struct RPCPendingCalls pendingCalls;
56 
57 	struct sockaddr_in mountAddr,nfsAddr;
58 
59 	int32 xid;
60 
61 	ino_t rootid;
62 
63 	sem_id sem;
64 	struct fs_node *first;
65 
66 	struct mount_nfs_params params;
67 
68 	bigtime_t last_rfsstat;
69 
70 };
71 
72 void fs_nspaceInit (struct fs_nspace *nspace);
73 void fs_nspaceDestroy (struct fs_nspace *nspace);
74 
75 struct fs_file_cookie
76 {
77 	int omode;
78 	off_t original_size;
79 	struct stat st;
80 };
81 
82 typedef struct fs_nspace fs_nspace;
83 typedef struct fs_node fs_node;
84 typedef struct nfs_cookie nfs_cookie;
85 typedef struct fs_file_cookie fs_file_cookie;
86 typedef struct nfs_fhandle nfs_fhandle;
87 
88 status_t create_socket(fs_nspace *ns);
89 status_t init_postoffice(fs_nspace *ns);
90 void shutdown_postoffice(fs_nspace *ns);
91 status_t postoffice_func(fs_nspace *ns);
92 
93 extern uint8 *send_rpc_call(fs_nspace *ns, const struct sockaddr_in *addr, int32 prog, int32 vers, int32 proc, const struct XDROutPacket *packet);
94 extern bool is_successful_reply(struct XDRInPacket *reply);
95 extern status_t get_remote_address(fs_nspace *ns, int32 prog, int32 vers, int32 prot, struct sockaddr_in *addr);
96 extern status_t nfs_mount(fs_nspace *ns, const char *path, nfs_fhandle *fhandle);
97 extern status_t map_nfs_to_system_error(status_t nfsstatus);
98 extern void get_nfs_attr(struct XDRInPacket *reply, struct stat *st);
99 extern status_t nfs_lookup(fs_nspace *ns, const nfs_fhandle *dir, const char *filename, nfs_fhandle *fhandle, struct stat *st);
100 extern status_t nfs_truncate_file(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st);
101 
102 nfs_fhandle handle_from_vnid (fs_nspace *ns, ino_t vnid);
103 
104 extern status_t nfs_getattr(fs_nspace *ns, const nfs_fhandle *fhandle, struct stat *st);
105 extern void insert_node(fs_nspace *ns, fs_node *node);
106 extern void remove_node(fs_nspace *ns, ino_t vnid);
107 
108 enum {
109 	C_ERROR_STALE = B_ERRORS_END + 1
110 };
111 
112 #define USE_SYSTEM_AUTHENTICATION 1
113 
114 #endif	/* _NFS_ADD_ON_H */
115