dfs_fs.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2005-02-22 Bernard The first version.
  9. * 2023-05-05 Bernard Change to dfs v2.0
  10. */
  11. #ifndef __DFS_FS_H__
  12. #define __DFS_FS_H__
  13. #include <dfs.h>
  14. #include <dfs_file.h>
  15. #ifdef __cplusplus
  16. extern "C"
  17. {
  18. #endif
  19. #define MS_RDONLY 1
  20. #define MS_NOSUID 2
  21. #define MS_NODEV 4
  22. #define MS_NOEXEC 8
  23. #define MS_SYNCHRONOUS 16
  24. #define MS_REMOUNT 32
  25. #define MS_MANDLOCK 64
  26. #define MS_DIRSYNC 128
  27. #define MS_NOATIME 1024
  28. #define MS_NODIRATIME 2048
  29. #define MS_BIND 4096
  30. #define MS_MOVE 8192
  31. #define MS_REC 16384
  32. #define MS_SILENT 32768
  33. #define MS_POSIXACL (1<<16)
  34. #define MS_UNBINDABLE (1<<17)
  35. #define MS_PRIVATE (1<<18)
  36. #define MS_SLAVE (1<<19)
  37. #define MS_SHARED (1<<20)
  38. #define MS_RELATIME (1<<21)
  39. #define MS_KERNMOUNT (1<<22)
  40. #define MS_I_VERSION (1<<23)
  41. #define MS_STRICTATIME (1<<24)
  42. #define MS_LAZYTIME (1<<25)
  43. #define MS_NOREMOTELOCK (1<<27)
  44. #define MS_NOSEC (1<<28)
  45. #define MS_BORN (1<<29)
  46. #define MS_ACTIVE (1<<30)
  47. #define MS_NOUSER (1U<<31)
  48. #define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|MS_LAZYTIME)
  49. /* file system partition table */
  50. struct dfs_partition
  51. {
  52. uint8_t type; /* file system type */
  53. off_t offset; /* partition start offset */
  54. size_t size; /* partition size */
  55. rt_sem_t lock;
  56. };
  57. struct dfs_attr
  58. {
  59. unsigned int ia_valid;
  60. uid_t st_uid;
  61. gid_t st_gid;
  62. mode_t st_mode;
  63. struct timespec ia_atime;
  64. struct timespec ia_mtime;
  65. };
  66. struct dfs_mnt;
  67. struct dfs_dentry;
  68. struct dfs_vnode;
  69. struct statfs;
  70. struct dfs_filesystem_ops
  71. {
  72. const char *name;
  73. uint32_t flags;
  74. #define FS_NEED_DEVICE 0x1
  75. const struct dfs_file_ops *default_fops;
  76. int (*mount)(struct dfs_mnt *mnt, unsigned long rwflag, const void *data);
  77. int (*umount)(struct dfs_mnt *mnt);
  78. int (*mkfs)(rt_device_t devid, const char *fs_name);
  79. int (*readlink)(struct dfs_dentry *dentry, char *buf, int len);
  80. int (*link)(struct dfs_dentry *src_dentry, struct dfs_dentry *dst_dentry); /*hard link interface */
  81. int (*unlink)(struct dfs_dentry *dentry);
  82. int (*symlink)(struct dfs_dentry *parent_dentry, const char *target, const char *newpath); /*soft link interface*/
  83. int (*rename)(struct dfs_dentry *old_dentry, struct dfs_dentry *new_dentry);
  84. int (*stat)(struct dfs_dentry *dentry, struct stat *buf);
  85. int (*statfs)(struct dfs_mnt *mnt, struct statfs *buf);
  86. int (*setattr) (struct dfs_dentry *dentry, struct dfs_attr *attr);
  87. struct dfs_vnode* (*lookup)(struct dfs_dentry *dentry);
  88. struct dfs_vnode* (*create_vnode)(struct dfs_dentry *dentry, int type, mode_t mode);
  89. int (*free_vnode)(struct dfs_vnode* vnode);
  90. };
  91. struct dfs_filesystem_type
  92. {
  93. const struct dfs_filesystem_ops *fs_ops;
  94. struct dfs_filesystem_type *next;
  95. };
  96. struct dfs_filesystem_type *dfs_filesystems(void);
  97. int dfs_unregister(struct dfs_filesystem_type *fs);
  98. int dfs_register(struct dfs_filesystem_type *fs);
  99. const char *dfs_filesystem_get_mounted_path(struct rt_device *device);
  100. int dfs_remount(const char *path, rt_ubase_t flags, void *data);
  101. int dfs_mount(const char *device_name,
  102. const char *path,
  103. const char *filesystemtype,
  104. unsigned long rwflag,
  105. const void *data);
  106. int dfs_umount(const char *specialfile, int flags);
  107. int dfs_unmount(const char *specialfile);
  108. int dfs_is_mounted(struct dfs_mnt *mnt);
  109. int dfs_mkfs(const char *fs_name, const char *device_name);
  110. int dfs_statfs(const char *path, struct statfs *buffer);
  111. int dfs_filesystem_get_partition(struct dfs_partition *part,
  112. uint8_t *buf,
  113. uint32_t pindex);
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif