Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

480 lines
23 KiB

  1. /*
  2. * $Log: V:/Flite/archives/FLite/src/FSAPI.H_V $
  3. Rev 1.4 Jan 20 2000 17:54:24 vadimk
  4. add FL_READ_ONLY define
  5. Rev 1.3 Jan 17 2000 13:43:06 vadimk
  6. remove fl_format_volume
  7. Rev 1.2 Jan 13 2000 18:28:12 vadimk
  8. TrueFFS OSAK 4.1
  9. Rev 1.1 Jul 12 1999 16:53:34 marinak
  10. dosFormat call is passed from blockdev.c to fatlite.c
  11. Rev 1.0 22 Dec 1998 14:04:34 marina
  12. Initial revision.
  13. *
  14. */
  15. /***********************************************************************************/
  16. /* M-Systems Confidential */
  17. /* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-99 */
  18. /* All Rights Reserved */
  19. /***********************************************************************************/
  20. /* NOTICE OF M-SYSTEMS OEM */
  21. /* SOFTWARE LICENSE AGREEMENT */
  22. /* */
  23. /* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
  24. /* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
  25. /* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
  26. /* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
  27. /* E-MAIL = [email protected] */
  28. /***********************************************************************************/
  29. #ifndef FSAPI_H
  30. #define FSAPI_H
  31. #include "flreq.h"
  32. /*----------------------------------------------------------------------*/
  33. /* f l C a l l */
  34. /* */
  35. /* Common entry-point to all file-system functions. Macros are */
  36. /* to call individual function, which are separately described below. */
  37. /* */
  38. /* Parameters: */
  39. /* function : file-system function code (listed below) */
  40. /* ioreq : IOreq structure */
  41. /* */
  42. /* Returns: */
  43. /* FLStatus : 0 on success, otherwise failed */
  44. /*----------------------------------------------------------------------*/
  45. typedef enum {
  46. FL_OPEN_FILE,
  47. FL_CLOSE_FILE,
  48. FL_READ_FILE,
  49. FL_WRITE_FILE,
  50. FL_SEEK_FILE,
  51. FL_FIND_FILE,
  52. FL_FIND_FIRST_FILE,
  53. FL_FIND_NEXT_FILE,
  54. FL_GET_DISK_INFO,
  55. FL_DELETE_FILE,
  56. FL_RENAME_FILE,
  57. FL_MAKE_DIR,
  58. FL_REMOVE_DIR,
  59. FL_SPLIT_FILE,
  60. FL_JOIN_FILE,
  61. FL_FLUSH_BUFFER
  62. } FLFunctionNo;
  63. FLStatus flCall(FLFunctionNo functionNo, IOreq FAR2 *ioreq);
  64. #if FILES > 0
  65. #ifndef FL_READ_ONLY
  66. /*----------------------------------------------------------------------*/
  67. /* f l F l u s h B u f f e r */
  68. /* */
  69. /* If there is relevant data in the RAM buffer then writes it on */
  70. /* the flash memory. */
  71. /* */
  72. /* Parameters: */
  73. /* irHandle : Drive number (0, 1, ...) */
  74. /* */
  75. /* Returns: */
  76. /* FLStatus : 0 on success, otherwise failed */
  77. /*----------------------------------------------------------------------*/
  78. #define flFlushBuffer(ioreq) flCall(FL_FLUSH_BUFFER,ioreq)
  79. #endif /* READ_ONLY */
  80. /*----------------------------------------------------------------------*/
  81. /* f l O p e n F i l e */
  82. /* */
  83. /* Opens an existing file or creates a new file. Creates a file handle */
  84. /* for further file processing. */
  85. /* */
  86. /* Parameters: */
  87. /* irHandle : Drive number (0, 1, ...) */
  88. /* irFlags : Access and action options, defined below */
  89. /* irPath : path of file to open */
  90. /* */
  91. /* Returns: */
  92. /* FLStatus : 0 on success, otherwise failed */
  93. /* irHandle : New file handle for open file */
  94. /* */
  95. /*----------------------------------------------------------------------*/
  96. /** Values of irFlags for flOpenFile: */
  97. #define ACCESS_MODE_MASK 3 /* Mask for access mode bits */
  98. /* Individual flags */
  99. #define ACCESS_READ_WRITE 1 /* Allow read and write */
  100. #define ACCESS_CREATE 2 /* Create new file */
  101. /* Access mode combinations */
  102. #define OPEN_FOR_READ 0 /* open existing file for read-only */
  103. #define OPEN_FOR_UPDATE 1 /* open existing file for read/write access */
  104. #define OPEN_FOR_WRITE 3 /* create a new file, even if it exists */
  105. #define flOpenFile(ioreq) flCall(FL_OPEN_FILE,ioreq)
  106. /*----------------------------------------------------------------------*/
  107. /* f l C l o s e F i l e */
  108. /* */
  109. /* Closes an open file, records file size and dates in directory and */
  110. /* releases file handle. */
  111. /* */
  112. /* Parameters: */
  113. /* irHandle : Handle of file to close. */
  114. /* */
  115. /* Returns: */
  116. /* FLStatus : 0 on success, otherwise failed */
  117. /*----------------------------------------------------------------------*/
  118. #define flCloseFile(ioreq) flCall(FL_CLOSE_FILE,ioreq)
  119. #ifndef FL_READ_ONLY
  120. #ifdef SPLIT_JOIN_FILE
  121. /*------------------------------------------------------------------------*/
  122. /* f l S p l i t F i l e */
  123. /* */
  124. /* Splits the file into two files. The original file contains the first */
  125. /* part, and a new file (which is created for that purpose) contains */
  126. /* the second part. If the current position is on a cluster */
  127. /* boundary, the file will be split at the current position. Otherwise, */
  128. /* the cluster of the current position is duplicated, one copy is the */
  129. /* first cluster of the new file, and the other is the last cluster of the*/
  130. /* original file, which now ends at the current position. */
  131. /* */
  132. /* Parameters: */
  133. /* file : file to split. */
  134. /* irPath : Path name of the new file. */
  135. /* */
  136. /* Returns: */
  137. /* irHandle : handle of the new file. */
  138. /* FLStatus : 0 on success, otherwise failed. */
  139. /* */
  140. /*------------------------------------------------------------------------*/
  141. #define flSplitFile(ioreq) flCall(FL_SPLIT_FILE,ioreq)
  142. /*------------------------------------------------------------------------*/
  143. /* f l J o i n F i l e */
  144. /* */
  145. /* joins two files. If the end of the first file is on a cluster */
  146. /* boundary, the files will be joined there. Otherwise, the data in */
  147. /* the second file from the beginning until the offset that is equal to */
  148. /* the offset in cluster of the end of the first file will be lost. The */
  149. /* rest of the second file will be joined to the first file at the end of */
  150. /* the first file. On exit, the first file is the expanded file and the */
  151. /* second file is deleted. */
  152. /* Note: The second file will be open by this function, it is advised to */
  153. /* close it before calling this function in order to avoid */
  154. /* inconsistencies. */
  155. /* */
  156. /* Parameters: */
  157. /* file : file to join to. */
  158. /* irPath : Path name of the file to be joined. */
  159. /* */
  160. /* Return: */
  161. /* FLStatus : 0 on success, otherwise failed. */
  162. /* */
  163. /*------------------------------------------------------------------------*/
  164. #define flJoinFile(ioreq) flCall(FL_JOIN_FILE,ioreq)
  165. #endif /* SPLIT_JOIN_FILE */
  166. #endif /* FL_READ_ONLY */
  167. /*----------------------------------------------------------------------*/
  168. /* f l R e a d F i l e */
  169. /* */
  170. /* Reads from the current position in the file to the user-buffer. */
  171. /* Parameters: */
  172. /* irHandle : Handle of file to read. */
  173. /* irData : Address of user buffer */
  174. /* irLength : Number of bytes to read. If the read extends */
  175. /* beyond the end-of-file, the read is truncated */
  176. /* at the end-of-file. */
  177. /* */
  178. /* Returns: */
  179. /* FLStatus : 0 on success, otherwise failed */
  180. /* irLength : Actual number of bytes read */
  181. /*----------------------------------------------------------------------*/
  182. #define flReadFile(ioreq) flCall(FL_READ_FILE,ioreq)
  183. #ifndef FL_READ_ONLY
  184. /*----------------------------------------------------------------------*/
  185. /* f l W r i t e F i l e */
  186. /* */
  187. /* Writes from the current position in the file from the user-buffer. */
  188. /* */
  189. /* Parameters: */
  190. /* irHandle : Handle of file to write. */
  191. /* irData : Address of user buffer */
  192. /* irLength : Number of bytes to write. */
  193. /* */
  194. /* Returns: */
  195. /* FLStatus : 0 on success, otherwise failed */
  196. /* irLength : Actual number of bytes written */
  197. /*----------------------------------------------------------------------*/
  198. #define flWriteFile(ioreq) flCall(FL_WRITE_FILE,ioreq)
  199. #endif /* FL_READ_ONLY */
  200. /*----------------------------------------------------------------------*/
  201. /* f l S e e k F i l e */
  202. /* */
  203. /* Sets the current position in the file, relative to file start, end or*/
  204. /* current position. */
  205. /* Note: This function will not move the file pointer beyond the */
  206. /* beginning or end of file, so the actual file position may be */
  207. /* different from the required. The actual position is indicated on */
  208. /* return. */
  209. /* */
  210. /* Parameters: */
  211. /* irHandle : File handle to close. */
  212. /* irLength : Offset to set position. */
  213. /* irFlags : Method code */
  214. /* SEEK_START: absolute offset from start of file */
  215. /* SEEK_CURR: signed offset from current position */
  216. /* SEEK_END: signed offset from end of file */
  217. /* */
  218. /* Returns: */
  219. /* FLStatus : 0 on success, otherwise failed */
  220. /* irLength : Actual absolute offset from start of file */
  221. /*----------------------------------------------------------------------*/
  222. /** Values of irFlags for flSeekFile: */
  223. #define SEEK_START 0 /* offset from start of file */
  224. #define SEEK_CURR 1 /* offset from current position */
  225. #define SEEK_END 2 /* offset from end of file */
  226. #define flSeekFile(ioreq) flCall(FL_SEEK_FILE,ioreq)
  227. /*----------------------------------------------------------------------*/
  228. /* f l F i n d F i l e */
  229. /* */
  230. /* Finds a file entry in a directory, optionally modifying the file */
  231. /* time/date and/or attributes. */
  232. /* Files may be found by handle no. provided they are open, or by name. */
  233. /* Only the Hidden, System or Read-only attributes may be modified. */
  234. /* Entries may be found for any existing file or directory other than */
  235. /* the root. A DirectoryEntry structure describing the file is copied */
  236. /* to a user buffer. */
  237. /* */
  238. /* The DirectoryEntry structure is defined in dosformt.h */
  239. /* */
  240. /* Parameters: */
  241. /* irHandle : If by name: Drive number (0, 1, ...) */
  242. /* else : Handle of open file */
  243. /* irPath : If by name: Specifies a file or directory path*/
  244. /* irFlags : Options flags */
  245. /* FIND_BY_HANDLE: Find open file by handle. */
  246. /* Default is access by path. */
  247. /* SET_DATETIME: Update time/date from buffer */
  248. /* SET_ATTRIBUTES: Update attributes from buffer */
  249. /* irDirEntry : Address of user buffer to receive a */
  250. /* DirectoryEntry structure */
  251. /* */
  252. /* Returns: */
  253. /* irLength : Modified */
  254. /* FLStatus : 0 on success, otherwise failed */
  255. /*----------------------------------------------------------------------*/
  256. /** Bit assignment of irFlags for flFindFile: */
  257. #define SET_DATETIME 1 /* Change date/time */
  258. #define SET_ATTRIBUTES 2 /* Change attributes */
  259. #define FIND_BY_HANDLE 4 /* Find file by handle rather than by name */
  260. #define flFindFile(ioreq) flCall(FL_FIND_FILE,ioreq)
  261. /*----------------------------------------------------------------------*/
  262. /* f l F i n d F i r s t F i l e */
  263. /* */
  264. /* Finds the first file entry in a directory. */
  265. /* This function is used in combination with the flFindNextFile call, */
  266. /* which returns the remaining file entries in a directory sequentially.*/
  267. /* Entries are returned according to the unsorted directory order. */
  268. /* flFindFirstFile creates a file handle, which is returned by it. Calls*/
  269. /* to flFindNextFile will provide this file handle. When flFindNextFile */
  270. /* returns 'noMoreEntries', the file handle is automatically closed. */
  271. /* Alternatively the file handle can be closed by a 'closeFile' call */
  272. /* before actually reaching the end of directory. */
  273. /* A DirectoryEntry structure is copied to the user buffer describing */
  274. /* each file found. This structure is defined in dosformt.h. */
  275. /* */
  276. /* Parameters: */
  277. /* irHandle : Drive number (0, 1, ...) */
  278. /* irPath : Specifies a directory path */
  279. /* irData : Address of user buffer to receive a */
  280. /* DirectoryEntry structure */
  281. /* */
  282. /* Returns: */
  283. /* irHandle : File handle to use for subsequent operations. */
  284. /* FLStatus : 0 on success, otherwise failed */
  285. /*----------------------------------------------------------------------*/
  286. #define flFindFirstFile(ioreq) flCall(FL_FIND_FIRST_FILE,ioreq)
  287. /*----------------------------------------------------------------------*/
  288. /* f l F i n d N e x t F i l e */
  289. /* */
  290. /* See the description of 'flFindFirstFile'. */
  291. /* */
  292. /* Parameters: */
  293. /* irHandle : File handle returned by flFindFirstFile. */
  294. /* irData : Address of user buffer to receive a */
  295. /* DirectoryEntry structure */
  296. /* */
  297. /* Returns: */
  298. /* FLStatus : 0 on success, otherwise failed */
  299. /*----------------------------------------------------------------------*/
  300. #define flFindNextFile(ioreq) flCall(FL_FIND_NEXT_FILE,ioreq)
  301. /*----------------------------------------------------------------------*/
  302. /* f l G e t D i s k I n f o */
  303. /* */
  304. /* Returns general allocation information. */
  305. /* */
  306. /* The bytes/sector, sector/cluster, total cluster and free cluster */
  307. /* information are returned into a DiskInfo structure. */
  308. /* */
  309. /* Parameters: */
  310. /* irHandle : Drive number (0, 1, ...) */
  311. /* irData : Address of DiskInfo structure */
  312. /* */
  313. /* Returns: */
  314. /* FLStatus : 0 on success, otherwise failed */
  315. /*----------------------------------------------------------------------*/
  316. typedef struct {
  317. unsigned bytesPerSector;
  318. unsigned sectorsPerCluster;
  319. unsigned totalClusters;
  320. unsigned freeClusters;
  321. } DiskInfo;
  322. #define flGetDiskInfo(ioreq) flCall(FL_GET_DISK_INFO,ioreq)
  323. #ifndef FL_READ_ONLY
  324. /*----------------------------------------------------------------------*/
  325. /* f l D e l e t e F i l e */
  326. /* */
  327. /* Deletes a file. */
  328. /* */
  329. /* Parameters: */
  330. /* irHandle : Drive number (0, 1, ...) */
  331. /* irPath : path of file to delete */
  332. /* */
  333. /* Returns: */
  334. /* FLStatus : 0 on success, otherwise failed */
  335. /*----------------------------------------------------------------------*/
  336. #define flDeleteFile(ioreq) flCall(FL_DELETE_FILE,ioreq)
  337. #ifdef RENAME_FILE
  338. /*----------------------------------------------------------------------*/
  339. /* f l R e n a m e F i l e */
  340. /* */
  341. /* Renames a file to another name. */
  342. /* */
  343. /* Parameters: */
  344. /* irHandle : Drive number (0, 1, ...) */
  345. /* irPath : path of existing file */
  346. /* irData : path of new name. */
  347. /* */
  348. /* Returns: */
  349. /* FLStatus : 0 on success, otherwise failed */
  350. /*----------------------------------------------------------------------*/
  351. #define flRenameFile(ioreq) flCall(FL_RENAME_FILE,ioreq)
  352. #endif /* RENAME_FILE */
  353. #ifdef SUB_DIRECTORY
  354. /*----------------------------------------------------------------------*/
  355. /* f l M a k e D i r */
  356. /* */
  357. /* Creates a new directory. */
  358. /* */
  359. /* Parameters: */
  360. /* irHandle : Drive number (0, 1, ...) */
  361. /* irPath : path of new directory. */
  362. /* */
  363. /* Returns: */
  364. /* FLStatus : 0 on success, otherwise failed */
  365. /*----------------------------------------------------------------------*/
  366. #define flMakeDir(ioreq) flCall(FL_MAKE_DIR,ioreq)
  367. /*----------------------------------------------------------------------*/
  368. /* f l R e m o v e D i r */
  369. /* */
  370. /* Removes an empty directory. */
  371. /* */
  372. /* Parameters: */
  373. /* irHandle : Drive number (0, 1, ...) */
  374. /* irPath : path of directory to remove. */
  375. /* */
  376. /* Returns: */
  377. /* FLStatus : 0 on success, otherwise failed */
  378. /*----------------------------------------------------------------------*/
  379. #define flRemoveDir(ioreq) flCall(FL_REMOVE_DIR,ioreq)
  380. #endif /* SUB_DIRECTORY */
  381. #endif /* FL_READ_ONLY */
  382. #endif /* FILES > 0 */
  383. #ifdef PARSE_PATH
  384. /*----------------------------------------------------------------------*/
  385. /* f l P a r s e P a t h */
  386. /* */
  387. /* Converts a DOS-like path string to a simple-path array. */
  388. /* */
  389. /* Note: Array length received in irPath must be greater than the */
  390. /* number of path components in the path to convert. */
  391. /* */
  392. /* Parameters: */
  393. /* irHandle : Drive number (0, 1, ...) */
  394. /* irData : address of path string to convert */
  395. /* irPath : address of array to receive parsed-path. */
  396. /* */
  397. /* Returns: */
  398. /* FLStatus : 0 on success, otherwise failed */
  399. /*----------------------------------------------------------------------*/
  400. extern FLStatus flParsePath(IOreq FAR2 *ioreq);
  401. #endif /* PARSE_PATH */
  402. #endif