1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
2 
3 /*
4  * This file is based on include/uapi/linux/fuse.h from Linux, and is used
5  * under the BSD-2-Clause license, as per the dual-license option
6  */
7 /*
8  * This file defines the kernel interface of FUSE
9  * This -- and only this -- header file may also be distributed under
10  * the terms of the BSD Licence as follows:
11  *
12  * Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  *
23  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 #ifndef ZEPHYR_SUBSYS_FS_FUSE_ABI_H_
37 #define ZEPHYR_SUBSYS_FS_FUSE_ABI_H_
38 #include <stdint.h>
39 
40 #define FUSE_MAJOR_VERSION 7
41 #define FUSE_MINOR_VERSION 31
42 
43 #define FUSE_LOOKUP 1
44 #define FUSE_FORGET 2
45 #define FUSE_SETATTR 4
46 #define FUSE_MKDIR 9
47 #define FUSE_UNLINK 10
48 #define FUSE_RMDIR 11
49 #define FUSE_RENAME 12
50 #define FUSE_OPEN 14
51 #define FUSE_READ 15
52 #define FUSE_WRITE 16
53 #define FUSE_STATFS 17
54 #define FUSE_RELEASE 18
55 #define FUSE_FSYNC 20
56 #define FUSE_INIT 26
57 #define FUSE_OPENDIR 27
58 #define FUSE_READDIR 28
59 #define FUSE_RELEASEDIR 29
60 #define FUSE_CREATE 35
61 #define FUSE_DESTROY 38
62 #define FUSE_LSEEK 46
63 
64 #define FUSE_ROOT_INODE 1
65 
66 struct fuse_in_header {
67 	uint32_t len;
68 	uint32_t opcode;
69 	uint64_t unique;
70 	uint64_t nodeid;
71 	uint32_t uid;
72 	uint32_t gid;
73 	uint32_t pid;
74 	uint16_t total_extlen;
75 	uint16_t padding;
76 };
77 
78 struct fuse_out_header {
79 	uint32_t len;
80 	int32_t error;
81 	uint64_t unique;
82 };
83 
84 struct fuse_init_in {
85 	uint32_t major;
86 	uint32_t minor;
87 	uint32_t max_readahead;
88 	uint32_t flags;
89 	uint32_t flags2;
90 	uint32_t unused[11];
91 };
92 
93 struct fuse_init_out {
94 	uint32_t major;
95 	uint32_t minor;
96 	uint32_t max_readahead;
97 	uint32_t flags;
98 	uint16_t max_background;
99 	uint16_t congestion_threshold;
100 	uint32_t max_write;
101 	uint32_t time_gran;
102 	uint16_t max_pages;
103 	uint16_t map_alignment;
104 	uint32_t flags2;
105 	uint32_t max_stack_depth;
106 	uint32_t unused[6];
107 };
108 
109 struct fuse_open_in {
110 	uint32_t flags;
111 	uint32_t open_flags;
112 };
113 
114 struct fuse_open_out {
115 	uint64_t fh;
116 	uint32_t open_flags;
117 	int32_t backing_id;
118 };
119 
120 struct fuse_attr {
121 	uint64_t ino;
122 	uint64_t size;
123 	uint64_t blocks;
124 	uint64_t atime;
125 	uint64_t mtime;
126 	uint64_t ctime;
127 	uint32_t atimensec;
128 	uint32_t mtimensec;
129 	uint32_t ctimensec;
130 	uint32_t mode;
131 	uint32_t nlink;
132 	uint32_t uid;
133 	uint32_t gid;
134 	uint32_t rdev;
135 	uint32_t blksize;
136 	uint32_t flags;
137 };
138 
139 struct fuse_entry_out {
140 	uint64_t nodeid;
141 	uint64_t generation;
142 	uint64_t entry_valid;
143 	uint64_t attr_valid;
144 	uint32_t entry_valid_nsec;
145 	uint32_t attr_valid_nsec;
146 	struct fuse_attr attr;
147 };
148 
149 struct fuse_read_in {
150 	uint64_t fh;
151 	uint64_t offset;
152 	uint32_t size;
153 	uint32_t read_flags;
154 	uint64_t lock_owner;
155 	uint32_t flags;
156 	uint32_t padding;
157 };
158 
159 struct fuse_release_in {
160 	uint64_t fh;
161 	uint32_t flags;
162 	uint32_t release_flags;
163 	uint64_t lock_owner;
164 };
165 
166 struct fuse_create_in {
167 	uint32_t flags;
168 	uint32_t mode;
169 	uint32_t umask;
170 	uint32_t open_flags;
171 };
172 
173 struct fuse_create_out {
174 	struct fuse_entry_out entry_out;
175 	struct fuse_open_out open_out;
176 };
177 
178 struct fuse_write_in {
179 	uint64_t fh;
180 	uint64_t offset;
181 	uint32_t size;
182 	uint32_t write_flags;
183 	uint64_t lock_owner;
184 	uint32_t flags;
185 	uint32_t padding;
186 };
187 
188 struct fuse_write_out {
189 	uint32_t size;
190 	uint32_t padding;
191 };
192 
193 struct fuse_lseek_in {
194 	uint64_t fh;
195 	uint64_t offset;
196 	uint32_t whence;
197 	uint32_t padding;
198 };
199 
200 struct fuse_lseek_out {
201 	uint64_t offset;
202 };
203 
204 /* mask used to set file size, used in fuse_setattr_in::valid */
205 #define FATTR_SIZE	(1 << 3)
206 
207 struct fuse_setattr_in {
208 	uint32_t valid;
209 	uint32_t padding;
210 	uint64_t fh;
211 	uint64_t size;
212 	uint64_t lock_owner;
213 	uint64_t atime;
214 	uint64_t mtime;
215 	uint64_t ctime;
216 	uint32_t atimensec;
217 	uint32_t mtimensec;
218 	uint32_t ctimensec;
219 	uint32_t mode;
220 	uint32_t unused4;
221 	uint32_t uid;
222 	uint32_t gid;
223 	uint32_t unused5;
224 };
225 
226 struct fuse_attr_out {
227 	uint64_t attr_valid;
228 	uint32_t attr_valid_nsec;
229 	uint32_t dummy;
230 	struct fuse_attr attr;
231 };
232 
233 struct fuse_fsync_in {
234 	uint64_t fh;
235 	uint32_t fsync_flags;
236 	uint32_t padding;
237 };
238 
239 struct fuse_mkdir_in {
240 	uint32_t mode;
241 	uint32_t umask;
242 };
243 
244 struct fuse_rename_in {
245 	uint64_t newdir;
246 };
247 
248 struct fuse_kstatfs {
249 	uint64_t blocks;
250 	uint64_t bfree;
251 	uint64_t bavail;
252 	uint64_t files;
253 	uint64_t ffree;
254 	uint32_t bsize;
255 	uint32_t namelen;
256 	uint32_t frsize;
257 	uint32_t padding;
258 	uint32_t spare[6];
259 };
260 
261 struct fuse_dirent {
262 	uint64_t ino;
263 	uint64_t off;
264 	uint32_t namelen;
265 	uint32_t type;
266 	char name[];
267 };
268 
269 struct fuse_forget_in {
270 	uint64_t nlookup;
271 };
272 
273 #endif /* ZEPHYR_SUBSYS_FS_FUSE_ABI_H_ */
274