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