VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h@ 72627

Last change on this file since 72627 was 72627, checked in by vboxsync, 7 years ago

Additions: relicence components needed for Linux shared folders to MIT.
bugref:9109: Shared folders: update to match in-kernel code more closely
This change makes the code on which the Linux kernel shared folder patch is
based MIT-licenced, so that the version in the Linux kernel can be too. This
would make it easier to move code back and forth.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/** @file
2 * vboxsf - VirtualBox Guest Additions for Linux.
3 */
4
5/*
6 * Copyright (C) 2006-2018 Oracle Corporation
7 *
8 * Permission is hereby granted, free of charge, to any person
9 * obtaining a copy of this software and associated documentation
10 * files (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use,
12 * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following
15 * conditions:
16 *
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30#ifndef VFSMOD_H
31#define VFSMOD_H
32
33#define LOG_GROUP LOG_GROUP_SHARED_FOLDERS
34#include "the-linux-kernel.h"
35#include <VBox/log.h>
36
37#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
38#include <linux/backing-dev.h>
39#endif
40
41#include <VBox/VBoxGuestLibSharedFolders.h>
42#include "vbsfmount.h"
43
44#define DIR_BUFFER_SIZE (16*_1K)
45
46/* per-shared folder information */
47struct sf_glob_info {
48 VBGLSFMAP map;
49 struct nls_table *nls;
50 int ttl;
51 int uid;
52 int gid;
53 int dmode;
54 int fmode;
55 int dmask;
56 int fmask;
57#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
58 struct backing_dev_info bdi;
59#endif
60};
61
62/* per-inode information */
63struct sf_inode_info {
64 /* which file */
65 SHFLSTRING *path;
66 /* some information was changed, update data on next revalidate */
67 int force_restat;
68 /* directory content changed, update the whole directory on next sf_getdent */
69 int force_reread;
70 /* file structure, only valid between open() and release() */
71 struct file *file;
72 /* handle valid if a file was created with sf_create_aux until it will
73 * be opened with sf_reg_open() */
74 SHFLHANDLE handle;
75};
76
77struct sf_dir_info {
78 struct list_head info_list;
79};
80
81struct sf_dir_buf {
82 size_t cEntries;
83 size_t cbFree;
84 size_t cbUsed;
85 void *buf;
86 struct list_head head;
87};
88
89struct sf_reg_info {
90 SHFLHANDLE handle;
91};
92
93/* globals */
94extern VBGLSFCLIENT client_handle;
95
96/* forward declarations */
97extern struct inode_operations sf_dir_iops;
98extern struct inode_operations sf_lnk_iops;
99extern struct inode_operations sf_reg_iops;
100extern struct file_operations sf_dir_fops;
101extern struct file_operations sf_reg_fops;
102extern struct dentry_operations sf_dentry_ops;
103extern struct address_space_operations sf_reg_aops;
104
105extern void sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode,
106 PSHFLFSOBJINFO info);
107extern int sf_stat(const char *caller, struct sf_glob_info *sf_g,
108 SHFLSTRING * path, PSHFLFSOBJINFO result, int ok_to_fail);
109extern int sf_inode_revalidate(struct dentry *dentry);
110#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
111#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
112extern int sf_getattr(const struct path *path, struct kstat *kstat,
113 u32 request_mask, unsigned int query_flags);
114#else
115extern int sf_getattr(struct vfsmount *mnt, struct dentry *dentry,
116 struct kstat *kstat);
117#endif
118extern int sf_setattr(struct dentry *dentry, struct iattr *iattr);
119#endif
120extern int sf_path_from_dentry(const char *caller, struct sf_glob_info *sf_g,
121 struct sf_inode_info *sf_i,
122 struct dentry *dentry, SHFLSTRING ** result);
123extern int sf_nlscpy(struct sf_glob_info *sf_g, char *name,
124 size_t name_bound_len, const unsigned char *utf8_name,
125 size_t utf8_len);
126extern void sf_dir_info_free(struct sf_dir_info *p);
127extern void sf_dir_info_empty(struct sf_dir_info *p);
128extern struct sf_dir_info *sf_dir_info_alloc(void);
129extern int sf_dir_read_all(struct sf_glob_info *sf_g,
130 struct sf_inode_info *sf_i, struct sf_dir_info *sf_d,
131 SHFLHANDLE handle);
132extern int sf_init_backing_dev(struct sf_glob_info *sf_g);
133extern void sf_done_backing_dev(struct sf_glob_info *sf_g);
134
135#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
136#define STRUCT_STATFS struct statfs
137#else
138#define STRUCT_STATFS struct kstatfs
139#endif
140int sf_get_volume_info(struct super_block *sb, STRUCT_STATFS * stat);
141
142#ifdef __cplusplus
143#define CMC_API __attribute__ ((cdecl, regparm (0)))
144#else
145#define CMC_API __attribute__ ((regparm (0)))
146#endif
147
148#define TRACE() LogFunc(("tracepoint\n"))
149
150/* Following casts are here to prevent assignment of void * to
151 pointers of arbitrary type */
152#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
153#define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->u.generic_sbp)
154#define SET_GLOB_INFO(sb, sf_g) (sb)->u.generic_sbp = sf_g
155#else
156#define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->s_fs_info)
157#define SET_GLOB_INFO(sb, sf_g) (sb)->s_fs_info = sf_g
158#endif
159
160#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) || defined(KERNEL_FC6)
161/* FC6 kernel 2.6.18, vanilla kernel 2.6.19+ */
162#define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->i_private)
163#define SET_INODE_INFO(i, sf_i) (i)->i_private = sf_i
164#else
165/* vanilla kernel up to 2.6.18 */
166#define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->u.generic_ip)
167#define SET_INODE_INFO(i, sf_i) (i)->u.generic_ip = sf_i
168#endif
169
170#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
171#define GET_F_DENTRY(f) (f->f_path.dentry)
172#else
173#define GET_F_DENTRY(f) (f->f_dentry)
174#endif
175
176#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette