dfs_tmpfs.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. * 2022-10-24 flybreak the first version
  9. */
  10. #ifndef __DFS_TMPFS_H__
  11. #define __DFS_TMPFS_H__
  12. #include <rtthread.h>
  13. #include <dfs_vfs.h>
  14. #define TMPFS_NAME_MAX 32
  15. #define TMPFS_MAGIC 0x0B0B0B0B
  16. #define TMPFS_TYPE_FILE 0x00
  17. #define TMPFS_TYPE_DIR 0x01
  18. struct tmpfs_sb;
  19. struct tmpfs_file
  20. {
  21. rt_uint32_t type; /* file type */
  22. char name[TMPFS_NAME_MAX]; /* file name */
  23. struct dfs_vfs_node node; /* file node in the tmpfs */
  24. struct tmpfs_sb *sb; /* superblock ptr */
  25. rt_uint8_t *data; /* file date ptr */
  26. rt_size_t size; /* file size */
  27. rt_bool_t fre_memory;/* Whether to release memory upon close */
  28. };
  29. struct tmpfs_sb
  30. {
  31. rt_uint32_t magic; /* TMPFS_MAGIC */
  32. struct tmpfs_file root; /* root dir */
  33. rt_size_t df_size; /* df size */
  34. rt_list_t sibling; /* sb sibling list */
  35. struct rt_spinlock lock; /* tmpfs lock */
  36. };
  37. int dfs_tmpfs_init(void);
  38. #endif