2 * Copyright (c) 2019 Tomohiro Kusumi <tkusumi@netbsd.org>
3 * Copyright (c) 2019 The DragonFly Project
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 fuse_hexdump(const char *p
, size_t len
)
38 for (i
= 0; i
< (int)len
; i
++) {
39 kprintf("%02X ", p
[i
] & 0xff);
40 if ((i
+ 1) % 32 == 0)
47 fuse_fill_in_header(struct fuse_in_header
*ihd
,
48 uint32_t len
, uint32_t opcode
, uint64_t unique
, uint64_t nodeid
,
49 uint32_t uid
, uint32_t gid
, uint32_t pid
)
61 fuse_forget_node(struct fuse_mount
*fmp
, uint64_t ino
, uint64_t nlookup
,
65 struct fuse_forget_in
*ffi
;
68 KKASSERT(nlookup
> 0);
70 fip
= fuse_ipc_get(fmp
, sizeof(*ffi
));
71 ffi
= fuse_ipc_fill(fip
, FUSE_FORGET
, ino
, cred
);
72 ffi
->nlookup
= nlookup
;
74 error
= fuse_ipc_tx_noreply(fip
);
83 * Ignore FUSE_COMPAT_XXX which seem to exist for backward compatibility
84 * for ancient versions of FUSE protocol.
87 fuse_audit_length(struct fuse_in_header
*ihd
, struct fuse_out_header
*ohd
)
89 size_t len
= ohd
->len
- sizeof(struct fuse_out_header
);
92 switch (ihd
->opcode
) {
94 res
= (len
== sizeof(struct fuse_entry_out
));
100 res
= (len
== sizeof(struct fuse_attr_out
));
103 res
= (len
== sizeof(struct fuse_attr_out
));
106 res
= (len
<= PAGE_SIZE
);
109 res
= (len
== sizeof(struct fuse_entry_out
));
112 res
= (len
== sizeof(struct fuse_entry_out
));
115 res
= (len
== sizeof(struct fuse_entry_out
));
127 res
= (len
== sizeof(struct fuse_entry_out
));
130 res
= (len
== sizeof(struct fuse_open_out
));
133 res
= (len
<= ((struct fuse_read_in
*)(ihd
+ 1))->size
);
136 res
= (len
== sizeof(struct fuse_write_out
));
139 res
= (len
== sizeof(struct fuse_statfs_out
));
156 case FUSE_REMOVEXATTR
:
163 res
= (len
== sizeof(struct fuse_init_out
));
166 res
= (len
== sizeof(struct fuse_open_out
));
169 res
= (len
<= ((struct fuse_read_in
*)(ihd
+ 1))->size
);
171 case FUSE_RELEASEDIR
:
190 res
= (len
== sizeof(struct fuse_entry_out
) +
191 sizeof(struct fuse_open_out
));
208 case FUSE_NOTIFY_REPLY
:
211 case FUSE_BATCH_FORGET
:
217 case FUSE_READDIRPLUS
:
226 case FUSE_COPY_FILE_RANGE
:
230 fuse_panic("Invalid opcode %d", ihd
->opcode
);
244 return "FUSE_LOOKUP";
246 return "FUSE_FORGET";
248 return "FUSE_GETATTR";
250 return "FUSE_SETATTR";
252 return "FUSE_READLINK";
254 return "FUSE_SYMLINK";
260 return "FUSE_UNLINK";
264 return "FUSE_RENAME";
274 return "FUSE_STATFS";
276 return "FUSE_RELEASE";
280 return "FUSE_SETXATTR";
282 return "FUSE_GETXATTR";
284 return "FUSE_LISTXATTR";
285 case FUSE_REMOVEXATTR
:
286 return "FUSE_REMOVEXATTR";
292 return "FUSE_OPENDIR";
294 return "FUSE_READDIR";
295 case FUSE_RELEASEDIR
:
296 return "FUSE_RELEASEDIR";
298 return "FUSE_FSYNCDIR";
304 return "FUSE_SETLKW";
306 return "FUSE_ACCESS";
308 return "FUSE_CREATE";
310 return "FUSE_INTERRUPT";
314 return "FUSE_DESTROY";
319 case FUSE_NOTIFY_REPLY
:
320 return "FUSE_NOTIFY_REPLY";
321 case FUSE_BATCH_FORGET
:
322 return "FUSE_BATCH_FORGET";
324 return "FUSE_FALLOCATE";
325 case FUSE_READDIRPLUS
:
326 return "FUSE_READDIRPLUS";
328 return "FUSE_RENAME2";
331 case FUSE_COPY_FILE_RANGE
:
332 return "FUSE_COPY_FILE_RANGE";
334 fuse_panic("Invalid opcode %d", op
);