vfsmod.h 4.5 KB

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