1 #ifndef _MFSIO_H_
2 #define _MFSIO_H_
3 
4 #include <inttypes.h>
5 #include <unistd.h>
6 #include <fcntl.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 
10 typedef struct _mfscfg {
11 	char *masterhost;
12 	char *masterport;
13 	char *masterpassword;
14 	char *mountpoint;
15 	char *masterpath;
16 	int read_cache_mb;
17 	int write_cache_mb;
18 	int io_try_cnt;
19 	int error_on_lost_chunk;
20 	int error_on_no_space;
21 	int sugid_clear_mode;
22 	int mkdir_copy_sgid;
23 } mfscfg;
24 
25 #ifndef UTIME_NOW
26 # define UTIME_NOW	((1l << 30) - 1l)
27 #endif
28 #ifndef UTIME_OMIT
29 # define UTIME_OMIT	((1l << 30) - 2l)
30 #endif
31 
32 #ifndef LOCK_SH
33 #define LOCK_SH 1
34 #endif
35 #ifndef LOCK_EX
36 #define LOCK_EX 2
37 #endif
38 #ifndef LOCK_NB
39 #define LOCK_NB 4
40 #endif
41 #ifndef LOCK_UN
42 #define LOCK_UN 8
43 #endif
44 
45 int mfs_mknod(const char *path, mode_t mode, dev_t dev);
46 int mfs_unlink(const char *path);
47 int mfs_mkdir(const char *path, mode_t mode);
48 int mfs_rename(const char *src, const char *dst);
49 int mfs_rmdir(const char *path);
50 int mfs_chmod(const char *path, mode_t mode);
51 int mfs_fchmod(int fildes, mode_t mode);
52 int mfs_chown(const char *path, uid_t owner, gid_t group);
53 int mfs_fchown(int fildes, uid_t owner, gid_t group);
54 int mfs_truncate(const char *path, off_t size);
55 int mfs_ftruncate(int fildes, off_t size);
56 int mfs_utimes(const char *path, const struct timeval times[2]);
57 int mfs_futimes(int fildes, const struct timeval times[2]);
58 int mfs_futimens(int fildes, const struct timespec times[2]);
59 off_t mfs_lseek(int fildes, off_t offset, int whence);
60 int mfs_stat(const char *path, struct stat *buf);
61 int mfs_fstat(int fildes, struct stat *buf);
62 int mfs_open(const char *path,int oflag,...);
63 ssize_t mfs_read(int fildes,void *buf,size_t nbyte);
64 ssize_t mfs_pread(int fildes,void *buf,size_t nbyte,off_t offset);
65 ssize_t mfs_write(int fildes,const void *buf,size_t nbyte);
66 ssize_t mfs_pwrite(int fildes,const void *buf,size_t nbyte,off_t offset);
67 int mfs_fsync(int fildes);
68 int mfs_close(int fildes);
69 int mfs_flock(int fildes, int op);
70 int mfs_lockf(int fildes, int function, off_t size);
71 int mfs_fcntl_locks(int fildes, int function, struct flock *fl);
72 
73 // 0 - initialize everything
74 // 1 - connect to master only (pre fork section)
75 // 2 - initialize everything else (post fork section)
76 
77 int mfs_init(mfscfg *mcfg,uint8_t stage);
78 void mfs_term(void);
79 
80 #endif
81