1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
/** @file
* Module to dynamically load libfuse/libosxfuse and load all symbols which are needed by
* vboximg-mount.
*/
/*
* Copyright (C) 2019-2023 Oracle and/or its affiliates.
*
* This file is part of VirtualBox base platform packages, as
* available from https://www.virtualbox.org.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, in version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses>.
*
* SPDX-License-Identifier: GPL-3.0-only
* --------------------------------------------------------------------
*
* This code is based on and contains parts of:
*
* libfuse
*
* FUSE: Filesystem in Userspace
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
*
* This program can be distributed under the terms of the GNU LGPLv2.
* See the file COPYING.LIB.
*/
#ifndef VBOX_INCLUDED_SRC_vboximg_mount_fuse_h
#define VBOX_INCLUDED_SRC_vboximg_mount_fuse_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif
#include <iprt/types.h>
#include <iprt/stdarg.h>
RT_C_DECLS_BEGIN
/* Forward declaration of stat buffer. */
struct stat;
/**
* Fuse option structure.
*/
typedef struct fuse_opt
{
/** Argument template with optional parameter formatting. */
const char *pszTempl;
/** Offset where the parameter is stored inside the data struct passed to fuse_opt_parse(). */
unsigned long uOffset;
/** The value to set the variable to if the template has no argument format. */
int uVal;
} fuse_opt;
#define FUSE_OPT_KEY(templ, key) { templ, -1U, key }
#define FUSE_OPT_END { NULL, 0, 0 }
#define FUSE_OPT_KEY_NONOPT -2
/**
* Fuse argument vector.
*/
typedef struct fuse_args
{
int argc;
char **argv;
int allocated;
} fuse_args;
#define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 }
/**
* Fuse file info structure - for us only the fh member is of interest for now.
*/
typedef struct fuse_file_info
{
int flags;
unsigned long fh_old;
int writepage;
unsigned int oth_flags;
uint64_t fh;
uint64_t lock_owner;
} fuse_file_info;
/** Option processing function. */
typedef int (*fuse_opt_proc_t)(void *data, const char *arg, int key, struct fuse_args *outargs);
/** Directory entry filler function. */
typedef int (*fuse_fill_dir_t) (void *buf, const char *name, const struct stat *stbuf, off_t off);
/**
* Fuse FS callback table implementing the filesystem functionality.
*
* Only required methods are filled out, others are stubbed (change as required).
*/
typedef struct fuse_operations
{
int (*getattr) (const char *pszPath, struct stat *pStatBuf);
int (*readlink) (const char *pszPath, char *pbBuf, size_t cbBuf);
PFNRT getdir;
PFNRT mknod;
PFNRT mkdir;
PFNRT unlink;
PFNRT rmdir;
PFNRT symlink;
PFNRT rename;
PFNRT link;
PFNRT chmod;
PFNRT chown;
PFNRT truncate;
PFNRT utime;
int (*open) (const char *pszPath, struct fuse_file_info *pInfo);
int (*read) (const char *pszPath, char *pbBuf, size_t cbBuf, off_t off, struct fuse_file_info *pInfo);
int (*write) (const char *pszPath, const char *pbBuf, size_t cbBuf, off_t off, struct fuse_file_info *pInfo);
PFNRT statfs;
PFNRT flush;
int (*release) (const char *pszPath, struct fuse_file_info *pInfo);
PFNRT fsync;
PFNRT setxattr; /* OSXFuse has a different parameter layout. */
PFNRT getxattr; /* OSXFuse has a different parameter layout. */
PFNRT listxattr;
PFNRT removexattr;
int (*opendir) (const char *pszPath, struct fuse_file_info *pInfo);
int (*readdir) (const char *pszPath, void *pvBuf, fuse_fill_dir_t pfnFiller, off_t offset, struct fuse_file_info *pInfo);
PFNRT releasedir;
PFNRT fsyncdir;
PFNRT init;
PFNRT destroy;
PFNRT access;
PFNRT create;
PFNRT ftruncate;
PFNRT fgettatr;
PFNRT lock;
PFNRT utimens;
PFNRT bmap;
unsigned int flag_null_path_ok: 1;
unsigned int flag_nopath: 1;
unsigned int flag_utime_omit_ok: 1;
unsigned int flag_reserved: 20;
PFNRT ioctl;
PFNRT poll;
PFNRT write_buf;
PFNRT read_buf;
PFNRT flock;
PFNRT fallocate;
#ifdef RT_OS_DARWIN
PFNRT rsvd00;
PFNRT rsvd01;
PFNRT rsvd02;
PFNRT statfs_x;
PFNRT setvolname;
PFNRT exchange;
PFNRT getxtimes;
PFNRT setbkuptime;
PFNRT setchgtime;
PFNRT setcrtime;
PFNRT chflags;
PFNRT setattr_x;
PFNRT fsetattr_x;
#endif
} fuse_operations;
/* Declarations of the functions that we need from libfuse */
#define VBOX_FUSE_GENERATE_HEADER
#include "fuse-calls.h"
#undef VBOX_FUSE_GENERATE_HEADER
RT_C_DECLS_END
#endif /* !VBOX_INCLUDED_SRC_vboximg_mount_fuse_h */
|