1 | /* $Id: vbsfmount.h 77953 2019-03-29 17:07:16Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * vboxsf - VBox Linux Shared Folders VFS, mount(2) parameter structure.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person
|
---|
10 | * obtaining a copy of this software and associated documentation
|
---|
11 | * files (the "Software"), to deal in the Software without
|
---|
12 | * restriction, including without limitation the rights to use,
|
---|
13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
14 | * copies of the Software, and to permit persons to whom the
|
---|
15 | * Software is furnished to do so, subject to the following
|
---|
16 | * conditions:
|
---|
17 | *
|
---|
18 | * The above copyright notice and this permission notice shall be
|
---|
19 | * included in all copies or substantial portions of the Software.
|
---|
20 | *
|
---|
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef GA_INCLUDED_SRC_linux_sharedfolders_vbsfmount_h
|
---|
32 | #define GA_INCLUDED_SRC_linux_sharedfolders_vbsfmount_h
|
---|
33 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
34 | # pragma once
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | /* Linux constraints the size of data mount argument to PAGE_SIZE - 1. */
|
---|
38 | #define MAX_HOST_NAME 256
|
---|
39 | #define MAX_NLS_NAME 32
|
---|
40 | #define VBSF_DEFAULT_TTL_MS 200
|
---|
41 |
|
---|
42 | #define VBSF_MOUNT_SIGNATURE_BYTE_0 '\377'
|
---|
43 | #define VBSF_MOUNT_SIGNATURE_BYTE_1 '\376'
|
---|
44 | #define VBSF_MOUNT_SIGNATURE_BYTE_2 '\375'
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * VBox Linux Shared Folders VFS caching mode.
|
---|
48 | */
|
---|
49 | enum vbsf_cache_mode {
|
---|
50 | /** Use the kernel modules default caching mode (kVbsfCacheMode_Strict). */
|
---|
51 | kVbsfCacheMode_Default = 0,
|
---|
52 | /** No caching, go to the host for everything. This will have some minor
|
---|
53 | * coherency issues for memory mapping with unsynced dirty pages. */
|
---|
54 | kVbsfCacheMode_None,
|
---|
55 | /** No caching, except for files with writable memory mappings.
|
---|
56 | * (Note to future: if we do oplock like stuff, it goes in here.) */
|
---|
57 | kVbsfCacheMode_Strict,
|
---|
58 | /** Use page cache for reads.
|
---|
59 | * This improves guest performance for read intensive jobs, like compiling
|
---|
60 | * building. The flip side is that the guest may not see host modification in a
|
---|
61 | * timely manner and possibly update files with out-of-date cache information,
|
---|
62 | * as there exists no protocol for the host to notify the guest about file
|
---|
63 | * modifications. */
|
---|
64 | kVbsfCacheMode_Read,
|
---|
65 | /** Use page cache for both reads and writes as far as that's possible.
|
---|
66 | * This is good for guest performance, but the price is that the guest possibly
|
---|
67 | * ignoring host changes and the host not seeing guest changes in a timely
|
---|
68 | * manner. */
|
---|
69 | kVbsfCacheMode_ReadWrite,
|
---|
70 | /** End of valid values (exclusive). */
|
---|
71 | kVbsfCacheMode_End,
|
---|
72 | /** Make sure the enum is sizeof(int32_t). */
|
---|
73 | kVbsfCacheMode_32BitHack = 0x7fffffff
|
---|
74 | };
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * VBox Linux Shared Folders VFS mount options.
|
---|
78 | */
|
---|
79 | struct vbsf_mount_info_new {
|
---|
80 | /**
|
---|
81 | * The old version of the mount_info struct started with a
|
---|
82 | * char name[MAX_HOST_NAME] field, where name cannot be '\0'.
|
---|
83 | * So the new version of the mount_info struct starts with a
|
---|
84 | * nullchar field which is always 0 so that we can detect and
|
---|
85 | * reject the old structure being passed.
|
---|
86 | */
|
---|
87 | char nullchar;
|
---|
88 | /** Signature */
|
---|
89 | char signature[3];
|
---|
90 | /** Length of the whole structure */
|
---|
91 | int length;
|
---|
92 | /** Share name */
|
---|
93 | char name[MAX_HOST_NAME];
|
---|
94 | /** Name of an I/O charset */
|
---|
95 | char nls_name[MAX_NLS_NAME];
|
---|
96 | /** User ID for all entries, default 0=root */
|
---|
97 | int uid;
|
---|
98 | /** Group ID for all entries, default 0=root */
|
---|
99 | int gid;
|
---|
100 | /** Directory entry and inode time to live in milliseconds.
|
---|
101 | * -1 for kernel default, 0 to disable caching.
|
---|
102 | * @sa vbsf_mount_info_new::msDirCacheTTL, vbsf_mount_info_new::msInodeTTL */
|
---|
103 | int ttl;
|
---|
104 | /** Mode for directories if != -1. */
|
---|
105 | int dmode;
|
---|
106 | /** Mode for regular files if != -1. */
|
---|
107 | int fmode;
|
---|
108 | /** umask applied to directories */
|
---|
109 | int dmask;
|
---|
110 | /** umask applied to regular files */
|
---|
111 | int fmask;
|
---|
112 | /** Mount tag for VBoxService automounter.
|
---|
113 | * @since 6.0.0 */
|
---|
114 | char szTag[32];
|
---|
115 | /** Max pages to read & write at a time.
|
---|
116 | * @since 6.0.6 */
|
---|
117 | uint32_t cMaxIoPages;
|
---|
118 | /** The directory content buffer size. Set to 0 for kernel module default.
|
---|
119 | * Larger value reduces the number of host calls on large directories. */
|
---|
120 | uint32_t cbDirBuf;
|
---|
121 | /** The time to live for directory entries (in milliseconds). @a ttl is used
|
---|
122 | * if negative.
|
---|
123 | * @since 6.0.6 */
|
---|
124 | int32_t msDirCacheTTL;
|
---|
125 | /** The time to live for inode information (in milliseconds). @a ttl is used
|
---|
126 | * if negative.
|
---|
127 | * @since 6.0.6 */
|
---|
128 | int32_t msInodeTTL;
|
---|
129 | /** The cache and coherency mode.
|
---|
130 | * @since 6.0.6 */
|
---|
131 | enum vbsf_cache_mode enmCacheMode;
|
---|
132 | };
|
---|
133 | #ifdef AssertCompileSize
|
---|
134 | AssertCompileSize(struct vbsf_mount_info_new, 2*4 + MAX_HOST_NAME + MAX_NLS_NAME + 7*4 + 32 + 5*4);
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * For use with the vbsfmount_complete() helper.
|
---|
139 | */
|
---|
140 | struct vbsf_mount_opts {
|
---|
141 | int ttl;
|
---|
142 | int32_t msDirCacheTTL;
|
---|
143 | int32_t msInodeTTL;
|
---|
144 | uint32_t cMaxIoPages;
|
---|
145 | uint32_t cbDirBuf;
|
---|
146 | enum vbsf_cache_mode enmCacheMode;
|
---|
147 | int uid;
|
---|
148 | int gid;
|
---|
149 | int dmode;
|
---|
150 | int fmode;
|
---|
151 | int dmask;
|
---|
152 | int fmask;
|
---|
153 | int ronly;
|
---|
154 | int sloppy;
|
---|
155 | int noexec;
|
---|
156 | int nodev;
|
---|
157 | int nosuid;
|
---|
158 | int remount;
|
---|
159 | char nls_name[MAX_NLS_NAME];
|
---|
160 | char *convertcp;
|
---|
161 | };
|
---|
162 |
|
---|
163 | /** Completes the mount operation by adding the new mount point to mtab if required. */
|
---|
164 | int vbsfmount_complete(const char *host_name, const char *mount_point,
|
---|
165 | unsigned long flags, struct vbsf_mount_opts *opts);
|
---|
166 |
|
---|
167 | #endif /* !GA_INCLUDED_SRC_linux_sharedfolders_vbsfmount_h */
|
---|