| 1 | /* $OpenBSD: fusefs_node.h,v 1.6 2026/01/22 11:53:31 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_NODE_H_ |
| 19 | #define _FUSEFS_NODE_H_ |
| 20 | |
| 21 | #include <sys/queue.h> |
| 22 | |
| 23 | enum fufh_type { |
| 24 | 	FUFH_INVALID = -1, |
| 25 | 	FUFH_RDONLY = 0, |
| 26 | 	FUFH_WRONLY = 1, |
| 27 | 	FUFH_RDWR = 2, |
| 28 | 	FUFH_MAXTYPE = 3, |
| 29 | }; |
| 30 | |
| 31 | struct fusefs_filehandle { |
| 32 | 	uint64_t fh_id; |
| 33 | 	enum fufh_type fh_type; |
| 34 | }; |
| 35 | |
| 36 | struct fusefs_mnt; |
| 37 | struct fusefs_node { |
| 38 | 	LIST_ENTRY(fusefs_node)	 i_hash; /* Hash chain */ |
| 39 | 	struct	vnode		*i_vnode;/* Vnode associated with this inode. */ |
| 40 | 	struct	fusefs_mnt	*i_ump; |
| 41 | 	dev_t			 i_dev;	 /* Device associated with the inode. */ |
| 42 | 	ino_t			 i_number;	/* The identity of the inode. */ |
| 43 | 	ino_t			 i_parent_cache;/* Parent inode (only dirs). */ |
| 44 | 	struct	lockf_state	*i_lockf;	/* Byte-level lock state. */ |
| 45 | 	struct	rrwlock		 i_lock;	/* Inode lock */ |
| 46 | |
| 47 | 	/** I/O **/ |
| 48 | 	struct fusefs_filehandle fufh[FUFH_MAXTYPE]; |
| 49 | |
| 50 | 	/** meta **/ |
| 51 | 	off_t			 filesize; |
| 52 | }; |
| 53 | |
| 54 | #ifdef ITOV |
| 55 | # undef ITOV |
| 56 | #endif |
| 57 | #define ITOV(ip) ((ip)->i_vnode) |
| 58 | |
| 59 | #ifdef VTOI |
| 60 | # undef VTOI |
| 61 | #endif |
| 62 | #define VTOI(vp) ((struct fusefs_node *)(vp)->v_data) |
| 63 | |
| 64 | void		 fuse_ihashinit(void); |
| 65 | struct vnode	*fuse_ihashget(dev_t, ino_t); |
| 66 | int		 fuse_ihashins(struct fusefs_node *); |
| 67 | void		 fuse_ihashrem(struct fusefs_node *); |
| 68 | |
| 69 | uint64_t fusefs_fd_get(struct fusefs_node *, enum fufh_type); |
| 70 | |
| 71 | #endif /* _FUSEFS_NODE_H_ */ |