VirtualBox

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

Last change on this file since 76767 was 76745, checked in by vboxsync, 6 years ago

vboxsf/linux: Indent #ifdefs and comment the according to our guidelines, no need to make this harder to untangle than it already is.

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