1 /*
2   FUSE: Filesystem in Userspace
3   Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
4 
5   This program can be distributed under the terms of the GNU LGPLv2.
6   See the file COPYING.LIB.
7 */
8 
9 /* these definitions provide source compatibility to prior versions.
10    Do not include this file directly! */
11 
12 struct fuse_lowlevel_ops_compat25 {
13 	void (*init) (void *userdata);
14 	void (*destroy) (void *userdata);
15 	void (*lookup) (fuse_req_t req, fuse_ino_t parent, const char *name);
16 	void (*forget) (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup);
17 	void (*getattr) (fuse_req_t req, fuse_ino_t ino,
18 			 struct fuse_file_info *fi);
19 	void (*setattr) (fuse_req_t req, fuse_ino_t ino, struct stat *attr,
20 			 int to_set, struct fuse_file_info *fi);
21 	void (*readlink) (fuse_req_t req, fuse_ino_t ino);
22 	void (*mknod) (fuse_req_t req, fuse_ino_t parent, const char *name,
23 		       mode_t mode, dev_t rdev);
24 	void (*mkdir) (fuse_req_t req, fuse_ino_t parent, const char *name,
25 		       mode_t mode);
26 	void (*unlink) (fuse_req_t req, fuse_ino_t parent, const char *name);
27 	void (*rmdir) (fuse_req_t req, fuse_ino_t parent, const char *name);
28 	void (*symlink) (fuse_req_t req, const char *link, fuse_ino_t parent,
29 			 const char *name);
30 	void (*rename) (fuse_req_t req, fuse_ino_t parent, const char *name,
31 			fuse_ino_t newparent, const char *newname);
32 	void (*link) (fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,
33 		      const char *newname);
34 	void (*open) (fuse_req_t req, fuse_ino_t ino,
35 		      struct fuse_file_info *fi);
36 	void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
37 		      struct fuse_file_info *fi);
38 	void (*write) (fuse_req_t req, fuse_ino_t ino, const char *buf,
39 		       size_t size, off_t off, struct fuse_file_info *fi);
40 	void (*flush) (fuse_req_t req, fuse_ino_t ino,
41 		       struct fuse_file_info *fi);
42 	void (*release) (fuse_req_t req, fuse_ino_t ino,
43 			 struct fuse_file_info *fi);
44 	void (*fsync) (fuse_req_t req, fuse_ino_t ino, int datasync,
45 		       struct fuse_file_info *fi);
46 	void (*opendir) (fuse_req_t req, fuse_ino_t ino,
47 			 struct fuse_file_info *fi);
48 	void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
49 			 struct fuse_file_info *fi);
50 	void (*releasedir) (fuse_req_t req, fuse_ino_t ino,
51 			    struct fuse_file_info *fi);
52 	void (*fsyncdir) (fuse_req_t req, fuse_ino_t ino, int datasync,
53 			  struct fuse_file_info *fi);
54 	void (*statfs) (fuse_req_t req);
55 	void (*setxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
56 			  const char *value, size_t size, int flags);
57 	void (*getxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
58 			  size_t size);
59 	void (*listxattr) (fuse_req_t req, fuse_ino_t ino, size_t size);
60 	void (*removexattr) (fuse_req_t req, fuse_ino_t ino, const char *name);
61 	void (*access) (fuse_req_t req, fuse_ino_t ino, int mask);
62 	void (*create) (fuse_req_t req, fuse_ino_t parent, const char *name,
63 			mode_t mode, struct fuse_file_info *fi);
64 };
65 
66 struct fuse_session *fuse_lowlevel_new_compat25(struct fuse_args *args,
67 				const struct fuse_lowlevel_ops_compat25 *op,
68 				size_t op_size, void *userdata);
69 
70 size_t fuse_dirent_size(size_t namelen);
71 
72 char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
73 		      off_t off);
74 
75 #if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
76 
77 #include <sys/statfs.h>
78 
79 struct fuse_lowlevel_ops_compat {
80 	void (*init) (void *userdata);
81 	void (*destroy) (void *userdata);
82 	void (*lookup) (fuse_req_t req, fuse_ino_t parent, const char *name);
83 	void (*forget) (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup);
84 	void (*getattr) (fuse_req_t req, fuse_ino_t ino,
85 			 struct fuse_file_info_compat *fi);
86 	void (*setattr) (fuse_req_t req, fuse_ino_t ino, struct stat *attr,
87 			 int to_set, struct fuse_file_info_compat *fi);
88 	void (*readlink) (fuse_req_t req, fuse_ino_t ino);
89 	void (*mknod) (fuse_req_t req, fuse_ino_t parent, const char *name,
90 		       mode_t mode, dev_t rdev);
91 	void (*mkdir) (fuse_req_t req, fuse_ino_t parent, const char *name,
92 		       mode_t mode);
93 	void (*unlink) (fuse_req_t req, fuse_ino_t parent, const char *name);
94 	void (*rmdir) (fuse_req_t req, fuse_ino_t parent, const char *name);
95 	void (*symlink) (fuse_req_t req, const char *link, fuse_ino_t parent,
96 			 const char *name);
97 	void (*rename) (fuse_req_t req, fuse_ino_t parent, const char *name,
98 			fuse_ino_t newparent, const char *newname);
99 	void (*link) (fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,
100 		      const char *newname);
101 	void (*open) (fuse_req_t req, fuse_ino_t ino,
102 		      struct fuse_file_info_compat *fi);
103 	void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
104 		      struct fuse_file_info_compat *fi);
105 	void (*write) (fuse_req_t req, fuse_ino_t ino, const char *buf,
106 		       size_t size, off_t off, struct fuse_file_info_compat *fi);
107 	void (*flush) (fuse_req_t req, fuse_ino_t ino,
108 		       struct fuse_file_info_compat *fi);
109 	void (*release) (fuse_req_t req, fuse_ino_t ino,
110 			 struct fuse_file_info_compat *fi);
111 	void (*fsync) (fuse_req_t req, fuse_ino_t ino, int datasync,
112 		       struct fuse_file_info_compat *fi);
113 	void (*opendir) (fuse_req_t req, fuse_ino_t ino,
114 			 struct fuse_file_info_compat *fi);
115 	void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
116 			 struct fuse_file_info_compat *fi);
117 	void (*releasedir) (fuse_req_t req, fuse_ino_t ino,
118 			    struct fuse_file_info_compat *fi);
119 	void (*fsyncdir) (fuse_req_t req, fuse_ino_t ino, int datasync,
120 			  struct fuse_file_info_compat *fi);
121 	void (*statfs) (fuse_req_t req);
122 	void (*setxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
123 			  const char *value, size_t size, int flags);
124 	void (*getxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
125 			  size_t size);
126 	void (*listxattr) (fuse_req_t req, fuse_ino_t ino, size_t size);
127 	void (*removexattr) (fuse_req_t req, fuse_ino_t ino, const char *name);
128 	void (*access) (fuse_req_t req, fuse_ino_t ino, int mask);
129 	void (*create) (fuse_req_t req, fuse_ino_t parent, const char *name,
130 			mode_t mode, struct fuse_file_info_compat *fi);
131 };
132 
133 int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf);
134 
135 int fuse_reply_open_compat(fuse_req_t req,
136 			   const struct fuse_file_info_compat *fi);
137 
138 struct fuse_session *fuse_lowlevel_new_compat(const char *opts,
139 				const struct fuse_lowlevel_ops_compat *op,
140 				size_t op_size, void *userdata);
141 
142 #endif /* __FreeBSD__ || __NetBSD__ */
143 
144 struct fuse_chan_ops_compat24 {
145 	int (*receive)(struct fuse_chan *ch, char *buf, size_t size);
146 	int (*send)(struct fuse_chan *ch, const struct iovec iov[],
147 		    size_t count);
148 	void (*destroy)(struct fuse_chan *ch);
149 };
150 
151 struct fuse_chan *fuse_chan_new_compat24(struct fuse_chan_ops_compat24 *op,
152 					 int fd, size_t bufsize, void *data);
153 
154 int fuse_chan_receive(struct fuse_chan *ch, char *buf, size_t size);
155 struct fuse_chan *fuse_kern_chan_new(int fd);
156