hostfs.h 3.2 KB

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