Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * VirtualBox Guest Shared Folders support: module header.
0004  *
0005  * Copyright (C) 2006-2018 Oracle Corporation
0006  */
0007 
0008 #ifndef VFSMOD_H
0009 #define VFSMOD_H
0010 
0011 #include <linux/backing-dev.h>
0012 #include <linux/idr.h>
0013 #include "shfl_hostintf.h"
0014 
0015 #define DIR_BUFFER_SIZE SZ_16K
0016 
0017 /* The cast is to prevent assignment of void * to pointers of arbitrary type */
0018 #define VBOXSF_SBI(sb)  ((struct vboxsf_sbi *)(sb)->s_fs_info)
0019 #define VBOXSF_I(i) container_of(i, struct vboxsf_inode, vfs_inode)
0020 
0021 struct vboxsf_handle;
0022 
0023 struct vboxsf_options {
0024     unsigned long ttl;
0025     kuid_t uid;
0026     kgid_t gid;
0027     bool dmode_set;
0028     bool fmode_set;
0029     umode_t dmode;
0030     umode_t fmode;
0031     umode_t dmask;
0032     umode_t fmask;
0033 };
0034 
0035 struct vboxsf_fs_context {
0036     struct vboxsf_options o;
0037     char *nls_name;
0038 };
0039 
0040 /* per-shared folder information */
0041 struct vboxsf_sbi {
0042     struct vboxsf_options o;
0043     struct shfl_fsobjinfo root_info;
0044     struct idr ino_idr;
0045     spinlock_t ino_idr_lock; /* This protects ino_idr */
0046     struct nls_table *nls;
0047     u32 next_generation;
0048     u32 root;
0049     int bdi_id;
0050 };
0051 
0052 /* per-inode information */
0053 struct vboxsf_inode {
0054     /* some information was changed, update data on next revalidate */
0055     int force_restat;
0056     /* list of open handles for this inode + lock protecting it */
0057     struct list_head handle_list;
0058     /* This mutex protects handle_list accesses */
0059     struct mutex handle_list_mutex;
0060     /* The VFS inode struct */
0061     struct inode vfs_inode;
0062 };
0063 
0064 struct vboxsf_dir_info {
0065     struct list_head info_list;
0066 };
0067 
0068 struct vboxsf_dir_buf {
0069     size_t entries;
0070     size_t free;
0071     size_t used;
0072     void *buf;
0073     struct list_head head;
0074 };
0075 
0076 /* globals */
0077 extern const struct inode_operations vboxsf_dir_iops;
0078 extern const struct inode_operations vboxsf_lnk_iops;
0079 extern const struct inode_operations vboxsf_reg_iops;
0080 extern const struct file_operations vboxsf_dir_fops;
0081 extern const struct file_operations vboxsf_reg_fops;
0082 extern const struct address_space_operations vboxsf_reg_aops;
0083 extern const struct dentry_operations vboxsf_dentry_ops;
0084 
0085 /* from file.c */
0086 struct vboxsf_handle *vboxsf_create_sf_handle(struct inode *inode,
0087                           u64 handle, u32 access_flags);
0088 void vboxsf_release_sf_handle(struct inode *inode, struct vboxsf_handle *sf_handle);
0089 
0090 /* from utils.c */
0091 struct inode *vboxsf_new_inode(struct super_block *sb);
0092 int vboxsf_init_inode(struct vboxsf_sbi *sbi, struct inode *inode,
0093                const struct shfl_fsobjinfo *info, bool reinit);
0094 int vboxsf_create_at_dentry(struct dentry *dentry,
0095                 struct shfl_createparms *params);
0096 int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path,
0097         struct shfl_fsobjinfo *info);
0098 int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info);
0099 int vboxsf_inode_revalidate(struct dentry *dentry);
0100 int vboxsf_getattr(struct user_namespace *mnt_userns, const struct path *path,
0101            struct kstat *kstat, u32 request_mask,
0102            unsigned int query_flags);
0103 int vboxsf_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
0104            struct iattr *iattr);
0105 struct shfl_string *vboxsf_path_from_dentry(struct vboxsf_sbi *sbi,
0106                         struct dentry *dentry);
0107 int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len,
0108           const unsigned char *utf8_name, size_t utf8_len);
0109 struct vboxsf_dir_info *vboxsf_dir_info_alloc(void);
0110 void vboxsf_dir_info_free(struct vboxsf_dir_info *p);
0111 int vboxsf_dir_read_all(struct vboxsf_sbi *sbi, struct vboxsf_dir_info *sf_d,
0112             u64 handle);
0113 
0114 /* from vboxsf_wrappers.c */
0115 int vboxsf_connect(void);
0116 void vboxsf_disconnect(void);
0117 
0118 int vboxsf_create(u32 root, struct shfl_string *parsed_path,
0119           struct shfl_createparms *create_parms);
0120 
0121 int vboxsf_close(u32 root, u64 handle);
0122 int vboxsf_remove(u32 root, struct shfl_string *parsed_path, u32 flags);
0123 int vboxsf_rename(u32 root, struct shfl_string *src_path,
0124           struct shfl_string *dest_path, u32 flags);
0125 
0126 int vboxsf_read(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf);
0127 int vboxsf_write(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf);
0128 
0129 int vboxsf_dirinfo(u32 root, u64 handle,
0130            struct shfl_string *parsed_path, u32 flags, u32 index,
0131            u32 *buf_len, struct shfl_dirinfo *buf, u32 *file_count);
0132 int vboxsf_fsinfo(u32 root, u64 handle, u32 flags,
0133           u32 *buf_len, void *buf);
0134 
0135 int vboxsf_map_folder(struct shfl_string *folder_name, u32 *root);
0136 int vboxsf_unmap_folder(u32 root);
0137 
0138 int vboxsf_readlink(u32 root, struct shfl_string *parsed_path,
0139             u32 buf_len, u8 *buf);
0140 int vboxsf_symlink(u32 root, struct shfl_string *new_path,
0141            struct shfl_string *old_path, struct shfl_fsobjinfo *buf);
0142 
0143 int vboxsf_set_utf8(void);
0144 int vboxsf_set_symlinks(void);
0145 
0146 #endif