| 1 | /* $OpenBSD: fusefs.h,v 1.15 2025/09/08 17:25:46 helg Exp $ */ |
| 2 | /* |
| 3 | * Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com> |
| 4 | * |
| 5 | * Permission to use, copy, modify, and distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __FUSEFS_H__ |
| 19 | #define __FUSEFS_H__ |
| 20 | |
| 21 | /* sysctl defines */ |
| 22 | #define FUSEFS_OPENDEVS		1	/* # of fuse devices opened */ |
| 23 | #define FUSEFS_INFBUFS		2	/* # of in fbufs */ |
| 24 | #define FUSEFS_WAITFBUFS	3	/* # of fbufs waiting for a response */ |
| 25 | #define FUSEFS_POOL_NBPAGES	4	/* # total fusefs size */ |
| 26 | #define FUSEFS_MAXID		5	/* number of valid fusefs ids */ |
| 27 | |
| 28 | #define FUSEFS_NAMES { \ |
| 29 | 	{ 0, 0}, \ |
| 30 | 	{ "fusefs_open_devices", CTLTYPE_INT }, \ |
| 31 | 	{ "fusefs_fbufs_in", CTLTYPE_INT }, \ |
| 32 | 	{ "fusefs_fbufs_wait", CTLTYPE_INT }, \ |
| 33 | 	{ "fusefs_pool_pages", CTLTYPE_INT }, \ |
| 34 | } |
| 35 | |
| 36 | #ifdef _KERNEL |
| 37 | |
| 38 | struct fuse_msg; |
| 39 | |
| 40 | struct fusefs_mnt { |
| 41 | 	struct mount *mp; |
| 42 | 	uint32_t undef_op; |
| 43 | 	int max_read; |
| 44 | 	int sess_init; |
| 45 | 	int allow_other; |
| 46 | 	dev_t dev; |
| 47 | }; |
| 48 | |
| 49 | #define	UNDEF_ACCESS	1<<0 |
| 50 | #define	UNDEF_MKDIR	1<<1 |
| 51 | #define	UNDEF_CREATE	1<<2 |
| 52 | #define	UNDEF_LINK	1<<3 |
| 53 | #define UNDEF_READLINK	1<<4 |
| 54 | #define UNDEF_RMDIR	1<<5 |
| 55 | #define UNDEF_REMOVE	1<<6 |
| 56 | #define UNDEF_SETATTR	1<<7 |
| 57 | #define UNDEF_RENAME	1<<8 |
| 58 | #define UNDEF_SYMLINK	1<<9 |
| 59 | #define UNDEF_MKNOD	1<<10 |
| 60 | #define UNDEF_FLUSH	1<<11 |
| 61 | #define UNDEF_FSYNC	1<<12 |
| 62 | |
| 63 | extern const struct vops fusefs_vops; |
| 64 | extern struct pool fusefs_fbuf_pool; |
| 65 | |
| 66 | /* files helpers. */ |
| 67 | int fusefs_file_open(struct fusefs_mnt *, struct fusefs_node *, enum fufh_type, |
| 68 | int, int, struct proc *); |
| 69 | int fusefs_file_close(struct fusefs_mnt *, struct fusefs_node *, |
| 70 | enum fufh_type, int, int, struct proc *); |
| 71 | |
| 72 | /* device helpers. */ |
| 73 | void fuse_device_cleanup(dev_t); |
| 74 | void fuse_device_queue_fbuf(dev_t, struct fusebuf *); |
| 75 | void fuse_device_set_fmp(struct fusefs_mnt *, int); |
| 76 | |
| 77 | /* |
| 78 | * The root inode is the root of the file system. Inode 0 can't be used for |
| 79 | * normal purposes. |
| 80 | */ |
| 81 | #define	FUSE_ROOTINO ((ino_t)1) |
| 82 | #define VFSTOFUSEFS(mp)	((struct fusefs_mnt *)((mp)->mnt_data)) |
| 83 | |
| 84 | #endif /* _KERNEL */ |
| 85 | #endif /* __FUSEFS_H__ */ |