partition.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /****************************************************************************
  2. * include/nuttx/fs/partition.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_NUTTX_FS_PARTITION_H
  21. #define __INCLUDE_NUTTX_FS_PARTITION_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include <limits.h>
  27. #include <sys/types.h>
  28. #ifndef CONFIG_DISABLE_MOUNTPOINT
  29. #ifdef __cplusplus
  30. #define EXTERN extern "C"
  31. extern "C"
  32. {
  33. #else
  34. #define EXTERN extern
  35. #endif
  36. /****************************************************************************
  37. * Public Types
  38. ****************************************************************************/
  39. struct partition_s
  40. {
  41. char name[NAME_MAX + 1];
  42. size_t index;
  43. size_t firstblock;
  44. size_t nblocks;
  45. size_t blocksize;
  46. };
  47. typedef CODE void
  48. (*partition_handler_t)(FAR struct partition_s *part, FAR void *arg);
  49. /****************************************************************************
  50. * Public Function Prototypes
  51. ****************************************************************************/
  52. /****************************************************************************
  53. * Name: parse_block_partition
  54. *
  55. * Description:
  56. * parse the partition table on a block device.
  57. *
  58. * Input Parameters:
  59. * path - The block device to be parsed
  60. * handler - The function to be called for each found partition
  61. * arg - A caller provided value to return with the handler
  62. *
  63. * Returned Value:
  64. * Zero on success; A negated errno value is returned on a failure
  65. *
  66. ****************************************************************************/
  67. int parse_block_partition(FAR const char *path,
  68. partition_handler_t handler,
  69. FAR void *arg);
  70. /****************************************************************************
  71. * Name: parse_mtd_partition
  72. *
  73. * Description:
  74. * parse the partition table on a mtd device.
  75. *
  76. * Input Parameters:
  77. * mtd - The MTD device to be parsed
  78. * handler - The function to be called for each found partition
  79. * arg - A caller provided value to return with the handler
  80. *
  81. * Returned Value:
  82. * Zero on success; A negated errno value is returned on a failure
  83. *
  84. ****************************************************************************/
  85. struct mtd_dev_s;
  86. int parse_mtd_partition(FAR struct mtd_dev_s *mtd,
  87. partition_handler_t handler,
  88. FAR void *arg);
  89. #undef EXTERN
  90. #if defined(__cplusplus)
  91. }
  92. #endif
  93. #endif /* CONFIG_DISABLE_MOUNTPOINT */
  94. #endif /* __INCLUDE_NUTTX_FS_PARTITION_H */