OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef LIBRARIES_NACL_IO_FUSE_H_ | 5 #ifndef LIBRARIES_NACL_IO_FUSE_H_ |
6 #define LIBRARIES_NACL_IO_FUSE_H_ | 6 #define LIBRARIES_NACL_IO_FUSE_H_ |
7 | 7 |
8 #include "osinttypes.h" | 8 #include "osinttypes.h" |
9 #include "ostypes.h" | 9 #include "ostypes.h" |
10 | 10 |
11 // These interfaces are copied from the FUSE library. | 11 // These interfaces are copied from the FUSE library. |
Sam Clegg
2014/09/24 20:48:28
We should probably convert these to C-style commen
binji
2014/09/24 21:30:50
Acknowledged.
| |
12 // | 12 // |
13 // FUSE has two interfaces that can be implemented: low-level and high-level. | 13 // FUSE has two interfaces that can be implemented: low-level and high-level. |
14 // In nacl_io, we only support the high-level interface. | 14 // In nacl_io, we only support the high-level interface. |
15 // | 15 // |
16 // See http://fuse.sourceforge.net/ for more information. | 16 // See http://fuse.sourceforge.net/ for more information. |
17 | 17 |
18 // This struct is typically passed to functions that would normally use return | 18 // This struct is typically passed to functions that would normally use return |
19 // or receive an fd; that is, operations to open/create a node, or operations | 19 // or receive an fd; that is, operations to open/create a node, or operations |
20 // that act on an already opened node. | 20 // that act on an already opened node. |
21 struct fuse_file_info { | 21 struct fuse_file_info { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 // etc. The sign will be flipped when the error is actually set. | 80 // etc. The sign will be flipped when the error is actually set. |
81 // | 81 // |
82 // Some functions (e.g. read, write) also return a positive count, which is the | 82 // Some functions (e.g. read, write) also return a positive count, which is the |
83 // number of bytes read/written. | 83 // number of bytes read/written. |
84 // | 84 // |
85 struct fuse_operations { | 85 struct fuse_operations { |
86 // Currently unsupported | 86 // Currently unsupported |
87 unsigned int flag_nopath : 1; | 87 unsigned int flag_nopath : 1; |
88 unsigned int flag_reserved : 31; | 88 unsigned int flag_reserved : 31; |
89 | 89 |
90 // Called when a filesystem of this type is initialized. | |
91 void* (*init)(struct fuse_conn_info* conn); | |
92 // Called when a filesystem of this type is unmounted. | |
93 void (*destroy)(void*); | |
94 // Called by access() | |
95 int (*access)(const char* path, int mode); | |
96 // Called when O_CREAT is passed to open() | |
97 int (*create)(const char* path, mode_t mode, struct fuse_file_info*); | |
98 // Called by stat()/fstat(). If this function pointer is non-NULL, it is | |
99 // called, otherwise fuse_operations.getattr will be called. | |
100 int (*fgetattr)(const char* path, struct stat*, struct fuse_file_info*); | |
101 // Called by fsync(). The datasync paramater is not currently supported. | |
102 int (*fsync)(const char* path, int datasync, struct fuse_file_info*); | |
103 // Called by ftruncate() | |
104 int (*ftruncate)(const char* path, off_t, struct fuse_file_info*); | |
105 // Called by stat()/fstat(), but only when fuse_operations.fgetattr is NULL. | 90 // Called by stat()/fstat(), but only when fuse_operations.fgetattr is NULL. |
106 // Also called by open() to determine if the path is a directory or a regular | 91 // Also called by open() to determine if the path is a directory or a regular |
107 // file. | 92 // file. |
108 int (*getattr)(const char* path, struct stat*); | 93 int (*getattr)(const char* path, struct stat*); |
109 // Called by mkdir() | 94 // Not called currently. |
110 int (*mkdir)(const char* path, mode_t); | 95 int (*readlink)(const char*, char*, size_t); |
111 // Called when O_CREAT is passed to open(), but only if fuse_operations.create | 96 // Called when O_CREAT is passed to open(), but only if fuse_operations.create |
112 // is non-NULL. | 97 // is non-NULL. |
113 int (*mknod)(const char* path, mode_t, dev_t); | 98 int (*mknod)(const char* path, mode_t, dev_t); |
99 // Called by mkdir() | |
100 int (*mkdir)(const char* path, mode_t); | |
101 // Called by unlink() | |
102 int (*unlink)(const char* path); | |
103 // Called by rmdir() | |
104 int (*rmdir)(const char* path); | |
105 // Not called currently. | |
106 int (*symlink)(const char*, const char*); | |
107 // Called by rename() | |
108 int (*rename)(const char* path, const char* new_path); | |
109 // Not called currently. | |
110 int (*link)(const char*, const char*); | |
111 // Called by chmod()/fchmod() | |
112 int (*chmod)(const char*, mode_t); | |
113 // Not called currently. | |
114 int (*chown)(const char*, uid_t, gid_t); | |
115 // Called by truncate(), as well as open() when O_TRUNC is passed. | |
116 int (*truncate)(const char* path, off_t); | |
114 // Called by open() | 117 // Called by open() |
115 int (*open)(const char* path, struct fuse_file_info*); | 118 int (*open)(const char* path, struct fuse_file_info*); |
116 // Called by getdents(), which is called by the more standard functions | |
117 // opendir()/readdir(). | |
118 int (*opendir)(const char* path, struct fuse_file_info*); | |
119 // Called by read(). Note that FUSE specifies that all reads will fill the | 119 // Called by read(). Note that FUSE specifies that all reads will fill the |
120 // entire requested buffer. If this function returns less than that, the | 120 // entire requested buffer. If this function returns less than that, the |
121 // remainder of the buffer is zeroed. | 121 // remainder of the buffer is zeroed. |
122 int (*read)(const char* path, | 122 int (*read)(const char* path, |
123 char* buf, | 123 char* buf, |
124 size_t count, | 124 size_t count, |
125 off_t, | 125 off_t, |
126 struct fuse_file_info*); | 126 struct fuse_file_info*); |
127 // Called by write(). Note that FUSE specifies that a write should always | |
128 // return the full count, unless an error occurs. | |
129 int (*write)(const char* path, | |
130 const char* buf, | |
131 size_t count, | |
132 off_t, | |
133 struct fuse_file_info*); | |
134 // Not called currently. | |
135 int (*statfs)(const char*, struct statvfs*); | |
136 // Not called currently. | |
137 int (*flush)(const char*, struct fuse_file_info*); | |
138 // Called when the last reference to this node is released. This is only | |
139 // called for regular files. For directories, fuse_operations.releasedir is | |
140 // called instead. | |
141 int (*release)(const char* path, struct fuse_file_info*); | |
142 // Called by fsync(). The datasync paramater is not currently supported. | |
143 int (*fsync)(const char* path, int datasync, struct fuse_file_info*); | |
144 // Not called currently. | |
145 int (*setxattr)(const char*, const char*, const char*, size_t, int); | |
146 // Not called currently. | |
147 int (*getxattr)(const char*, const char*, char*, size_t); | |
148 // Not called currently. | |
149 int (*listxattr)(const char*, char*, size_t); | |
150 // Not called currently. | |
151 int (*removexattr)(const char*, const char*); | |
152 // Called by getdents(), which is called by the more standard functions | |
153 // opendir()/readdir(). | |
154 int (*opendir)(const char* path, struct fuse_file_info*); | |
127 // Called by getdents(), which is called by the more standard function | 155 // Called by getdents(), which is called by the more standard function |
128 // readdir(). | 156 // readdir(). |
129 // | 157 // |
130 // NOTE: it is the responsibility of this function to add the "." and ".." | 158 // NOTE: it is the responsibility of this function to add the "." and ".." |
131 // entries. | 159 // entries. |
132 // | 160 // |
133 // This function can be implemented one of two ways: | 161 // This function can be implemented one of two ways: |
134 // 1) Ignore the offset, and always write every entry in a given directory. | 162 // 1) Ignore the offset, and always write every entry in a given directory. |
135 // In this case, you should always call filler() with an offset of 0. You | 163 // In this case, you should always call filler() with an offset of 0. You |
136 // can ignore the return value of the filler. | 164 // can ignore the return value of the filler. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 // // No more entries, we're done. | 197 // // No more entries, we're done. |
170 // return 0; | 198 // return 0; |
171 // } | 199 // } |
172 // | 200 // |
173 int (*readdir)(const char* path, | 201 int (*readdir)(const char* path, |
174 void* buf, | 202 void* buf, |
175 fuse_fill_dir_t filldir, | 203 fuse_fill_dir_t filldir, |
176 off_t, | 204 off_t, |
177 struct fuse_file_info*); | 205 struct fuse_file_info*); |
178 // Called when the last reference to this node is released. This is only | 206 // Called when the last reference to this node is released. This is only |
179 // called for regular files. For directories, fuse_operations.releasedir is | |
180 // called instead. | |
181 int (*release)(const char* path, struct fuse_file_info*); | |
182 // Called when the last reference to this node is released. This is only | |
183 // called for directories. For regular files, fuse_operations.release is | 207 // called for directories. For regular files, fuse_operations.release is |
184 // called instead. | 208 // called instead. |
185 int (*releasedir)(const char* path, struct fuse_file_info*); | 209 int (*releasedir)(const char* path, struct fuse_file_info*); |
186 // Called by rename() | 210 // Not called currently. |
187 int (*rename)(const char* path, const char* new_path); | 211 int (*fsyncdir)(const char*, int, struct fuse_file_info*); |
188 // Called by rmdir() | 212 // Called when a filesystem of this type is initialized. |
189 int (*rmdir)(const char* path); | 213 void* (*init)(struct fuse_conn_info* conn); |
190 // Called by truncate(), as well as open() when O_TRUNC is passed. | 214 // Called when a filesystem of this type is unmounted. |
191 int (*truncate)(const char* path, off_t); | 215 void (*destroy)(void*); |
192 // Called by unlink() | 216 // Called by access() |
193 int (*unlink)(const char* path); | 217 int (*access)(const char* path, int mode); |
194 // Called by write(). Note that FUSE specifies that a write should always | 218 // Called when O_CREAT is passed to open() |
195 // return the full count, unless an error occurs. | 219 int (*create)(const char* path, mode_t mode, struct fuse_file_info*); |
196 int (*write)(const char* path, | 220 // Called by ftruncate() |
197 const char* buf, | 221 int (*ftruncate)(const char* path, off_t, struct fuse_file_info*); |
198 size_t count, | 222 // Called by stat()/fstat(). If this function pointer is non-NULL, it is |
199 off_t, | 223 // called, otherwise fuse_operations.getattr will be called. |
200 struct fuse_file_info*); | 224 int (*fgetattr)(const char* path, struct stat*, struct fuse_file_info*); |
225 // Not called currently. | |
226 int (*lock)(const char*, struct fuse_file_info*, int cmd, struct flock*); | |
201 // Called by utime()/utimes()/futimes()/futimens() etc. | 227 // Called by utime()/utimes()/futimes()/futimens() etc. |
202 int (*utimens)(const char*, const struct timespec tv[2]); | 228 int (*utimens)(const char*, const struct timespec tv[2]); |
203 | 229 // Not called currently. |
204 // The following functions are not currently called by the nacl_io | |
205 // implementation of FUSE. | |
206 int (*bmap)(const char*, size_t blocksize, uint64_t* idx); | 230 int (*bmap)(const char*, size_t blocksize, uint64_t* idx); |
207 int (*chmod)(const char*, mode_t); | 231 // Not called currently. |
208 int (*chown)(const char*, uid_t, gid_t); | |
209 int (*fallocate)(const char*, int, off_t, off_t, struct fuse_file_info*); | |
210 int (*flock)(const char*, struct fuse_file_info*, int op); | |
211 int (*flush)(const char*, struct fuse_file_info*); | |
212 int (*fsyncdir)(const char*, int, struct fuse_file_info*); | |
213 int (*getxattr)(const char*, const char*, char*, size_t); | |
214 int (*ioctl)(const char*, | 232 int (*ioctl)(const char*, |
215 int cmd, | 233 int cmd, |
216 void* arg, | 234 void* arg, |
217 struct fuse_file_info*, | 235 struct fuse_file_info*, |
218 unsigned int flags, | 236 unsigned int flags, |
219 void* data); | 237 void* data); |
220 int (*link)(const char*, const char*); | 238 // Not called currently. |
221 int (*listxattr)(const char*, char*, size_t); | |
222 int (*lock)(const char*, struct fuse_file_info*, int cmd, struct flock*); | |
223 int (*poll)(const char*, | 239 int (*poll)(const char*, |
224 struct fuse_file_info*, | 240 struct fuse_file_info*, |
225 struct fuse_pollhandle* ph, | 241 struct fuse_pollhandle* ph, |
226 unsigned* reventsp); | 242 unsigned* reventsp); |
243 // Not called currently. | |
244 int (*write_buf)(const char*, | |
245 struct fuse_bufvec* buf, | |
246 off_t off, | |
247 struct fuse_file_info*); | |
248 // Not called currently. | |
227 int (*read_buf)(const char*, | 249 int (*read_buf)(const char*, |
228 struct fuse_bufvec** bufp, | 250 struct fuse_bufvec** bufp, |
229 size_t size, | 251 size_t size, |
230 off_t off, | 252 off_t off, |
231 struct fuse_file_info*); | 253 struct fuse_file_info*); |
232 int (*readlink)(const char*, char*, size_t); | 254 // Not called currently. |
233 int (*removexattr)(const char*, const char*); | 255 int (*flock)(const char*, struct fuse_file_info*, int op); |
234 int (*setxattr)(const char*, const char*, const char*, size_t, int); | 256 // Not called currently. |
235 int (*statfs)(const char*, struct statvfs*); | 257 int (*fallocate)(const char*, int, off_t, off_t, struct fuse_file_info*); |
236 int (*symlink)(const char*, const char*); | |
237 int (*write_buf)(const char*, | |
238 struct fuse_bufvec* buf, | |
239 off_t off, | |
240 struct fuse_file_info*); | |
241 }; | 258 }; |
242 | 259 |
243 #endif // LIBRARIES_NACL_IO_FUSE_H_ | 260 #endif // LIBRARIES_NACL_IO_FUSE_H_ |
OLD | NEW |