jcs's openbsd hax
openbsd
1/* $OpenBSD: fuse.h,v 1.16 2026/01/29 06:04:27 helg Exp $ */
2/*
3 * Copyright (c) 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 _FUSE_H_
19#define _FUSE_H_
20
21#ifndef FUSE_USE_VERSION
22#define FUSE_USE_VERSION 26
23#endif
24
25#include <sys/stat.h>
26#include <sys/statvfs.h>
27
28#include <fcntl.h>
29#include <utime.h>
30
31#include "fuse_common.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37struct fuse_context {
38 struct fuse *fuse;
39 uid_t uid;
40 gid_t gid;
41 pid_t pid;
42 void *private_data;
43 mode_t umask;
44};
45
46typedef int (*fuse_fill_dir_t)(void *, const char *, const struct stat *,
47 off_t);
48
49typedef struct fuse_dirhandle *fuse_dirh_t;
50typedef int (*fuse_dirfil_t)(fuse_dirh_t, const char *, int, ino_t);
51
52/*
53 * Fuse operations work in the same way as their UNIX file system
54 * counterparts. A major exception is that these routines return
55 * a negated errno value (-errno) on failure.
56 */
57struct fuse_operations {
58 int (*getattr)(const char *, struct stat *);
59 int (*readlink)(const char *, char *, size_t);
60 int (*getdir)(const char *, fuse_dirh_t, fuse_dirfil_t);
61 int (*mknod)(const char *, mode_t, dev_t);
62 int (*mkdir)(const char *, mode_t);
63 int (*unlink)(const char *);
64 int (*rmdir)(const char *);
65 int (*symlink)(const char *, const char *);
66 int (*rename)(const char *, const char *);
67 int (*link)(const char *, const char *);
68 int (*chmod)(const char *, mode_t);
69 int (*chown)(const char *, uid_t, gid_t);
70 int (*truncate)(const char *, off_t);
71 int (*utime)(const char *, struct utimbuf *);
72 int (*open)(const char *, struct fuse_file_info *);
73 int (*read)(const char *, char *, size_t, off_t,
74 struct fuse_file_info *);
75 int (*write)(const char *, const char *, size_t, off_t,
76 struct fuse_file_info *);
77 int (*statfs)(const char *, struct statvfs *);
78 int (*flush)(const char *, struct fuse_file_info *);
79 int (*release)(const char *, struct fuse_file_info *);
80 int (*fsync)(const char *, int, struct fuse_file_info *);
81 int (*setxattr)(const char *, const char *, const char *, size_t,
82 int);
83 int (*getxattr)(const char *, const char *, char *, size_t);
84 int (*listxattr)(const char *, char *, size_t);
85 int (*removexattr)(const char *, const char *);
86 int (*opendir)(const char *, struct fuse_file_info *);
87 int (*readdir)(const char *, void *, fuse_fill_dir_t, off_t,
88 struct fuse_file_info *);
89 int (*releasedir)(const char *, struct fuse_file_info *);
90 int (*fsyncdir)(const char *, int, struct fuse_file_info *);
91 void *(*init)(struct fuse_conn_info *);
92 void (*destroy)(void *);
93 int (*access)(const char *, int);
94 int (*create)(const char *, mode_t, struct fuse_file_info *);
95 int (*ftruncate)(const char *, off_t, struct fuse_file_info *);
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 *);
100 int (*utimens)(const char *, const struct timespec *);
101 int (*bmap)(const char *, size_t , uint64_t *);
102};
103
104/*
105 * API prototypes
106 */
107int fuse_main(int, char **, const struct fuse_operations *, void *);
108struct fuse *fuse_new(struct fuse_chan *, struct fuse_args *,
109 const struct fuse_operations *, size_t, void *);
110struct fuse *fuse_setup(int, char **, const struct fuse_operations *,
111 size_t, char **, int *, void *);
112struct fuse_session *fuse_get_session(struct fuse *);
113struct fuse_context *fuse_get_context(void);
114int fuse_loop(struct fuse *);
115int fuse_loop_mt(struct fuse *);
116void fuse_destroy(struct fuse *);
117void fuse_teardown(struct fuse *, char *);
118
119/* Obsolete */
120int fuse_is_lib_option(const char *);
121int fuse_invalidate(struct fuse *, const char *);
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* _FUSE_H_ */