driver.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /****************************************************************************
  2. * fs/driver/driver.h
  3. *
  4. * Copyright (C) 2007, 2009, 2012, 2014, 2018 Gregory Nutt. All rights
  5. * reserved.
  6. * Author: Gregory Nutt <gnutt@nuttx.org>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ****************************************************************************/
  36. #ifndef __FS_DRIVER_DRIVER_H
  37. #define __FS_DRIVER_DRIVER_H
  38. /****************************************************************************
  39. * Included Files
  40. ****************************************************************************/
  41. #include <nuttx/config.h>
  42. #include <nuttx/compiler.h>
  43. #include <nuttx/fs/fs.h>
  44. #include "inode/inode.h"
  45. /****************************************************************************
  46. * Public Data
  47. ****************************************************************************/
  48. #undef EXTERN
  49. #if defined(__cplusplus)
  50. #define EXTERN extern "C"
  51. extern "C"
  52. {
  53. #else
  54. #define EXTERN extern
  55. #endif
  56. /****************************************************************************
  57. * Public Function Prototypes
  58. ****************************************************************************/
  59. /****************************************************************************
  60. * Name: find_blockdriver
  61. *
  62. * Description:
  63. * Return the inode of the block driver specified by 'pathname'
  64. *
  65. * Input Parameters:
  66. * pathname - The full path to the block driver to be located
  67. * mountflags - If MS_RDONLY is not set, then driver must support write
  68. * operations (see include/sys/mount.h)
  69. * ppinode - Address of the location to return the inode reference
  70. *
  71. * Returned Value:
  72. * Returns zero on success or a negated errno on failure:
  73. *
  74. * ENOENT - No block driver of this name is registered
  75. * ENOTBLK - The inode associated with the pathname is not a block driver
  76. * EACCESS - The MS_RDONLY option was not set but this driver does not
  77. * support write access
  78. *
  79. ****************************************************************************/
  80. #ifndef CONFIG_DISABLE_MOUNTPOINT
  81. int find_blockdriver(FAR const char *pathname, int mountflags,
  82. FAR struct inode **ppinode);
  83. #endif
  84. /****************************************************************************
  85. * Name: block_proxy
  86. *
  87. * Description:
  88. * Create a temporary char driver using drivers/bch to mediate character
  89. * oriented accessed to the block driver.
  90. *
  91. * Input Parameters:
  92. * blkdev - The path to the block driver
  93. * oflags - Character driver open flags
  94. *
  95. * Returned Value:
  96. * If positive, non-zero file descriptor is returned on success. This
  97. * is the file descriptor of the nameless character driver that mediates
  98. * accesses to the block driver.
  99. *
  100. * Errors that may be returned:
  101. *
  102. * ENOMEM - Failed to create a temporary path name.
  103. *
  104. * Plus:
  105. *
  106. * - Errors reported from bchdev_register()
  107. * - Errors reported from open() or unlink()
  108. *
  109. ****************************************************************************/
  110. #if !defined(CONFIG_DISABLE_MOUNTPOINT)
  111. int block_proxy(FAR const char *blkdev, int oflags);
  112. #endif
  113. /****************************************************************************
  114. * Name: mtd_proxy
  115. *
  116. * Description:
  117. * Create a temporary block driver using drivers/mtd/ftl to mediate block
  118. * oriented accessed to the mtd driver.
  119. *
  120. * Input Parameters:
  121. * mtddev - The path to the mtd driver
  122. * mountflags - if MS_RDONLY is not set, then driver must support write
  123. * operations (see include/sys/mount.h)
  124. * ppinode - address of the location to return the inode reference
  125. *
  126. * Returned Value:
  127. * If zero, non-zero inode pointer is returned on success. This
  128. * is the inode pointer of the nameless block driver that mediates
  129. * accesses to the mtd driver.
  130. *
  131. * Errors that may be returned:
  132. *
  133. * ENOMEM - Failed to create a temporary path name.
  134. *
  135. * Plus:
  136. *
  137. * - Errors reported from ftl_initialize()
  138. * - Errors reported from open() or unlink()
  139. *
  140. ****************************************************************************/
  141. #ifdef CONFIG_MTD
  142. int mtd_proxy(FAR const char *mtddev, int mountflags,
  143. FAR struct inode **ppinode);
  144. #endif
  145. /****************************************************************************
  146. * Name: find_mtddriver
  147. *
  148. * Description:
  149. * Return the inode of the named MTD driver specified by 'pathname'
  150. *
  151. * Input Parameters:
  152. * pathname - the full path to the named MTD driver to be located
  153. * ppinode - address of the location to return the inode reference
  154. *
  155. * Returned Value:
  156. * Returns zero on success or a negated errno on failure:
  157. *
  158. * ENOENT - No MTD driver of this name is registered
  159. * ENOTBLK - The inode associated with the pathname is not an MTD driver
  160. *
  161. ****************************************************************************/
  162. #if defined(CONFIG_MTD) && !defined(CONFIG_DISABLE_MOUNTPOINT)
  163. int find_mtddriver(FAR const char *pathname, FAR struct inode **ppinode);
  164. #endif
  165. #undef EXTERN
  166. #if defined(__cplusplus)
  167. }
  168. #endif
  169. #endif /* __FS_DRIVER_DRIVER_H */