phatfs.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef FS_PHATFS_H_
  2. #define FS_PHATFS_H_
  3. /*
  4. * Copyright (C) 2005-2006 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*!
  35. * \file fs/phatfs.h
  36. * \brief PHAT file system.
  37. *
  38. * \verbatim
  39. *
  40. * $Log: phatfs.h,v $
  41. * Revision 1.5 2006/10/08 16:42:56 haraldkipp
  42. * Not optimal, but simple and reliable exclusive access implemented.
  43. * Fixes bug #1486539. Furthermore, bug #1567790, which had been rejected,
  44. * had been reported correctly and is now fixed.
  45. *
  46. * Revision 1.4 2006/06/18 16:42:50 haraldkipp
  47. * Support for long filenames (VFAT) added.
  48. *
  49. * Revision 1.3 2006/05/15 11:48:38 haraldkipp
  50. * Added a second PHAT file system instance.
  51. *
  52. * Revision 1.2 2006/01/22 17:44:20 haraldkipp
  53. * ICCAVR failed to find local header files.
  54. *
  55. * Revision 1.1 2006/01/05 16:32:57 haraldkipp
  56. * First check-in.
  57. *
  58. *
  59. * \endverbatim
  60. */
  61. #include <sys/types.h>
  62. #include <sys/file.h>
  63. #include <sys/device.h>
  64. #include <fs/phatdir.h>
  65. /*!
  66. * \addtogroup xgPhatFs
  67. */
  68. /*@{*/
  69. /*!
  70. * \brief PHAT file descriptor structure.
  71. */
  72. typedef struct _PHATFILE {
  73. /*! \brief Current position into the file. */
  74. u_long f_pos;
  75. /*! \brief Current cluster. */
  76. u_long f_clust;
  77. /*! \brief Sector within the current cluster. */
  78. u_long f_clust_pos;
  79. /*! \brief Position within the sector. */
  80. u_long f_sect_pos;
  81. /*! \brief Previous cluster used, */
  82. u_long f_clust_prv;
  83. /*! \brief File open mode flags. */
  84. u_long f_mode;
  85. /*! \brief Directory entry of this file. */
  86. PHATDIRENT f_dirent;
  87. /*! \brief Sector of the directory entry.
  88. *
  89. * For the root directory this value is zero, because the root
  90. * doesn't have any entry in another directory.
  91. */
  92. u_long f_de_sect;
  93. /*! \brief Offset into the sector containing the directory entry. */
  94. u_long f_de_offs;
  95. /*! \brief Directory entry change marker. */
  96. u_int f_de_dirty;
  97. /*! \brief First cluster of the parent directory, low word.
  98. *
  99. * Our directory entry is located in this cluster.
  100. */
  101. u_short f_pde_clust;
  102. /*! \brief First cluster of the parent directory, high word. */
  103. u_short f_pde_clusthi;
  104. } PHATFILE;
  105. /*! \brief Marks end of cluster chain. */
  106. #define PHATEOC 0x0FFFFFF8
  107. /*!
  108. * \name File attributes.
  109. */
  110. /*@{*/
  111. /*! Read only file. */
  112. #define PHAT_FATTR_RDONLY 0x01
  113. /*! Hidden file. */
  114. #define PHAT_FATTR_HIDDEN 0x02
  115. /*! System file. */
  116. #define PHAT_FATTR_SYSTEM 0x04
  117. /*! No file, but a volume label. */
  118. #define PHAT_FATTR_VOLID 0x08
  119. /*! File contains a subdirectory. */
  120. #define PHAT_FATTR_DIR 0x10
  121. /*! File is not archived. This flag will be set when the file is created
  122. * or modified.
  123. */
  124. #define PHAT_FATTR_ARCHIV 0x20
  125. /*! Long filename entry. */
  126. #define PHAT_FATTR_LFN (PHAT_FATTR_RDONLY | PHAT_FATTR_HIDDEN | PHAT_FATTR_SYSTEM | PHAT_FATTR_VOLID)
  127. /*! Only these flags are allowed for files and directories. */
  128. #define PHAT_FATTR_FILEMASK 0x37
  129. /*@}*/
  130. #include <fs/phat12.h>
  131. #include <fs/phat16.h>
  132. #include <fs/phat32.h>
  133. extern NUTDEVICE devPhat0;
  134. extern NUTDEVICE devPhat1;
  135. extern u_long AllocFirstCluster(NUTFILE * nfp);
  136. extern NUTFILE *PhatFileOpen(NUTDEVICE * dev, CONST char *path, int mode, int acc);
  137. extern int PhatFileClose(NUTFILE * nfp);
  138. extern int PhatFileWrite(NUTFILE * nfp, CONST void *buffer, int len);
  139. #ifdef __HARVARD_ARCH__
  140. extern int PhatFileWrite_P(NUTFILE * nfp, PGM_P buffer, int len);
  141. #endif
  142. extern int PhatFileRead(NUTFILE * nfp, void *buffer, int size);
  143. #endif