1 | /* $Id: vfsmod.h 77138 2019-02-01 19:00:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * vboxsf - Linux Shared Folders VFS, internal header.
|
---|
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_vfsmod_h
|
---|
32 | #define GA_INCLUDED_SRC_linux_sharedfolders_vfsmod_h
|
---|
33 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
34 | # pragma once
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | /* VBOXSF_USE_DEPRECATED_VBGL_INTERFACE is also settable in make env. */
|
---|
38 | /*#define VBOXSF_USE_DEPRECATED_VBGL_INTERFACE*/
|
---|
39 |
|
---|
40 | #define LOG_GROUP LOG_GROUP_SHARED_FOLDERS
|
---|
41 | #include "the-linux-kernel.h"
|
---|
42 | #include <VBox/log.h>
|
---|
43 |
|
---|
44 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
---|
45 | # include <linux/backing-dev.h>
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #include <VBox/VBoxGuestLibSharedFolders.h>
|
---|
49 | #include <VBox/VBoxGuestLibSharedFoldersInline.h>
|
---|
50 | #include "vbsfmount.h"
|
---|
51 |
|
---|
52 | #define DIR_BUFFER_SIZE (16*_1K)
|
---|
53 |
|
---|
54 | /* per-shared folder information */
|
---|
55 | struct sf_glob_info {
|
---|
56 | VBGLSFMAP map;
|
---|
57 | struct nls_table *nls;
|
---|
58 | int ttl;
|
---|
59 | int uid;
|
---|
60 | int gid;
|
---|
61 | int dmode;
|
---|
62 | int fmode;
|
---|
63 | int dmask;
|
---|
64 | int fmask;
|
---|
65 | /** Maximum number of pages to allow in an I/O buffer with the host.
|
---|
66 | * This applies to read and write operations. */
|
---|
67 | uint32_t cMaxIoPages;
|
---|
68 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
---|
69 | struct backing_dev_info bdi;
|
---|
70 | #endif
|
---|
71 | char tag[32]; /**< Mount tag for VBoxService automounter. @since 6.0 */
|
---|
72 | };
|
---|
73 |
|
---|
74 | /* per-inode information */
|
---|
75 | struct sf_inode_info {
|
---|
76 | /* which file */
|
---|
77 | SHFLSTRING *path;
|
---|
78 | /* some information was changed, update data on next revalidate */
|
---|
79 | int force_restat;
|
---|
80 | /* directory content changed, update the whole directory on next sf_getdent */
|
---|
81 | int force_reread;
|
---|
82 | /* file structure, only valid between open() and release() */
|
---|
83 | struct file *file;
|
---|
84 | /* handle valid if a file was created with sf_create_aux until it will
|
---|
85 | * be opened with sf_reg_open() */
|
---|
86 | SHFLHANDLE handle;
|
---|
87 | };
|
---|
88 |
|
---|
89 | struct sf_dir_info {
|
---|
90 | struct list_head info_list;
|
---|
91 | };
|
---|
92 |
|
---|
93 | struct sf_dir_buf {
|
---|
94 | size_t cEntries;
|
---|
95 | size_t cbFree;
|
---|
96 | size_t cbUsed;
|
---|
97 | void *buf;
|
---|
98 | struct list_head head;
|
---|
99 | };
|
---|
100 |
|
---|
101 | struct sf_reg_info {
|
---|
102 | SHFLHANDLE handle;
|
---|
103 | };
|
---|
104 |
|
---|
105 | /* globals */
|
---|
106 | extern VBGLSFCLIENT client_handle;
|
---|
107 |
|
---|
108 | /* forward declarations */
|
---|
109 | extern struct inode_operations sf_dir_iops;
|
---|
110 | extern struct inode_operations sf_lnk_iops;
|
---|
111 | extern struct inode_operations sf_reg_iops;
|
---|
112 | extern struct file_operations sf_dir_fops;
|
---|
113 | extern struct file_operations sf_reg_fops;
|
---|
114 | extern struct dentry_operations sf_dentry_ops;
|
---|
115 | extern struct address_space_operations sf_reg_aops;
|
---|
116 |
|
---|
117 | extern void sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode,
|
---|
118 | PSHFLFSOBJINFO info);
|
---|
119 | extern int sf_stat(const char *caller, struct sf_glob_info *sf_g,
|
---|
120 | SHFLSTRING * path, PSHFLFSOBJINFO result, int ok_to_fail);
|
---|
121 | extern int sf_inode_revalidate(struct dentry *dentry);
|
---|
122 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
---|
123 | # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
---|
124 | extern int sf_getattr(const struct path *path, struct kstat *kstat,
|
---|
125 | u32 request_mask, unsigned int query_flags);
|
---|
126 | # else
|
---|
127 | extern int sf_getattr(struct vfsmount *mnt, struct dentry *dentry,
|
---|
128 | struct kstat *kstat);
|
---|
129 | # endif
|
---|
130 | extern int sf_setattr(struct dentry *dentry, struct iattr *iattr);
|
---|
131 | #endif
|
---|
132 | extern int sf_path_from_dentry(const char *caller, struct sf_glob_info *sf_g,
|
---|
133 | struct sf_inode_info *sf_i,
|
---|
134 | struct dentry *dentry, SHFLSTRING ** result);
|
---|
135 | extern int sf_nlscpy(struct sf_glob_info *sf_g, char *name,
|
---|
136 | size_t name_bound_len, const unsigned char *utf8_name,
|
---|
137 | size_t utf8_len);
|
---|
138 | extern void sf_dir_info_free(struct sf_dir_info *p);
|
---|
139 | extern void sf_dir_info_empty(struct sf_dir_info *p);
|
---|
140 | extern struct sf_dir_info *sf_dir_info_alloc(void);
|
---|
141 | extern int sf_dir_read_all(struct sf_glob_info *sf_g,
|
---|
142 | struct sf_inode_info *sf_i, struct sf_dir_info *sf_d,
|
---|
143 | SHFLHANDLE handle);
|
---|
144 | extern int sf_init_backing_dev(struct sf_glob_info *sf_g);
|
---|
145 | extern void sf_done_backing_dev(struct sf_glob_info *sf_g);
|
---|
146 |
|
---|
147 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
---|
148 | # define STRUCT_STATFS struct statfs
|
---|
149 | #else
|
---|
150 | # define STRUCT_STATFS struct kstatfs
|
---|
151 | #endif
|
---|
152 | int sf_get_volume_info(struct super_block *sb, STRUCT_STATFS * stat);
|
---|
153 |
|
---|
154 | #ifdef __cplusplus
|
---|
155 | # define CMC_API __attribute__ ((cdecl, regparm (0)))
|
---|
156 | #else
|
---|
157 | # define CMC_API __attribute__ ((regparm (0)))
|
---|
158 | #endif
|
---|
159 |
|
---|
160 | #define TRACE() LogFunc(("tracepoint\n"))
|
---|
161 |
|
---|
162 | /* Following casts are here to prevent assignment of void * to
|
---|
163 | pointers of arbitrary type */
|
---|
164 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
---|
165 | # define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->u.generic_sbp)
|
---|
166 | # define SET_GLOB_INFO(sb, sf_g) (sb)->u.generic_sbp = sf_g
|
---|
167 | #else
|
---|
168 | # define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->s_fs_info)
|
---|
169 | # define SET_GLOB_INFO(sb, sf_g) (sb)->s_fs_info = sf_g
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) || defined(KERNEL_FC6)
|
---|
173 | /* FC6 kernel 2.6.18, vanilla kernel 2.6.19+ */
|
---|
174 | # define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->i_private)
|
---|
175 | # define SET_INODE_INFO(i, sf_i) (i)->i_private = sf_i
|
---|
176 | #else
|
---|
177 | /* vanilla kernel up to 2.6.18 */
|
---|
178 | # define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->u.generic_ip)
|
---|
179 | # define SET_INODE_INFO(i, sf_i) (i)->u.generic_ip = sf_i
|
---|
180 | #endif
|
---|
181 |
|
---|
182 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
|
---|
183 | # define GET_F_DENTRY(f) (f->f_path.dentry)
|
---|
184 | #else
|
---|
185 | # define GET_F_DENTRY(f) (f->f_dentry)
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | #endif /* !GA_INCLUDED_SRC_linux_sharedfolders_vfsmod_h */
|
---|