1 | /** @file
|
---|
2 | * vboxsf - VirtualBox Guest Additions for Linux.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2011 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef VFSMOD_H
|
---|
18 | #define VFSMOD_H
|
---|
19 |
|
---|
20 | #define LOG_GROUP LOG_GROUP_SHARED_FOLDERS
|
---|
21 | #include "the-linux-kernel.h"
|
---|
22 | #include "version-generated.h"
|
---|
23 | #include "product-generated.h"
|
---|
24 | #include <VBox/log.h>
|
---|
25 |
|
---|
26 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
---|
27 | # include <linux/backing-dev.h>
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | #include "VBoxGuestR0LibSharedFolders.h"
|
---|
31 | #include "vbsfmount.h"
|
---|
32 |
|
---|
33 | #define DIR_BUFFER_SIZE (16*_1K)
|
---|
34 |
|
---|
35 | /* per-shared folder information */
|
---|
36 | struct sf_glob_info
|
---|
37 | {
|
---|
38 | VBSFMAP map;
|
---|
39 | struct nls_table *nls;
|
---|
40 | int ttl;
|
---|
41 | int uid;
|
---|
42 | int gid;
|
---|
43 | int dmode;
|
---|
44 | int fmode;
|
---|
45 | int dmask;
|
---|
46 | int fmask;
|
---|
47 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
---|
48 | struct backing_dev_info bdi;
|
---|
49 | #endif
|
---|
50 | };
|
---|
51 |
|
---|
52 | /* per-inode information */
|
---|
53 | struct sf_inode_info
|
---|
54 | {
|
---|
55 | /* which file */
|
---|
56 | SHFLSTRING *path;
|
---|
57 | /* some information was changed, update data on next revalidate */
|
---|
58 | int force_restat;
|
---|
59 | /* directory content changed, update the whole directory on next sf_getdent */
|
---|
60 | int force_reread;
|
---|
61 | /* file structure, only valid between open() and release() */
|
---|
62 | struct file *file;
|
---|
63 | /* handle valid if a file was created with sf_create_aux until it will
|
---|
64 | * be opened with sf_reg_open() */
|
---|
65 | SHFLHANDLE handle;
|
---|
66 | };
|
---|
67 |
|
---|
68 | struct sf_dir_info
|
---|
69 | {
|
---|
70 | struct list_head info_list;
|
---|
71 | };
|
---|
72 |
|
---|
73 | struct sf_dir_buf
|
---|
74 | {
|
---|
75 | size_t cEntries;
|
---|
76 | size_t cbFree;
|
---|
77 | size_t cbUsed;
|
---|
78 | void *buf;
|
---|
79 | struct list_head head;
|
---|
80 | };
|
---|
81 |
|
---|
82 | struct sf_reg_info
|
---|
83 | {
|
---|
84 | SHFLHANDLE handle;
|
---|
85 | };
|
---|
86 |
|
---|
87 | /* globals */
|
---|
88 | extern VBSFCLIENT client_handle;
|
---|
89 |
|
---|
90 | /* forward declarations */
|
---|
91 | extern struct inode_operations sf_dir_iops;
|
---|
92 | extern struct inode_operations sf_lnk_iops;
|
---|
93 | extern struct inode_operations sf_reg_iops;
|
---|
94 | extern struct file_operations sf_dir_fops;
|
---|
95 | extern struct file_operations sf_reg_fops;
|
---|
96 | extern struct dentry_operations sf_dentry_ops;
|
---|
97 | extern struct address_space_operations sf_reg_aops;
|
---|
98 |
|
---|
99 | extern void sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode,
|
---|
100 | PSHFLFSOBJINFO info);
|
---|
101 | extern int sf_stat(const char *caller, struct sf_glob_info *sf_g,
|
---|
102 | SHFLSTRING *path, PSHFLFSOBJINFO result, int ok_to_fail);
|
---|
103 | extern int sf_inode_revalidate(struct dentry *dentry);
|
---|
104 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
---|
105 | extern int sf_getattr(struct vfsmount *mnt, struct dentry *dentry,
|
---|
106 | struct kstat *kstat);
|
---|
107 | extern int sf_setattr(struct dentry *dentry, struct iattr *iattr);
|
---|
108 | #endif
|
---|
109 | extern int sf_path_from_dentry(const char *caller, struct sf_glob_info *sf_g,
|
---|
110 | struct sf_inode_info *sf_i, struct dentry *dentry,
|
---|
111 | SHFLSTRING **result);
|
---|
112 | extern int sf_nlscpy(struct sf_glob_info *sf_g,
|
---|
113 | char *name, size_t name_bound_len,
|
---|
114 | const unsigned char *utf8_name, size_t utf8_len);
|
---|
115 | extern void sf_dir_info_free(struct sf_dir_info *p);
|
---|
116 | extern void sf_dir_info_empty(struct sf_dir_info *p);
|
---|
117 | extern struct sf_dir_info *sf_dir_info_alloc(void);
|
---|
118 | extern int sf_dir_read_all(struct sf_glob_info *sf_g, struct sf_inode_info *sf_i,
|
---|
119 | struct sf_dir_info *sf_d, SHFLHANDLE handle);
|
---|
120 | extern int sf_init_backing_dev(struct sf_glob_info *sf_g);
|
---|
121 | extern void sf_done_backing_dev(struct sf_glob_info *sf_g);
|
---|
122 |
|
---|
123 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
---|
124 | # define STRUCT_STATFS struct statfs
|
---|
125 | #else
|
---|
126 | # define STRUCT_STATFS struct kstatfs
|
---|
127 | #endif
|
---|
128 | int sf_get_volume_info(struct super_block *sb,STRUCT_STATFS *stat);
|
---|
129 |
|
---|
130 | #ifdef __cplusplus
|
---|
131 | # define CMC_API __attribute__ ((cdecl, regparm (0)))
|
---|
132 | #else
|
---|
133 | # define CMC_API __attribute__ ((regparm (0)))
|
---|
134 | #endif
|
---|
135 |
|
---|
136 | #define TRACE() LogFunc(("tracepoint\n"))
|
---|
137 |
|
---|
138 | /* Following casts are here to prevent assignment of void * to
|
---|
139 | pointers of arbitrary type */
|
---|
140 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
---|
141 | # define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->u.generic_sbp)
|
---|
142 | # define SET_GLOB_INFO(sb, sf_g) (sb)->u.generic_sbp = sf_g
|
---|
143 | #else
|
---|
144 | # define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->s_fs_info)
|
---|
145 | # define SET_GLOB_INFO(sb, sf_g) (sb)->s_fs_info = sf_g
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) || defined(KERNEL_FC6)
|
---|
149 | /* FC6 kernel 2.6.18, vanilla kernel 2.6.19+ */
|
---|
150 | # define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->i_private)
|
---|
151 | # define SET_INODE_INFO(i, sf_i) (i)->i_private = sf_i
|
---|
152 | #else
|
---|
153 | /* vanilla kernel up to 2.6.18 */
|
---|
154 | # define GET_INODE_INFO(i) ((struct sf_inode_info *) (i)->u.generic_ip)
|
---|
155 | # define SET_INODE_INFO(i, sf_i) (i)->u.generic_ip = sf_i
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
|
---|
159 | # define GET_F_DENTRY(f) (f->f_path.dentry)
|
---|
160 | #else
|
---|
161 | # define GET_F_DENTRY(f) (f->f_dentry)
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | #endif
|
---|
165 |
|
---|