jcs's openbsd hax
openbsd

This is a preperatory patch to move things around to be ready for supporting the low-level FUSE API:

It introduces the following new files.

- /usr/include/fuse/fuse_common.h
- /usr/include/fuse/fuse_lowlevel.h
- /usr/src/lib/libfuse/fuse_chan.c

Additionally, it relocates all libfuse header files to the
/usr/include/fuse directory so that it now contains.

- /usr/include/fuse/fuse.h
- /usr/include/fuse/fuse_opt.h
- /usr/include/fuse/fuse_common.h
- /usr/include/fuse/fuse_lowlevel.h

Relevant definitions have been moved into their appropriate
files, and I took the opportunity for some minor cleanup. The
pkg-config metadata has also been updated to reflect the new header
locations.

ok claudio@ sthen@

helg 08e623eb f3229d3e

+231 -95
+8 -5
lib/libfuse/Makefile
··· 1 - # $OpenBSD: Makefile,v 1.17 2018/11/28 21:19:11 mpi Exp $ 1 + # $OpenBSD: Makefile,v 1.18 2025/12/08 06:37:04 helg Exp $ 2 2 3 3 LIB= fuse 4 4 MAN= fuse_chan_fd.3 fuse_daemonize.3 fuse_destroy.3 fuse_get_context.3 \ ··· 17 17 # XXX Shouldn't we use a common fuse.h with proper ifdef _KERNEL part? 18 18 CFLAGS+= -I${.CURDIR} 19 19 20 - SRCS= debug.c dict.c fuse.c fuse_ops.c fuse_opt.c fuse_subr.c tree.c 21 - HDRS= fuse.h fuse_opt.h 20 + SRCS= debug.c dict.c fuse.c fuse_ops.c fuse_opt.c fuse_subr.c tree.c \ 21 + fuse_chan.c 22 + HDRS= fuse.h fuse_opt.h fuse_common.h fuse_lowlevel.h 22 23 23 24 VERSION_SCRIPT= ${.CURDIR}/Symbols.map 24 25 ··· 26 27 CLEANFILES+=${PC_FILES} 27 28 28 29 includes: 30 + ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \ 31 + ${DESTDIR}/usr/include/fuse 29 32 @cd ${.CURDIR}; for i in ${HDRS}; do \ 30 - j="cmp -s $$i ${DESTDIR}/usr/include/$$i || \ 33 + j="cmp -s $$i ${DESTDIR}/usr/include/fuse/$$i || \ 31 34 ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \ 32 - $$i ${DESTDIR}/usr/include"; \ 35 + $$i ${DESTDIR}/usr/include/fuse"; \ 33 36 echo $$j; \ 34 37 eval "$$j"; \ 35 38 done
+8 -11
lib/libfuse/fuse.c
··· 1 - /* $OpenBSD: fuse.c,v 1.56 2025/11/19 08:19:18 helg Exp $ */ 1 + /* $OpenBSD: fuse.c,v 1.57 2025/12/08 06:37:04 helg Exp $ */ 2 2 /* 3 3 * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> 4 4 * ··· 24 24 #include <string.h> 25 25 #include <unistd.h> 26 26 27 - #include "fuse_opt.h" 28 27 #include "fuse_private.h" 29 28 #include "debug.h" 30 29 ··· 297 296 { 298 297 return (fuse_opt_match(fuse_lib_opts, opt)); 299 298 } 300 - 301 - int 302 - fuse_chan_fd(struct fuse_chan *ch) 303 - { 304 - if (ch == NULL) 305 - return (-1); 306 - 307 - return (ch->fd); 308 - } 299 + DEF(fuse_is_lib_option); 309 300 310 301 struct fuse_session * 311 302 fuse_get_session(struct fuse *f) ··· 319 310 { 320 311 return (-1); 321 312 } 313 + DEF(fuse_loop_mt); 322 314 323 315 static int 324 316 ifuse_lib_opt_proc(void *data, const char *arg, int key, ··· 479 471 480 472 return (0); 481 473 } 474 + DEF(fuse_set_signal_handlers); 482 475 483 476 static void 484 477 dump_help(void) ··· 592 585 { 593 586 return (FUSE_VERSION); 594 587 } 588 + DEF(fuse_version); 595 589 596 590 void 597 591 fuse_teardown(struct fuse *fuse, char *mp) ··· 603 597 fuse_unmount(mp, fuse->fc); 604 598 fuse_destroy(fuse); 605 599 } 600 + DEF(fuse_teardown); 606 601 607 602 int 608 603 fuse_invalidate(unused struct fuse *f, unused const char *path) 609 604 { 610 605 return (EINVAL); 611 606 } 607 + DEF(fuse_invalidate); 612 608 613 609 struct fuse * 614 610 fuse_setup(int argc, char **argv, const struct fuse_operations *ops, ··· 675 671 676 672 return (ret == -1 ? 1 : 0); 677 673 } 674 + DEF(fuse_main);
+14 -73
lib/libfuse/fuse.h
··· 1 - /* $OpenBSD: fuse.h,v 1.14 2018/05/16 13:09:17 helg Exp $ */ 1 + /* $OpenBSD: fuse.h,v 1.15 2025/12/08 06:37:04 helg Exp $ */ 2 2 /* 3 3 * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> 4 4 * ··· 18 18 #ifndef _FUSE_H_ 19 19 #define _FUSE_H_ 20 20 21 - #include <sys/types.h> 21 + #ifndef FUSE_USE_VERSION 22 + #define FUSE_USE_VERSION 26 23 + #endif 24 + 22 25 #include <sys/stat.h> 23 26 #include <sys/statvfs.h> 24 27 25 28 #include <fcntl.h> 26 29 #include <utime.h> 27 30 28 - #include <fuse_opt.h> 31 + #include "fuse_common.h" 29 32 30 33 #ifdef __cplusplus 31 34 extern "C" { 32 35 #endif 33 36 34 - struct fuse_chan; 35 - struct fuse_args; 36 - struct fuse_session; 37 - 38 - struct fuse_file_info { 39 - int32_t flags; /* open(2) flags */ 40 - uint32_t fh_old; /* old file handle */ 41 - int32_t writepage; 42 - uint32_t direct_io:1; 43 - uint32_t keep_cache:1; 44 - uint32_t flush:1; 45 - uint32_t nonseekable:1; 46 - uint32_t __padd:27; 47 - uint32_t flock_release : 1; 48 - uint64_t fh; /* file handle */ 49 - uint64_t lock_owner; 50 - }; 51 - 52 - /* unused but needed for gvfs compilation */ 53 - #define FUSE_CAP_ASYNC_READ (1 << 0) 54 - #define FUSE_CAP_POSIX_LOCKS (1 << 1) 55 - #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3) 56 - #define FUSE_CAP_EXPORT_SUPPORT (1 << 4) 57 - #define FUSE_CAP_BIG_WRITES (1 << 5) 58 - #define FUSE_CAP_DONT_MASK (1 << 6) 59 - #define FUSE_CAP_SPLICE_WRITE (1 << 7) 60 - #define FUSE_CAP_SPLICE_MOVE (1 << 8) 61 - #define FUSE_CAP_SPLICE_READ (1 << 9) 62 - #define FUSE_CAP_FLOCK_LOCKS (1 << 10) 63 - #define FUSE_CAP_IOCTL_DIR (1 << 11) 64 - 65 - struct fuse_conn_info { 66 - uint32_t proto_major; 67 - uint32_t proto_minor; 68 - uint32_t async_read; 69 - uint32_t max_write; 70 - uint32_t max_readahead; 71 - uint32_t capable; 72 - uint32_t want; 73 - uint32_t max_background; 74 - uint32_t congestion_threshold; 75 - uint32_t reserved[23]; 76 - }; 77 - 78 37 struct fuse_context { 79 38 struct fuse * fuse; 80 39 uid_t uid; ··· 84 43 mode_t umask; 85 44 }; 86 45 87 - typedef ino_t fuse_ino_t; 88 46 typedef int (*fuse_fill_dir_t)(void *, const char *, const struct stat *, 89 47 off_t); 90 48 91 49 typedef struct fuse_dirhandle *fuse_dirh_t; 92 50 typedef int (*fuse_dirfil_t)(fuse_dirh_t, const char *, int, ino_t); 93 51 94 - /* 52 + /* 95 53 * Fuse operations work in the same way as their UNIX file system 96 54 * counterparts. A major exception is that these routines return 97 55 * a negated errno value (-errno) on failure. ··· 135 93 int (*access)(const char *, int); 136 94 int (*create)(const char *, mode_t, struct fuse_file_info *); 137 95 int (*ftruncate)(const char *, off_t, struct fuse_file_info *); 138 - int (*fgetattr)(const char *, struct stat *, struct fuse_file_info *); 139 - int (*lock)(const char *, struct fuse_file_info *, int, struct flock *); 96 + int (*fgetattr)(const char *, struct stat *, 97 + struct fuse_file_info *); 98 + int (*lock)(const char *, struct fuse_file_info *, int, 99 + struct flock *); 140 100 int (*utimens)(const char *, const struct timespec *); 141 101 int (*bmap)(const char *, size_t , uint64_t *); 142 102 }; 143 103 144 - #ifndef FUSE_USE_VERSION 145 - #define FUSE_USE_VERSION 26 146 - #endif 147 - 148 - #if FUSE_USE_VERSION >= 26 149 - #define FUSE_VERSION 26 150 - #else 151 - #error "Fuse version < 26 not supported" 152 - #endif 153 - 154 - #define FUSE_MAJOR_VERSION 2 155 - #define FUSE_MINOR_VERSION 6 156 - 157 104 /* 158 105 * API prototypes 159 106 */ 160 - int fuse_version(void); 161 107 int fuse_main(int, char **, const struct fuse_operations *, void *); 162 108 struct fuse *fuse_new(struct fuse_chan *, struct fuse_args *, 163 109 const struct fuse_operations *, size_t, void *); 164 110 struct fuse *fuse_setup(int, char **, const struct fuse_operations *, 165 111 size_t, char **, int *, void *); 166 - int fuse_parse_cmdline(struct fuse_args *, char **, int *, int *); 167 - struct fuse_chan *fuse_mount(const char *, struct fuse_args *); 168 - void fuse_remove_signal_handlers(struct fuse_session *); 169 - int fuse_set_signal_handlers(struct fuse_session *); 170 112 struct fuse_session *fuse_get_session(struct fuse *); 171 113 struct fuse_context *fuse_get_context(void); 172 - int fuse_is_lib_option(const char *); 173 114 int fuse_loop(struct fuse *); 174 115 int fuse_loop_mt(struct fuse *); 175 - int fuse_chan_fd(struct fuse_chan *); 176 - void fuse_unmount(const char *, struct fuse_chan *); 177 - int fuse_daemonize(int); 178 116 void fuse_destroy(struct fuse *); 179 117 void fuse_teardown(struct fuse *, char *); 118 + 119 + /* Obsolete */ 120 + int fuse_is_lib_option(const char *); 180 121 int fuse_invalidate(struct fuse *, const char *); 181 122 182 123 #ifdef __cplusplus
+30
lib/libfuse/fuse_chan.c
··· 1 + /* $OpenBSD: fuse_chan.c,v 1.1 2025/12/08 06:37:04 helg Exp $ */ 2 + /* 3 + * Copyright (c) 2025 Helg Bredow <helg@openbsd.org> 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 + #include <string.h> 19 + 20 + #include "fuse_private.h" 21 + 22 + int 23 + fuse_chan_fd(struct fuse_chan *ch) 24 + { 25 + if (ch == NULL) 26 + return (-1); 27 + 28 + return (ch->fd); 29 + } 30 + DEF(fuse_chan_fd);
+107
lib/libfuse/fuse_common.h
··· 1 + /* $OpenBSD: fuse_common.h,v 1.1 2025/12/08 06:37:04 helg Exp $ */ 2 + /* 3 + * Copyright (c) 2025 Helg Bredow <helg@openbsd.org> 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 + /* 19 + * This file contains definitions common to both the low and high-level FUSE 20 + * APIs. 21 + */ 22 + 23 + #if !defined(_FUSE_H_) && !defined(_FUSE_LOWLEVEL_H_) 24 + #error "Never include <fuse_common.h> directly; use <fuse.h> or <fuse_lowlevel.h> instead." 25 + #endif 26 + 27 + #ifndef _FUSE_COMMON_H_ 28 + #define _FUSE_COMMON_H_ 29 + 30 + #if FUSE_USE_VERSION >= 26 31 + #define FUSE_VERSION 26 32 + #else 33 + #error "Fuse version < 26 not supported" 34 + #endif 35 + 36 + #include <sys/types.h> 37 + #include <stdint.h> 38 + 39 + #include "fuse_opt.h" 40 + 41 + #define FUSE_MAJOR_VERSION 2 42 + #define FUSE_MINOR_VERSION 6 43 + 44 + #ifdef __cplusplus 45 + extern "C" { 46 + #endif 47 + 48 + struct fuse_file_info { 49 + int32_t flags; /* open(2) flags */ 50 + uint32_t fh_old; /* old file handle */ 51 + int32_t writepage; 52 + uint32_t direct_io : 1; 53 + uint32_t keep_cache : 1; 54 + uint32_t flush : 1; 55 + uint32_t nonseekable : 1; 56 + uint32_t __padd : 27; 57 + uint32_t flock_release : 1; 58 + uint64_t fh; /* file handle */ 59 + uint64_t lock_owner; 60 + }; 61 + 62 + /* unused but needed for gvfs compilation */ 63 + #define FUSE_CAP_ASYNC_READ (1 << 0) 64 + #define FUSE_CAP_POSIX_LOCKS (1 << 1) 65 + #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3) 66 + #define FUSE_CAP_EXPORT_SUPPORT (1 << 4) 67 + #define FUSE_CAP_BIG_WRITES (1 << 5) 68 + #define FUSE_CAP_DONT_MASK (1 << 6) 69 + #define FUSE_CAP_SPLICE_WRITE (1 << 7) 70 + #define FUSE_CAP_SPLICE_MOVE (1 << 8) 71 + #define FUSE_CAP_SPLICE_READ (1 << 9) 72 + #define FUSE_CAP_FLOCK_LOCKS (1 << 10) 73 + #define FUSE_CAP_IOCTL_DIR (1 << 11) 74 + 75 + struct fuse_conn_info { 76 + uint32_t proto_major; 77 + uint32_t proto_minor; 78 + uint32_t async_read; 79 + uint32_t max_write; 80 + uint32_t max_readahead; 81 + uint32_t capable; 82 + uint32_t want; 83 + uint32_t max_background; 84 + uint32_t congestion_threshold; 85 + uint32_t reserved[23]; 86 + }; 87 + 88 + struct fuse_chan; 89 + struct fuse_args; 90 + struct fuse_session; 91 + 92 + /* 93 + * API prototypes 94 + */ 95 + int fuse_version(void); 96 + int fuse_parse_cmdline(struct fuse_args *, char **, int *, int *); 97 + int fuse_daemonize(int); 98 + int fuse_set_signal_handlers(struct fuse_session *); 99 + void fuse_unmount(const char *, struct fuse_chan *); 100 + void fuse_remove_signal_handlers(struct fuse_session *); 101 + struct fuse_chan *fuse_mount(const char *, struct fuse_args *); 102 + 103 + #ifdef __cplusplus 104 + } 105 + #endif 106 + 107 + #endif /* _FUSE_COMMON_H_ */
+44
lib/libfuse/fuse_lowlevel.h
··· 1 + /* $OpenBSD: fuse_lowlevel.h,v 1.1 2025/12/08 06:37:04 helg Exp $ */ 2 + /* 3 + * Copyright (c) 2025 Helg Bredow <helg@openbsd.org> 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 _FUSE_LOWLEVEL_H_ 19 + #define _FUSE_LOWLEVEL_H_ 20 + 21 + #ifndef FUSE_USE_VERSION 22 + #define FUSE_USE_VERSION 26 23 + #endif 24 + 25 + #include <sys/stat.h> 26 + 27 + #include "fuse_common.h" 28 + 29 + #ifdef __cplusplus 30 + extern "C" { 31 + #endif 32 + 33 + typedef ino_t fuse_ino_t; 34 + 35 + /* 36 + * FUSE Channel API Prototypes 37 + */ 38 + int fuse_chan_fd(struct fuse_chan *); 39 + 40 + #ifdef __cplusplus 41 + } 42 + #endif 43 + 44 + #endif /* _FUSE_LOWLEVEL_H_ */
+3 -1
lib/libfuse/fuse_opt.c
··· 1 - /* $OpenBSD: fuse_opt.c,v 1.27 2022/01/16 20:06:18 naddy Exp $ */ 1 + /* $OpenBSD: fuse_opt.c,v 1.28 2025/12/08 06:37:05 helg Exp $ */ 2 2 /* 3 3 * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> 4 4 * Copyright (c) 2013 Stefan Sperling <stsp@openbsd.org> ··· 126 126 ret = add_opt(opts, opt); 127 127 return (ret); 128 128 } 129 + DEF(fuse_opt_add_opt); 129 130 130 131 int 131 132 fuse_opt_add_opt_escaped(char **opts, const char *opt) ··· 177 178 free(escaped_opt); 178 179 return (ret); 179 180 } 181 + DEF(fuse_opt_add_opt_escaped); 180 182 181 183 int 182 184 fuse_opt_add_arg(struct fuse_args *args, const char *name)
+15 -3
lib/libfuse/fuse_private.h
··· 1 - /* $OpenBSD: fuse_private.h,v 1.25 2025/11/19 08:19:18 helg Exp $ */ 1 + /* $OpenBSD: fuse_private.h,v 1.26 2025/12/08 06:37:05 helg Exp $ */ 2 2 /* 3 3 * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> 4 4 * ··· 18 18 #ifndef _FUSE_SUBR_H_ 19 19 #define _FUSE_SUBR_H_ 20 20 21 + #include <sys/types.h> 21 22 #include <sys/dirent.h> 22 23 #include <sys/mount.h> 23 24 #include <sys/stat.h> ··· 27 28 #include <limits.h> 28 29 29 30 #include "fuse.h" 30 - 31 - struct fuse_args; 31 + #include "fuse_lowlevel.h" 32 32 33 33 struct fuse_vnode { 34 34 ino_t ino; ··· 147 147 #define DEF(x) __strong_alias(x, __##x) 148 148 149 149 PROTO(fuse_daemonize); 150 + PROTO(fuse_teardown); 150 151 PROTO(fuse_destroy); 151 152 PROTO(fuse_get_context); 152 153 PROTO(fuse_get_session); 153 154 PROTO(fuse_loop); 155 + PROTO(fuse_loop_mt); 154 156 PROTO(fuse_mount); 155 157 PROTO(fuse_new); 156 158 PROTO(fuse_opt_add_arg); 159 + PROTO(fuse_opt_add_opt); 160 + PROTO(fuse_opt_add_opt_escaped); 157 161 PROTO(fuse_opt_free_args); 158 162 PROTO(fuse_opt_insert_arg); 159 163 PROTO(fuse_opt_match); 160 164 PROTO(fuse_opt_parse); 161 165 PROTO(fuse_parse_cmdline); 162 166 PROTO(fuse_remove_signal_handlers); 167 + PROTO(fuse_set_signal_handlers); 163 168 PROTO(fuse_setup); 164 169 PROTO(fuse_unmount); 170 + PROTO(fuse_main); 171 + PROTO(fuse_version); 172 + PROTO(fuse_invalidate); 173 + PROTO(fuse_is_lib_option); 174 + 175 + /* FUSE low-level */ 176 + PROTO(fuse_chan_fd); 165 177 166 178 #endif /* _FUSE_SUBR_ */
+2 -2
lib/libfuse/generate_pkgconfig.sh
··· 1 1 #!/bin/sh 2 2 # 3 - # $OpenBSD: generate_pkgconfig.sh,v 1.2 2013/06/15 11:40:56 jasper Exp $ 3 + # $OpenBSD: generate_pkgconfig.sh,v 1.3 2025/12/08 06:37:05 helg Exp $ 4 4 # 5 5 # Copyright (c) 2010,2011 Jasper Lievisse Adriaanse <jasper@openbsd.org> 6 6 # ··· 59 59 prefix=/usr 60 60 exec_prefix=\${prefix} 61 61 libdir=\${exec_prefix}/lib 62 - includedir=\${prefix}/include 62 + includedir=\${prefix}/include/fuse 63 63 64 64 Name: fuse 65 65 Description: fuse filesystem library