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