ff_sys.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * FreeRTOS+FAT V2.3.3
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * https://www.FreeRTOS.org
  23. * https://github.com/FreeRTOS
  24. *
  25. */
  26. /*
  27. * ff_sys.h
  28. *
  29. * This module allow to map several separate file-sub-systems into a root directory
  30. *
  31. * For instance, a system with 3 sub sytems:
  32. *
  33. * /flash : NAND flash driver
  34. * /ram : RAM-disk driver
  35. * / : SD-card driver
  36. *
  37. * In this example, the SD-card driver handles ALL files and directories which
  38. * do not match /flash/ * or /ram/ *
  39. *
  40. * Now for instance a file call "/flash/etc/network.ini"
  41. * will be stored as "/etc/network.ini" on the NAND drive
  42. *
  43. * This module along with ff_stdio.c make translations between absolute
  44. * and relative paths
  45. */
  46. #ifndef FF_SYS_H
  47. #define FF_SYS_H
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. typedef struct FILE_SUB_SYSTEM
  52. {
  53. char pcPath[ 16 ];
  54. BaseType_t xPathlen;
  55. FF_IOManager_t * pxManager;
  56. } FF_SubSystem_t;
  57. typedef struct FF_DIR_HANDLER
  58. {
  59. union
  60. {
  61. struct
  62. {
  63. unsigned
  64. bEndOfDir : 1,
  65. bFirstCalled : 1,
  66. bIsValid : 1,
  67. bAddDotEntries : 2;
  68. } bits;
  69. unsigned uFlags;
  70. } u;
  71. /*
  72. * path will contain the relative path. It will be used when calling +FAT functions
  73. * like FF_FindFirst() / FF_FindNext()
  74. * For instance, for "/flash/etc" path will become "/etc"
  75. */
  76. const char * pcPath;
  77. FF_IOManager_t * pxManager; /* Will point to handler of this partition. */
  78. BaseType_t xFSIndex; /* The index of this entry, where 0 always means: the root system. */
  79. } FF_DirHandler_t;
  80. /*
  81. * Initialise (clear) the file system table
  82. * This will also called by FF_FS_Add()
  83. */
  84. void FF_FS_Init( void );
  85. /*
  86. * Add a file system
  87. * The path must be absolute, e.g. start with a slash
  88. * The second argument is the FF_Disk_t structure that is handling the driver
  89. */
  90. int FF_FS_Add( const char * pcPath,
  91. FF_Disk_t * pxDisk );
  92. /*
  93. * Remove a file system
  94. * which ws earlier added by ff_fs_ad()
  95. */
  96. void FF_FS_Remove( const char * pcPath );
  97. /*
  98. * Internally used by ff_stdio:
  99. * The ff_dir_handler helps to iterate through a mounte directory
  100. *
  101. * FF_FS_Find() will find a ff_dir_handler for a given path
  102. */
  103. int FF_FS_Find( const char * pcPath,
  104. FF_DirHandler_t * pxHandler );
  105. /*
  106. * For internal use:
  107. * Get the file system information, based on an index
  108. */
  109. int FF_FS_Get( int iIndex,
  110. FF_SubSystem_t * pxSystem );
  111. /*
  112. * Returns the number of registered
  113. * file systems
  114. */
  115. int FF_FS_Count( void );
  116. #ifdef __cplusplus
  117. } /* extern "C" */
  118. #endif
  119. #endif /* FF_SYS_H */