hostfs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __UM_FS_HOSTFS
  3. #define __UM_FS_HOSTFS
  4. #include <os.h>
  5. /*
  6. * These are exactly the same definitions as in fs.h, but the names are
  7. * changed so that this file can be included in both kernel and user files.
  8. */
  9. #define HOSTFS_ATTR_MODE 1
  10. #define HOSTFS_ATTR_UID 2
  11. #define HOSTFS_ATTR_GID 4
  12. #define HOSTFS_ATTR_SIZE 8
  13. #define HOSTFS_ATTR_ATIME 16
  14. #define HOSTFS_ATTR_MTIME 32
  15. #define HOSTFS_ATTR_CTIME 64
  16. #define HOSTFS_ATTR_ATIME_SET 128
  17. #define HOSTFS_ATTR_MTIME_SET 256
  18. /* This one is unused by hostfs. */
  19. #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */
  20. #define HOSTFS_ATTR_ATTR_FLAG 1024
  21. /*
  22. * If you are very careful, you'll notice that these two are missing:
  23. *
  24. * #define ATTR_KILL_SUID 2048
  25. * #define ATTR_KILL_SGID 4096
  26. *
  27. * and this is because they were added in 2.5 development.
  28. * Actually, they are not needed by most ->setattr() methods - they are set by
  29. * callers of notify_change() to notify that the setuid/setgid bits must be
  30. * dropped.
  31. * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
  32. * is on, and remove the appropriate bits from attr->ia_mode (attr is a
  33. * "struct iattr *"). -BlaisorBlade
  34. */
  35. struct hostfs_iattr {
  36. unsigned int ia_valid;
  37. unsigned short ia_mode;
  38. uid_t ia_uid;
  39. gid_t ia_gid;
  40. loff_t ia_size;
  41. struct timespec ia_atime;
  42. struct timespec ia_mtime;
  43. struct timespec ia_ctime;
  44. };
  45. struct hostfs_stat {
  46. unsigned long long ino;
  47. unsigned int mode;
  48. unsigned int nlink;
  49. unsigned int uid;
  50. unsigned int gid;
  51. unsigned long long size;
  52. struct timespec atime, mtime, ctime;
  53. unsigned int blksize;
  54. unsigned long long blocks;
  55. unsigned int maj;
  56. unsigned int min;
  57. };
  58. extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
  59. extern int access_file(char *path, int r, int w, int x);
  60. extern int open_file(char *path, int r, int w, int append);
  61. extern void *open_dir(char *path, int *err_out);
  62. extern void seek_dir(void *stream, unsigned long long pos);
  63. extern char *read_dir(void *stream, unsigned long long *pos_out,
  64. unsigned long long *ino_out, int *len_out,
  65. unsigned int *type_out);
  66. extern void close_file(void *stream);
  67. extern int replace_file(int oldfd, int fd);
  68. extern void close_dir(void *stream);
  69. extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
  70. extern int write_file(int fd, unsigned long long *offset, const char *buf,
  71. int len);
  72. extern int lseek_file(int fd, long long offset, int whence);
  73. extern int fsync_file(int fd, int datasync);
  74. extern int file_create(char *name, int mode);
  75. extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
  76. extern int make_symlink(const char *from, const char *to);
  77. extern int unlink_file(const char *file);
  78. extern int do_mkdir(const char *file, int mode);
  79. extern int hostfs_do_rmdir(const char *file);
  80. extern int do_mknod(const char *file, int mode, unsigned int major,
  81. unsigned int minor);
  82. extern int link_file(const char *from, const char *to);
  83. extern int hostfs_do_readlink(char *file, char *buf, int size);
  84. extern int rename_file(char *from, char *to);
  85. extern int rename2_file(char *from, char *to, unsigned int flags);
  86. extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
  87. long long *bfree_out, long long *bavail_out,
  88. long long *files_out, long long *ffree_out,
  89. void *fsid_out, int fsid_size, long *namelen_out);
  90. #endif