1 | #ifndef __NETFILE_HPP_ |
---|
2 | #define __NETFILE_HPP_ |
---|
3 | |
---|
4 | #include <sys/types.h> |
---|
5 | |
---|
6 | |
---|
7 | void secure_filename(char *filename, char *mode); |
---|
8 | |
---|
9 | class nfs_client // this is a client only read's a file |
---|
10 | { |
---|
11 | public : |
---|
12 | int socket_fd; |
---|
13 | int file_fd; |
---|
14 | |
---|
15 | long size_to_read; |
---|
16 | long size; |
---|
17 | nfs_client *next; |
---|
18 | nfs_client(int Socket_fd, int File_fd, nfs_client *Next); |
---|
19 | int send_read(); // flushes as much of size_to_read as possible |
---|
20 | ~nfs_client(); |
---|
21 | } ; |
---|
22 | |
---|
23 | |
---|
24 | class remote_file // a remote client has opened this file with us |
---|
25 | { |
---|
26 | public : |
---|
27 | int socket_fd; |
---|
28 | void r_close(char *reason); |
---|
29 | long size; // server tells us the size of the file when we open it |
---|
30 | int open_local; |
---|
31 | remote_file *next; |
---|
32 | remote_file(char *filename, char *mode, remote_file *Next); |
---|
33 | |
---|
34 | int unbuffered_read(int out_fd, size_t count); |
---|
35 | int unbuffered_write(void *buf, size_t count) { return 0; } // not supported |
---|
36 | int unbuffered_tell(); |
---|
37 | int unbuffered_seek(long offset); |
---|
38 | int file_size() { return size; } |
---|
39 | int open_failure() { return socket_fd<0; } |
---|
40 | ~remote_file(); |
---|
41 | int fd() { return socket_fd; } |
---|
42 | } ; |
---|
43 | |
---|
44 | |
---|
45 | extern nfs_client *first_nfs_client; |
---|
46 | extern remote_file *remote_file_list; |
---|
47 | extern char default_fs_name[256]; |
---|
48 | |
---|
49 | int process_nfs_command(nfs_client *c); |
---|
50 | void add_nfs_client(int fd); |
---|
51 | int local_address(char *server_name); // returns 1 if server name is ourself |
---|
52 | remote_file *find_rfile(int fd); |
---|
53 | void unlink_remote_file(remote_file *rf); |
---|
54 | int open_file(char *&filename, char *mode); |
---|
55 | int fetch_crcs(char *server); |
---|
56 | |
---|
57 | #endif |
---|