hostfs.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef __UM_FS_HOSTFS
  2. #define __UM_FS_HOSTFS
  3. #include "os.h"
  4. /* These are exactly the same definitions as in fs.h, but the names are
  5. * changed so that this file can be included in both kernel and user files.
  6. */
  7. #define HOSTFS_ATTR_MODE 1
  8. #define HOSTFS_ATTR_UID 2
  9. #define HOSTFS_ATTR_GID 4
  10. #define HOSTFS_ATTR_SIZE 8
  11. #define HOSTFS_ATTR_ATIME 16
  12. #define HOSTFS_ATTR_MTIME 32
  13. #define HOSTFS_ATTR_CTIME 64
  14. #define HOSTFS_ATTR_ATIME_SET 128
  15. #define HOSTFS_ATTR_MTIME_SET 256
  16. /* These two are unused by hostfs. */
  17. #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */
  18. #define HOSTFS_ATTR_ATTR_FLAG 1024
  19. /* If you are very careful, you'll notice that these two are missing:
  20. *
  21. * #define ATTR_KILL_SUID 2048
  22. * #define ATTR_KILL_SGID 4096
  23. *
  24. * and this is because they were added in 2.5 development in this patch:
  25. *
  26. * http://linux.bkbits.net:8080/linux-2.5/
  27. * cset@3caf4a12k4XgDzK7wyK-TGpSZ9u2Ww?nav=index.html
  28. * |src/.|src/include|src/include/linux|related/include/linux/fs.h
  29. *
  30. * Actually, they are not needed by most ->setattr() methods - they are set by
  31. * callers of notify_change() to notify that the setuid/setgid bits must be
  32. * dropped.
  33. * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
  34. * is on, and remove the appropriate bits from attr->ia_mode (attr is a
  35. * "struct iattr *"). -BlaisorBlade
  36. */
  37. struct hostfs_iattr {
  38. unsigned int ia_valid;
  39. mode_t ia_mode;
  40. uid_t ia_uid;
  41. gid_t ia_gid;
  42. loff_t ia_size;
  43. struct timespec ia_atime;
  44. struct timespec ia_mtime;
  45. struct timespec ia_ctime;
  46. };
  47. extern int stat_file(const char *path, unsigned long long *inode_out,
  48. int *mode_out, int *nlink_out, int *uid_out, int *gid_out,
  49. unsigned long long *size_out, struct timespec *atime_out,
  50. struct timespec *mtime_out, struct timespec *ctime_out,
  51. int *blksize_out, unsigned long long *blocks_out);
  52. extern int access_file(char *path, int r, int w, int x);
  53. extern int open_file(char *path, int r, int w, int append);
  54. extern int file_type(const char *path, int *maj, int *min);
  55. extern void *open_dir(char *path, int *err_out);
  56. extern char *read_dir(void *stream, unsigned long long *pos,
  57. unsigned long long *ino_out, int *len_out);
  58. extern void close_file(void *stream);
  59. extern void close_dir(void *stream);
  60. extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
  61. extern int write_file(int fd, unsigned long long *offset, const char *buf,
  62. int len);
  63. extern int lseek_file(int fd, long long offset, int whence);
  64. extern int fsync_file(int fd, int datasync);
  65. extern int file_create(char *name, int ur, int uw, int ux, int gr,
  66. int gw, int gx, int or, int ow, int ox);
  67. extern int set_attr(const char *file, struct hostfs_iattr *attrs);
  68. extern int make_symlink(const char *from, const char *to);
  69. extern int unlink_file(const char *file);
  70. extern int do_mkdir(const char *file, int mode);
  71. extern int do_rmdir(const char *file);
  72. extern int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor);
  73. extern int link_file(const char *from, const char *to);
  74. extern int do_readlink(char *file, char *buf, int size);
  75. extern int rename_file(char *from, char *to);
  76. extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
  77. long long *bfree_out, long long *bavail_out,
  78. long long *files_out, long long *ffree_out,
  79. void *fsid_out, int fsid_size, long *namelen_out,
  80. long *spare_out);
  81. #endif
  82. /*
  83. * Overrides for Emacs so that we follow Linus's tabbing style.
  84. * Emacs will notice this stuff at the end of the file and automatically
  85. * adjust the settings for this buffer only. This must remain at the end
  86. * of the file.
  87. * ---------------------------------------------------------------------------
  88. * Local variables:
  89. * c-file-style: "linux"
  90. * End:
  91. */