VirtualBox

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

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

linux/shared folders: use indent to switch Linux-only files to kernel style.
bugref:9109: Shared folders: update to match in-kernel code more closely

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