exfat_api.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef _EXFAT_API_H
  19. #define _EXFAT_API_H
  20. #include "exfat_config.h"
  21. #include "exfat_global.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #define EXFAT_SUPER_MAGIC (0x2011BAB0L)
  26. #define EXFAT_ROOT_INO 1
  27. #define FAT12 0x01
  28. #define FAT16 0x0E
  29. #define FAT32 0x0C
  30. #define EXFAT 0x07
  31. #define MAX_CHARSET_SIZE 3
  32. #define MAX_PATH_DEPTH 15
  33. #define MAX_NAME_LENGTH 256
  34. #define MAX_PATH_LENGTH 260
  35. #define DOS_NAME_LENGTH 11
  36. #define DOS_PATH_LENGTH 80
  37. #define ATTR_NORMAL 0x0000
  38. #define ATTR_READONLY 0x0001
  39. #define ATTR_HIDDEN 0x0002
  40. #define ATTR_SYSTEM 0x0004
  41. #define ATTR_VOLUME 0x0008
  42. #define ATTR_SUBDIR 0x0010
  43. #define ATTR_ARCHIVE 0x0020
  44. #define ATTR_SYMLINK 0x0040
  45. #define ATTR_EXTEND 0x000F
  46. #define ATTR_RWMASK 0x007E
  47. #define FM_REGULAR 0x00
  48. #define FM_SYMLINK 0x40
  49. #define FFS_SUCCESS 0
  50. #define FFS_MEDIAERR 1
  51. #define FFS_FORMATERR 2
  52. #define FFS_MOUNTED 3
  53. #define FFS_NOTMOUNTED 4
  54. #define FFS_ALIGNMENTERR 5
  55. #define FFS_SEMAPHOREERR 6
  56. #define FFS_INVALIDPATH 7
  57. #define FFS_INVALIDFID 8
  58. #define FFS_NOTFOUND 9
  59. #define FFS_FILEEXIST 10
  60. #define FFS_PERMISSIONERR 11
  61. #define FFS_NOTOPENED 12
  62. #define FFS_MAXOPENED 13
  63. #define FFS_FULL 14
  64. #define FFS_EOF 15
  65. #define FFS_DIRBUSY 16
  66. #define FFS_MEMORYERR 17
  67. #define FFS_NAMETOOLONG 18
  68. #define FFS_ERROR 19
  69. typedef struct {
  70. UINT16 Year;
  71. UINT16 Month;
  72. UINT16 Day;
  73. UINT16 Hour;
  74. UINT16 Minute;
  75. UINT16 Second;
  76. UINT16 MilliSecond;
  77. } DATE_TIME_T;
  78. typedef struct {
  79. UINT32 Offset;
  80. UINT32 Size;
  81. } PART_INFO_T;
  82. typedef struct {
  83. UINT32 SecSize;
  84. UINT32 DevSize;
  85. } DEV_INFO_T;
  86. typedef struct {
  87. UINT32 FatType;
  88. UINT32 ClusterSize;
  89. UINT32 NumClusters;
  90. UINT32 FreeClusters;
  91. UINT32 UsedClusters;
  92. } VOL_INFO_T;
  93. typedef struct {
  94. UINT32 dir;
  95. INT32 size;
  96. UINT8 flags;
  97. } CHAIN_T;
  98. typedef struct {
  99. CHAIN_T dir;
  100. INT32 entry;
  101. UINT32 type;
  102. UINT32 attr;
  103. UINT32 start_clu;
  104. UINT64 size;
  105. UINT8 flags;
  106. INT64 rwoffset;
  107. INT32 hint_last_off;
  108. UINT32 hint_last_clu;
  109. } FILE_ID_T;
  110. typedef struct {
  111. INT8 Name[MAX_NAME_LENGTH *MAX_CHARSET_SIZE];
  112. INT8 ShortName[DOS_NAME_LENGTH + 2];
  113. UINT32 Attr;
  114. UINT64 Size;
  115. UINT32 NumSubdirs;
  116. DATE_TIME_T CreateTimestamp;
  117. DATE_TIME_T ModifyTimestamp;
  118. DATE_TIME_T AccessTimestamp;
  119. } DIR_ENTRY_T;
  120. INT32 FsInit(void);
  121. INT32 FsShutdown(void);
  122. INT32 FsMountVol(struct super_block *sb);
  123. INT32 FsUmountVol(struct super_block *sb);
  124. INT32 FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info);
  125. INT32 FsSyncVol(struct super_block *sb, INT32 do_sync);
  126. INT32 FsLookupFile(struct inode *inode, UINT8 *path, FILE_ID_T *fid);
  127. INT32 FsCreateFile(struct inode *inode, UINT8 *path, UINT8 mode, FILE_ID_T *fid);
  128. INT32 FsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, UINT64 count, UINT64 *rcount);
  129. INT32 FsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, UINT64 count, UINT64 *wcount);
  130. INT32 FsTruncateFile(struct inode *inode, UINT64 old_size, UINT64 new_size);
  131. INT32 FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry);
  132. INT32 FsRemoveFile(struct inode *inode, FILE_ID_T *fid);
  133. INT32 FsSetAttr(struct inode *inode, UINT32 attr);
  134. INT32 FsReadStat(struct inode *inode, DIR_ENTRY_T *info);
  135. INT32 FsWriteStat(struct inode *inode, DIR_ENTRY_T *info);
  136. INT32 FsMapCluster(struct inode *inode, INT32 clu_offset, UINT32 *clu);
  137. INT32 FsCreateDir(struct inode *inode, UINT8 *path, FILE_ID_T *fid);
  138. INT32 FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry);
  139. INT32 FsRemoveDir(struct inode *inode, FILE_ID_T *fid);
  140. INT32 FsRemoveEntry(struct inode *inode, FILE_ID_T *fid);
  141. INT32 FsReleaseCache(struct super_block *sb);
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif