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
|
/* $Id: vfsmod.h $ */
/** @file
* vboxsf - Linux Shared Folders VFS, internal header.
*/
/*
* Copyright (C) 2006-2019 Oracle Corporation
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef GA_INCLUDED_SRC_linux_sharedfolders_vfsmod_h
#define GA_INCLUDED_SRC_linux_sharedfolders_vfsmod_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif
#define LOG_GROUP LOG_GROUP_SHARED_FOLDERS
#include "the-linux-kernel.h"
#include <VBox/log.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
# include <linux/backing-dev.h>
#endif
#include <VBox/VBoxGuestLibSharedFolders.h>
#include "vbsfmount.h"
#define DIR_BUFFER_SIZE (16*_1K)
/* per-shared folder information */
struct sf_glob_info {
VBGLSFMAP map;
struct nls_table *nls;
int ttl;
int uid;
int gid;
int dmode;
int fmode;
int dmask;
int fmask;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
struct backing_dev_info bdi;
#endif
char tag[32]; /**< Mount tag for VBoxService automounter. @since 6.0 */
};
/* per-inode information */
struct sf_inode_info {
/* which file */
SHFLSTRING *path;
/* some information was changed, update data on next revalidate */
int force_restat;
/* directory content changed, update the whole directory on next sf_getdent */
int force_reread;
/* file structure, only valid between open() and release() */
struct file *file;
/* handle valid if a file was created with sf_create_aux until it will
* be opened with sf_reg_open() */
SHFLHANDLE handle;
};
struct sf_dir_info {
struct list_head info_list;
};
struct sf_dir_buf {
size_t cEntries;
size_t cbFree;
size_t cbUsed;
void *buf;
struct list_head head;
};
struct sf_reg_info {
SHFLHANDLE handle;
};
/* globals */
extern VBGLSFCLIENT client_handle;
/* forward declarations */
extern struct inode_operations sf_dir_iops;
extern struct inode_operations sf_lnk_iops;
extern struct inode_operations sf_reg_iops;
extern struct file_operations sf_dir_fops;
extern struct file_operations sf_reg_fops;
extern struct dentry_operations sf_dentry_ops;
extern struct address_space_operations sf_reg_aops;
extern void sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode,
PSHFLFSOBJINFO info);
extern int sf_stat(const char *caller, struct sf_glob_info *sf_g,
SHFLSTRING * path, PSHFLFSOBJINFO result, int ok_to_fail);
extern int sf_inode_revalidate(struct dentry *dentry);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
extern int sf_getattr(const struct path *path, struct kstat *kstat,
u32 request_mask, unsigned int query_flags);
# else
extern int sf_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *kstat);
# endif
extern int sf_setattr(struct dentry *dentry, struct iattr *iattr);
#endif
extern int sf_path_from_dentry(const char *caller, struct sf_glob_info *sf_g,
struct sf_inode_info *sf_i,
struct dentry *dentry, SHFLSTRING ** result);
extern int sf_nlscpy(struct sf_glob_info *sf_g, char *name,
size_t name_bound_len, const unsigned char *utf8_name,
size_t utf8_len);
extern void sf_dir_info_free(struct sf_dir_info *p);
extern void sf_dir_info_empty(struct sf_dir_info *p);
extern struct sf_dir_info *sf_dir_info_alloc(void);
extern int sf_dir_read_all(struct sf_glob_info *sf_g,
struct sf_inode_info *sf_i, struct sf_dir_info *sf_d,
SHFLHANDLE handle);
extern int sf_init_backing_dev(struct sf_glob_info *sf_g);
extern void sf_done_backing_dev(struct sf_glob_info *sf_g);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
# define STRUCT_STATFS struct statfs
#else
# define STRUCT_STATFS struct kstatfs
#endif
int sf_get_volume_info(struct super_block *sb, STRUCT_STATFS * stat);
#ifdef __cplusplus
# define CMC_API __attribute__ ((cdecl, regparm (0)))
#else
# define CMC_API __attribute__ ((regparm (0)))
#endif
#define TRACE() LogFunc(("tracepoint\n"))
/* Following casts are here to prevent assignment of void * to
pointers of arbitrary type */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
# define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->u.generic_sbp)
# define SET_GLOB_INFO(sb, sf_g) (sb)->u.generic_sbp = sf_g
#else
# define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->s_fs_info)
# define SET_GLOB_INFO(sb, sf_g) (sb)->s_fs_info = sf_g
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) || defined(KERNEL_FC6)
/* FC6 kernel 2.6.18, vanilla kernel 2.6.19+ */
# define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->i_private)
# define SET_INODE_INFO(i, sf_i) (i)->i_private = sf_i
#else
/* vanilla kernel up to 2.6.18 */
# define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->u.generic_ip)
# define SET_INODE_INFO(i, sf_i) (i)->u.generic_ip = sf_i
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
# define GET_F_DENTRY(f) (f->f_path.dentry)
#else
# define GET_F_DENTRY(f) (f->f_dentry)
#endif
#endif /* !GA_INCLUDED_SRC_linux_sharedfolders_vfsmod_h */
|