Source code of Windows XP (NT5)
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.

166 lines
5.9 KiB

  1. /*******************************************************************************
  2. * *
  3. * M-Systems Confidential *
  4. * Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 *
  5. * All Rights Reserved *
  6. * *
  7. *******************************************************************************
  8. * *
  9. * NOTICE OF M-SYSTEMS OEM *
  10. * SOFTWARE LICENSE AGREEMENT *
  11. * *
  12. * THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE AGREEMENT *
  13. * BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT FOR THE SPECIFIC *
  14. * TERMS AND CONDITIONS OF USE, OR CONTACT M-SYSTEMS FOR LICENSE *
  15. * ASSISTANCE: *
  16. * E-MAIL = info@m-sys.com *
  17. * *
  18. *******************************************************************************
  19. * *
  20. * Module: FATFILT *
  21. * *
  22. * This module implements installable FAT12/16 filters. It supports up to *
  23. * SOCKETS sockets, with up to FL_MAX_DISKS_PER_SOCKET disks per socket. *
  24. * Each disk can contain up to FL_MAX_PARTS_PER_DISK partitions on it, with *
  25. * maximum depth of partition nesting in extended partitions equal to *
  26. * MAX_PARTITION_DEPTH. *
  27. * *
  28. * In order for this module to work, disks must be abs.mounted rather then *
  29. * mounted. In latter case, this module won't detect any of disk's *
  30. * partitions, and won't install FAT filters. *
  31. * *
  32. * This module uses more then 512 bytes of stack space in case if MALLOC is *
  33. * not enabled. *
  34. * *
  35. *******************************************************************************/
  36. /*
  37. * $Log: V:/Flite/archives/TrueFFS5/Src/FATFILT.H_V $
  38. *
  39. * Rev 1.3 Apr 10 2001 23:54:52 oris
  40. * Removed FL_MAX_DISKS_PER_SOCKET definition.
  41. *
  42. * Rev 1.2 Apr 09 2001 15:01:00 oris
  43. * Change static allocation to dynamic allocations.
  44. *
  45. * Rev 1.1 Apr 01 2001 07:51:24 oris
  46. * New implementation of fat filter.
  47. *
  48. * Rev 1.0 19 Feb 2001 21:16:14 andreyk
  49. * Initial revision.
  50. */
  51. #ifndef FLFF_H
  52. #define FLFF_H
  53. #include "dosformt.h"
  54. #include "flreq.h"
  55. /* number of entries in disk's partition table */
  56. #define FL_PART_TBL_ENTRIES 4
  57. /* max number of partitions (filesystem volumes) per disk */
  58. #define FL_MAX_PARTS_PER_DISK (FL_PART_TBL_ENTRIES + MAX_PARTITION_DEPTH)
  59. /*
  60. * Generic 'initialization status' type
  61. */
  62. typedef enum {
  63. flStateNotInitialized = 0,
  64. flStateInitInProgress = 1,
  65. flStateInitialized = 2
  66. } FLState;
  67. /*
  68. * Disk partition (filesystem volume). Multiple partitions are allowed
  69. * on the disk.
  70. */
  71. typedef struct {
  72. int handle; /* disk's TFFS handle */
  73. int type; /* FAT16_PARTIT */
  74. int flags; /* VOLUME_12BIT_FAT etc. */
  75. FLBoolean ffEnabled; /* FAT filter is enabled on that part. */
  76. SectorNo startSecNo; /* sectorNo where partition starts */
  77. SectorNo sectors; /* (info) total sectors in partition */
  78. SectorNo firstFATsecNo; /* sectorNo of 1st sector of 1st FAT */
  79. SectorNo lastFATsecNo; /* sectorNo of last sector of 1st FAT */
  80. SectorNo firstDataSecNo;
  81. unsigned clusterSize; /* Cluster size in sectors */
  82. } FLffVol;
  83. /*
  84. * Disk with multiple partitions. Multiple disks are allowed on socket.
  85. */
  86. typedef struct {
  87. int handle; /* disk's TFFS handle */
  88. FLState ffstate; /* FAT filter init. state */
  89. int parts; /* total FAT12/16 partitions found */
  90. FLffVol * part[FL_MAX_PARTS_PER_DISK];
  91. SectorNo secToWatch; /* used to track disk partitioning */
  92. char * buf; /* scratch buffer */
  93. } FLffDisk;
  94. /*
  95. * Master Boot Record/Extended Boot Record of the disk
  96. */
  97. typedef struct {
  98. char reserved[0x1be];
  99. struct {
  100. unsigned char activeFlag; /* 80h = bootable */
  101. unsigned char startingHead;
  102. LEushort startingCylinderSector;
  103. char type;
  104. unsigned char endingHead;
  105. LEushort endingCylinderSector;
  106. Unaligned4 startingSectorOfPartition;
  107. Unaligned4 sectorsInPartition;
  108. } parts [FL_PART_TBL_ENTRIES];
  109. LEushort signature; /* = PARTITION_SIGNATURE */
  110. } flMBR;
  111. /*
  112. * FAT Filter API
  113. */
  114. #if defined(ABS_READ_WRITE) && !defined(FL_READ_ONLY)
  115. extern FLStatus ffCheckBeforeWrite (IOreq FAR2 *ioreq);
  116. extern FLStatus flffControl (int devNo, int partNo, FLState state);
  117. extern FLffDisk* flffInfo (int devNo);
  118. #endif
  119. #endif /* FLFF_H */