hostfs.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __UM_FS_HOSTFS
  3. #define __UM_FS_HOSTFS
  4. #include <os.h>
  5. #include <generated/asm-offsets.h>
  6. struct hostfs_timespec {
  7. long long tv_sec;
  8. long long tv_nsec;
  9. };
  10. struct hostfs_iattr {
  11. unsigned int ia_valid;
  12. unsigned short ia_mode;
  13. uid_t ia_uid;
  14. gid_t ia_gid;
  15. loff_t ia_size;
  16. struct hostfs_timespec ia_atime;
  17. struct hostfs_timespec ia_mtime;
  18. struct hostfs_timespec ia_ctime;
  19. };
  20. struct hostfs_stat {
  21. unsigned long long ino;
  22. unsigned int mode;
  23. unsigned int nlink;
  24. unsigned int uid;
  25. unsigned int gid;
  26. unsigned long long size;
  27. struct hostfs_timespec atime, mtime, ctime, btime;
  28. unsigned int blksize;
  29. unsigned long long blocks;
  30. struct {
  31. unsigned int maj;
  32. unsigned int min;
  33. } rdev, dev;
  34. };
  35. extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
  36. extern int access_file(char *path, int r, int w, int x);
  37. extern int open_file(char *path, int r, int w, int append);
  38. extern void *open_dir(char *path, int *err_out);
  39. extern void seek_dir(void *stream, unsigned long long pos);
  40. extern char *read_dir(void *stream, unsigned long long *pos_out,
  41. unsigned long long *ino_out, int *len_out,
  42. unsigned int *type_out);
  43. extern void close_file(void *stream);
  44. extern int replace_file(int oldfd, int fd);
  45. extern void close_dir(void *stream);
  46. extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
  47. extern int write_file(int fd, unsigned long long *offset, const char *buf,
  48. int len);
  49. extern int lseek_file(int fd, long long offset, int whence);
  50. extern int fsync_file(int fd, int datasync);
  51. extern int file_create(char *name, int mode);
  52. extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
  53. extern int make_symlink(const char *from, const char *to);
  54. extern int unlink_file(const char *file);
  55. extern int do_mkdir(const char *file, int mode);
  56. extern int hostfs_do_rmdir(const char *file);
  57. extern int do_mknod(const char *file, int mode, unsigned int major,
  58. unsigned int minor);
  59. extern int link_file(const char *to, const char *from);
  60. extern int hostfs_do_readlink(char *file, char *buf, int size);
  61. extern int rename_file(char *from, char *to);
  62. extern int rename2_file(char *from, char *to, unsigned int flags);
  63. extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
  64. long long *bfree_out, long long *bavail_out,
  65. long long *files_out, long long *ffree_out,
  66. void *fsid_out, int fsid_size, long *namelen_out);
  67. #endif