1 /* SPDX-License-Identifier: MIT */ 1 /* SPDX-License-Identifier: MIT */ 2 /* 2 /* 3 * VirtualBox Guest Shared Folders support: mo 3 * VirtualBox Guest Shared Folders support: module header. 4 * 4 * 5 * Copyright (C) 2006-2018 Oracle Corporation 5 * Copyright (C) 2006-2018 Oracle Corporation 6 */ 6 */ 7 7 8 #ifndef VFSMOD_H 8 #ifndef VFSMOD_H 9 #define VFSMOD_H 9 #define VFSMOD_H 10 10 11 #include <linux/backing-dev.h> 11 #include <linux/backing-dev.h> 12 #include <linux/idr.h> 12 #include <linux/idr.h> 13 #include "shfl_hostintf.h" 13 #include "shfl_hostintf.h" 14 14 15 #define DIR_BUFFER_SIZE SZ_16K 15 #define DIR_BUFFER_SIZE SZ_16K 16 16 17 /* The cast is to prevent assignment of void * 17 /* The cast is to prevent assignment of void * to pointers of arbitrary type */ 18 #define VBOXSF_SBI(sb) ((struct vboxsf_sbi *) 18 #define VBOXSF_SBI(sb) ((struct vboxsf_sbi *)(sb)->s_fs_info) 19 #define VBOXSF_I(i) container_of(i, struct 19 #define VBOXSF_I(i) container_of(i, struct vboxsf_inode, vfs_inode) 20 20 21 struct vboxsf_handle; 21 struct vboxsf_handle; 22 22 23 struct vboxsf_options { 23 struct vboxsf_options { 24 unsigned long ttl; 24 unsigned long ttl; 25 kuid_t uid; 25 kuid_t uid; 26 kgid_t gid; 26 kgid_t gid; 27 bool dmode_set; 27 bool dmode_set; 28 bool fmode_set; 28 bool fmode_set; 29 umode_t dmode; 29 umode_t dmode; 30 umode_t fmode; 30 umode_t fmode; 31 umode_t dmask; 31 umode_t dmask; 32 umode_t fmask; 32 umode_t fmask; 33 }; 33 }; 34 34 35 struct vboxsf_fs_context { 35 struct vboxsf_fs_context { 36 struct vboxsf_options o; 36 struct vboxsf_options o; 37 char *nls_name; 37 char *nls_name; 38 }; 38 }; 39 39 40 /* per-shared folder information */ 40 /* per-shared folder information */ 41 struct vboxsf_sbi { 41 struct vboxsf_sbi { 42 struct vboxsf_options o; 42 struct vboxsf_options o; 43 struct shfl_fsobjinfo root_info; 43 struct shfl_fsobjinfo root_info; 44 struct idr ino_idr; 44 struct idr ino_idr; 45 spinlock_t ino_idr_lock; /* This prote 45 spinlock_t ino_idr_lock; /* This protects ino_idr */ 46 struct nls_table *nls; 46 struct nls_table *nls; 47 u32 next_generation; 47 u32 next_generation; 48 u32 root; 48 u32 root; 49 int bdi_id; 49 int bdi_id; 50 }; 50 }; 51 51 52 /* per-inode information */ 52 /* per-inode information */ 53 struct vboxsf_inode { 53 struct vboxsf_inode { 54 /* some information was changed, updat 54 /* some information was changed, update data on next revalidate */ 55 int force_restat; 55 int force_restat; 56 /* list of open handles for this inode 56 /* list of open handles for this inode + lock protecting it */ 57 struct list_head handle_list; 57 struct list_head handle_list; 58 /* This mutex protects handle_list acc 58 /* This mutex protects handle_list accesses */ 59 struct mutex handle_list_mutex; 59 struct mutex handle_list_mutex; 60 /* The VFS inode struct */ 60 /* The VFS inode struct */ 61 struct inode vfs_inode; 61 struct inode vfs_inode; 62 }; 62 }; 63 63 64 struct vboxsf_dir_info { 64 struct vboxsf_dir_info { 65 struct list_head info_list; 65 struct list_head info_list; 66 }; 66 }; 67 67 68 struct vboxsf_dir_buf { 68 struct vboxsf_dir_buf { 69 size_t entries; 69 size_t entries; 70 size_t free; 70 size_t free; 71 size_t used; 71 size_t used; 72 void *buf; 72 void *buf; 73 struct list_head head; 73 struct list_head head; 74 }; 74 }; 75 75 76 /* globals */ 76 /* globals */ 77 extern const struct inode_operations vboxsf_di 77 extern const struct inode_operations vboxsf_dir_iops; 78 extern const struct inode_operations vboxsf_ln 78 extern const struct inode_operations vboxsf_lnk_iops; 79 extern const struct inode_operations vboxsf_re 79 extern const struct inode_operations vboxsf_reg_iops; 80 extern const struct file_operations vboxsf_dir 80 extern const struct file_operations vboxsf_dir_fops; 81 extern const struct file_operations vboxsf_reg 81 extern const struct file_operations vboxsf_reg_fops; 82 extern const struct address_space_operations v 82 extern const struct address_space_operations vboxsf_reg_aops; 83 extern const struct dentry_operations vboxsf_d 83 extern const struct dentry_operations vboxsf_dentry_ops; 84 84 85 /* from file.c */ 85 /* from file.c */ 86 struct vboxsf_handle *vboxsf_create_sf_handle( 86 struct vboxsf_handle *vboxsf_create_sf_handle(struct inode *inode, 87 87 u64 handle, u32 access_flags); 88 void vboxsf_release_sf_handle(struct inode *in 88 void vboxsf_release_sf_handle(struct inode *inode, struct vboxsf_handle *sf_handle); 89 89 90 /* from utils.c */ 90 /* from utils.c */ 91 struct inode *vboxsf_new_inode(struct super_bl 91 struct inode *vboxsf_new_inode(struct super_block *sb); 92 int vboxsf_init_inode(struct vboxsf_sbi *sbi, 92 int vboxsf_init_inode(struct vboxsf_sbi *sbi, struct inode *inode, 93 const struct shfl_fsobj 93 const struct shfl_fsobjinfo *info, bool reinit); 94 int vboxsf_create_at_dentry(struct dentry *den 94 int vboxsf_create_at_dentry(struct dentry *dentry, 95 struct shfl_create 95 struct shfl_createparms *params); 96 int vboxsf_stat(struct vboxsf_sbi *sbi, struct 96 int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path, 97 struct shfl_fsobjinfo *info); 97 struct shfl_fsobjinfo *info); 98 int vboxsf_stat_dentry(struct dentry *dentry, 98 int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info); 99 int vboxsf_inode_revalidate(struct dentry *den 99 int vboxsf_inode_revalidate(struct dentry *dentry); 100 int vboxsf_getattr(struct mnt_idmap *idmap, co 100 int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path, 101 struct kstat *kstat, u32 re 101 struct kstat *kstat, u32 request_mask, 102 unsigned int query_flags); 102 unsigned int query_flags); 103 int vboxsf_setattr(struct mnt_idmap *idmap, st 103 int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 104 struct iattr *iattr); 104 struct iattr *iattr); 105 struct shfl_string *vboxsf_path_from_dentry(st 105 struct shfl_string *vboxsf_path_from_dentry(struct vboxsf_sbi *sbi, 106 st 106 struct dentry *dentry); 107 int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char 107 int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len, 108 const unsigned char *utf8_na 108 const unsigned char *utf8_name, size_t utf8_len); 109 struct vboxsf_dir_info *vboxsf_dir_info_alloc( 109 struct vboxsf_dir_info *vboxsf_dir_info_alloc(void); 110 void vboxsf_dir_info_free(struct vboxsf_dir_in 110 void vboxsf_dir_info_free(struct vboxsf_dir_info *p); 111 int vboxsf_dir_read_all(struct vboxsf_sbi *sbi 111 int vboxsf_dir_read_all(struct vboxsf_sbi *sbi, struct vboxsf_dir_info *sf_d, 112 u64 handle); 112 u64 handle); 113 113 114 /* from vboxsf_wrappers.c */ 114 /* from vboxsf_wrappers.c */ 115 int vboxsf_connect(void); 115 int vboxsf_connect(void); 116 void vboxsf_disconnect(void); 116 void vboxsf_disconnect(void); 117 117 118 int vboxsf_create(u32 root, struct shfl_string 118 int vboxsf_create(u32 root, struct shfl_string *parsed_path, 119 struct shfl_createparms *cre 119 struct shfl_createparms *create_parms); 120 120 121 int vboxsf_close(u32 root, u64 handle); 121 int vboxsf_close(u32 root, u64 handle); 122 int vboxsf_remove(u32 root, struct shfl_string 122 int vboxsf_remove(u32 root, struct shfl_string *parsed_path, u32 flags); 123 int vboxsf_rename(u32 root, struct shfl_string 123 int vboxsf_rename(u32 root, struct shfl_string *src_path, 124 struct shfl_string *dest_pat 124 struct shfl_string *dest_path, u32 flags); 125 125 126 int vboxsf_read(u32 root, u64 handle, u64 offs 126 int vboxsf_read(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf); 127 int vboxsf_write(u32 root, u64 handle, u64 off 127 int vboxsf_write(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf); 128 128 129 int vboxsf_dirinfo(u32 root, u64 handle, 129 int vboxsf_dirinfo(u32 root, u64 handle, 130 struct shfl_string *parsed_ 130 struct shfl_string *parsed_path, u32 flags, u32 index, 131 u32 *buf_len, struct shfl_d 131 u32 *buf_len, struct shfl_dirinfo *buf, u32 *file_count); 132 int vboxsf_fsinfo(u32 root, u64 handle, u32 fl 132 int vboxsf_fsinfo(u32 root, u64 handle, u32 flags, 133 u32 *buf_len, void *buf); 133 u32 *buf_len, void *buf); 134 134 135 int vboxsf_map_folder(struct shfl_string *fold 135 int vboxsf_map_folder(struct shfl_string *folder_name, u32 *root); 136 int vboxsf_unmap_folder(u32 root); 136 int vboxsf_unmap_folder(u32 root); 137 137 138 int vboxsf_readlink(u32 root, struct shfl_stri 138 int vboxsf_readlink(u32 root, struct shfl_string *parsed_path, 139 u32 buf_len, u8 *buf); 139 u32 buf_len, u8 *buf); 140 int vboxsf_symlink(u32 root, struct shfl_strin 140 int vboxsf_symlink(u32 root, struct shfl_string *new_path, 141 struct shfl_string *old_pat 141 struct shfl_string *old_path, struct shfl_fsobjinfo *buf); 142 142 143 int vboxsf_set_utf8(void); 143 int vboxsf_set_utf8(void); 144 int vboxsf_set_symlinks(void); 144 int vboxsf_set_symlinks(void); 145 145 146 #endif 146 #endif 147 147
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.