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