nxffs.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /****************************************************************************
  2. * include/nuttx/fs/nxffs.h
  3. *
  4. * Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ****************************************************************************/
  35. #ifndef __INCLUDE_NUTTX_FS_NXFFS_H
  36. #define __INCLUDE_NUTTX_FS_NXFFS_H
  37. /****************************************************************************
  38. * Included Files
  39. ****************************************************************************/
  40. #include <nuttx/config.h>
  41. #include <stdbool.h>
  42. #include <nuttx/fs/fs.h>
  43. /****************************************************************************
  44. * Pre-processor Definitions
  45. ****************************************************************************/
  46. /* Configuration ************************************************************/
  47. /* If the erased state of FLASH memory is anything other than 0xff, then this
  48. * configuration should be provided.
  49. */
  50. #ifndef CONFIG_NXFFS_ERASEDSTATE
  51. # define CONFIG_NXFFS_ERASEDSTATE 0xff
  52. #endif
  53. #if CONFIG_NXFFS_ERASEDSTATE != 0xff && CONFIG_NXFFS_ERASEDSTATE != 0x00
  54. # error "CONFIG_NXFFS_ERASEDSTATE must be either 0x00 or 0xff"
  55. #endif
  56. /* Don't bother trying to pack things closer together than this. */
  57. #ifndef CONFIG_NXFFS_PACKTHRESHOLD
  58. # define CONFIG_NXFFS_PACKTHRESHOLD 32
  59. #endif
  60. /* This is how big an inode name is permitted to be. */
  61. #ifndef CONFIG_NXFFS_MAXNAMLEN
  62. # define CONFIG_NXFFS_MAXNAMLEN 255
  63. #endif
  64. /* Clean-up can either mean packing files together toward the end of the file
  65. * or, if file are deleted at the end of the file, clean up can simply mean
  66. * erasing the end of FLASH memory so that it can be re-used again. However,
  67. * doing this can also harm the life of the FLASH part because it can mean
  68. * that the tail end of the FLASH is re-used too often.
  69. *
  70. * This threshold determines if/when it is worth erased the tail end of FLASH
  71. * and making it available for re-use (and possible over-wear).
  72. */
  73. #ifndef CONFIG_NXFFS_TAILTHRESHOLD
  74. # define CONFIG_NXFFS_TAILTHRESHOLD (8*1024)
  75. #endif
  76. /* At present, only a single pre-allocated NXFFS volume is supported. This
  77. * is because here can be only a single NXFFS volume mounted at any time.
  78. * This has to do with the fact that we bind to an MTD driver (instead of a
  79. * block driver) and bypass all of the normal mount operations.
  80. */
  81. #undef CONFIG_NXFSS_PREALLOCATED
  82. #define CONFIG_NXFSS_PREALLOCATED 1
  83. /* If we were asked to scan the volume, then a re-formatting threshold must
  84. * also be provided.
  85. */
  86. #ifdef CONFIG_NXFFS_SCAN_VOLUME
  87. # ifndef CONFIG_NXFFS_REFORMAT_THRESH
  88. # define CONFIG_NXFFS_REFORMAT_THRESH 20
  89. # endif
  90. # if CONFIG_NXFFS_REFORMAT_THRESH < 0 || CONFIG_NXFFS_REFORMAT_THRESH > 100
  91. # error CONFIG_NXFFS_REFORMAT_THRESH is not a valid percentage
  92. # endif
  93. #endif
  94. /****************************************************************************
  95. * Public Function Prototypes
  96. ****************************************************************************/
  97. #ifdef __cplusplus
  98. #define EXTERN extern "C"
  99. extern "C"
  100. {
  101. #else
  102. #define EXTERN extern
  103. #endif
  104. /****************************************************************************
  105. * Name: nxffs_initialize
  106. *
  107. * Description:
  108. * Initialize to provide NXFFS on an MTD interface
  109. *
  110. * Input Parameters:
  111. * mtd - The MTD device that supports the FLASH interface.
  112. *
  113. * Returned Value:
  114. * Zero is returned on success. Otherwise, a negated errno value is
  115. * returned to indicate the nature of the failure.
  116. *
  117. ****************************************************************************/
  118. struct mtd_dev_s;
  119. int nxffs_initialize(FAR struct mtd_dev_s *mtd);
  120. /****************************************************************************
  121. * Name: nxffs_dump
  122. *
  123. * Description:
  124. * Dump a summary of the contents of an NXFFS file system. CONFIG_DEBUG_FEATURES
  125. * and CONFIG_DEBUG_FS must be enabled for this function to do anything.
  126. *
  127. * Input Parameters:
  128. * mtd - The MTD device that provides the interface to NXFFS-formatted
  129. * media.
  130. * verbose - FALSE: only show errors
  131. *
  132. * Returned Value:
  133. * Zero is returned on success. Otherwise, a negated errno value is
  134. * returned to indicate the nature of the failure.
  135. *
  136. ****************************************************************************/
  137. struct mtd_dev_s;
  138. int nxffs_dump(FAR struct mtd_dev_s *mtd, bool verbose);
  139. #undef EXTERN
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif /* __INCLUDE_NUTTX_FS_NXFFS_H */