dfs_fs.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2006-2018, 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. */
  10. #ifndef __DFS_FS_H__
  11. #define __DFS_FS_H__
  12. #include <dfs.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /* Pre-declaration */
  17. struct dfs_filesystem;
  18. struct dfs_fd;
  19. /* File system operations */
  20. struct dfs_filesystem_ops
  21. {
  22. char *name;
  23. uint32_t flags; /* flags for file system operations */
  24. /* operations for file */
  25. const struct dfs_file_ops *fops;
  26. /* mount and unmount file system */
  27. int (*mount) (struct dfs_filesystem *fs, unsigned long rwflag, const void *data);
  28. int (*unmount) (struct dfs_filesystem *fs);
  29. /* make a file system */
  30. int (*mkfs) (rt_device_t devid);
  31. int (*statfs) (struct dfs_filesystem *fs, struct statfs *buf);
  32. int (*unlink) (struct dfs_filesystem *fs, const char *pathname);
  33. int (*stat) (struct dfs_filesystem *fs, const char *filename, struct stat *buf);
  34. int (*rename) (struct dfs_filesystem *fs, const char *oldpath, const char *newpath);
  35. };
  36. /* Mounted file system */
  37. struct dfs_filesystem
  38. {
  39. rt_device_t dev_id; /* Attached device */
  40. char *path; /* File system mount point */
  41. const struct dfs_filesystem_ops *ops; /* Operations for file system type */
  42. void *data; /* Specific file system data */
  43. };
  44. /* file system partition table */
  45. struct dfs_partition
  46. {
  47. uint8_t type; /* file system type */
  48. off_t offset; /* partition start offset */
  49. size_t size; /* partition size */
  50. rt_sem_t lock;
  51. };
  52. /* mount table */
  53. struct dfs_mount_tbl
  54. {
  55. const char *device_name;
  56. const char *path;
  57. const char *filesystemtype;
  58. unsigned long rwflag;
  59. const void *data;
  60. };
  61. int dfs_register(const struct dfs_filesystem_ops *ops);
  62. struct dfs_filesystem *dfs_filesystem_lookup(const char *path);
  63. const char *dfs_filesystem_get_mounted_path(struct rt_device *device);
  64. int dfs_filesystem_get_partition(struct dfs_partition *part,
  65. uint8_t *buf,
  66. uint32_t pindex);
  67. int dfs_mount(const char *device_name,
  68. const char *path,
  69. const char *filesystemtype,
  70. unsigned long rwflag,
  71. const void *data);
  72. int dfs_unmount(const char *specialfile);
  73. int dfs_mkfs(const char *fs_name, const char *device_name);
  74. int dfs_statfs(const char *path, struct statfs *buffer);
  75. int dfs_mount_device(rt_device_t dev);
  76. int dfs_unmount_device(rt_device_t dev);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif