diff options
author | Stef Walter <stef@thewalter.net> | 2004-04-01 04:35:55 +0000 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2004-04-01 04:35:55 +0000 |
commit | de5167a304b5e3b2db7462329334ac01d492d72c (patch) | |
tree | f091b1c7679c9120579875d17bbf7295a4ccbc9f /src/drive.h | |
parent | 048987b4e95b70a4559b9163d90e57dd69097203 (diff) |
- Fixes all round
- Uncontiguous FAT
- Move to C (instead of C++)
- Preparing for porting
Diffstat (limited to 'src/drive.h')
-rw-r--r-- | src/drive.h | 139 |
1 files changed, 67 insertions, 72 deletions
diff --git a/src/drive.h b/src/drive.h index f0df9f1..4c52584 100644 --- a/src/drive.h +++ b/src/drive.h @@ -1,94 +1,89 @@ -// -// AUTHOR -// N. Nielsen -// -// VERSION -// 0.7 -// -// LICENSE -// This software is in the public domain. -// -// The software is provided "as is", without warranty of any kind, -// express or implied, including but not limited to the warranties -// of merchantability, fitness for a particular purpose, and -// noninfringement. In no event shall the author(s) be liable for any -// claim, damages, or other liability, whether in an action of -// contract, tort, or otherwise, arising from, out of, or in connection -// with the software or the use or other dealings in the software. -// -// SUPPORT -// Send bug reports to: <nielsen@memberwebs.com> -// - +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ #ifndef __DRIVE_H__20010822 #define __DRIVE_H__20010822 #include "usuals.h" -const uint16 kSectorSize = 0x200; -const uint64 kInvalidSector = 0xFFFFFFFFFFFFFFFF; -struct DriveLock; - -struct PartitionInfo -{ - uint32 firstSector; - uint32 lastSector; - uint32 offMFT; // In sectors - byte clusterSize; // In sectors - - DriveLock* pLocks; - uint32 cLocks; - uint32 curLock; -}; +#define kSectorSize 0x200 +#define kInvalidSector 0xFFFFFFFFFFFFFFFF -PartitionInfo* CreatePartitionInfo(); -void FreePartitionInfo(PartitionInfo* pInfo); +typedef struct _ntfsx_mftmap ntfsx_mftmap; +typedef struct _drivelocks drivelocks; +typedef struct _partitioninfo +{ + uint32 first; /* The first sector (in sectors) */ + uint32 end; /* The end sector (in sectors) */ + uint32 mft; /* Offset into the MFT (in sectors) */ + byte cluster; /* Cluster size (in sectors) */ + int device; /* A handle to an open device */ + + /* Some other context stuff about the drive */ + drivelocks* locks; + ntfsx_mftmap* mftmap; +} +partitioninfo; #pragma pack(push, drive) #pragma pack(1) -const byte kPartition_Invalid = 0; -const byte kPartition_Extended = 5; -const byte kPartition_ExtendedLBA = 15; +#define kPartition_Invalid 0 +#define kPartition_Extended 5 +#define kPartition_ExtendedLBA 15 -// Partition table entry -struct Drive_PartEntry +/* Partition table entry */ +typedef struct _drive_partentry { - byte active; // partition bootable flag - byte starthead; // starting head - byte startsector; // starting sector and 2 MS bits of cylinder - byte startcylinder; // starting cylinder (low 8 bits) - byte system; // partition type - byte endhead; // ending head - byte endsector; // ending sector and 2 MS bits of cylinder - byte endcylinder; // ending cylinder (low 8 bits) - uint32 startsec; // absolute starting sector - uint32 endsec; // absolute ending sector -}; - -const uint16 kMBR_Sig = 0xAA55; - -// Master Boot Record -struct Drive_MBR + byte active; /* partition bootable flag */ + byte starthead; /* starting head */ + byte startsector; /* starting sector and 2 MS bits of cylinder */ + byte startcylinder; /* starting cylinder (low 8 bits) */ + byte system; /* partition type */ + byte endhead; /* ending head */ + byte endsector; /* ending sector and 2 MS bits of cylinder */ + byte endcylinder; /* ending cylinder (low 8 bits) */ + uint32 startsec; /* absolute starting sector */ + uint32 endsec; /* absolute ending sector */ +} +drive_partentry; + +#define kMBR_Sig 0xAA55 + +/* Master Boot Record */ +typedef struct _drive_mbr { - byte fill[0x1be]; // boot code - Drive_PartEntry partitions[4]; // partition table - uint16 sig; // 55AAh boot signature -}; + byte fill[0x1be]; /* boot code */ + drive_partentry partitions[4]; /* partition table */ + uint16 sig; /* 55AAh boot signature */ +} +drive_mbr; #pragma pack(pop, drive) -#define CLUSTER_TO_SECTOR(info, clus) (((clus) * (info).clusterSize) + (info).firstSector) +#define CLUSTER_TO_SECTOR(info, clus) (((clus) * (info).cluster) + (info).first) #define SECTOR_TO_BYTES(sec) ((sec) * kSectorSize) -#define CLUSTER_SIZE(info) ((info).clusterSize * kSectorSize) - -bool IntersectRange(uint64& b1, uint64& e1, uint64 b2, uint64 e2); -void AddLocationLock(PartitionInfo* pInfo, uint64 beg, uint64 end); -bool CheckLocationLock(PartitionInfo* pInfo, uint64& sec); - +#define CLUSTER_SIZE(info) ((info).cluster * kSectorSize) +/* driveName should be MAX_PATH chars long */ +void makeDriveName(char* driveName, int i); -#endif //__DRIVE_H__20010822
\ No newline at end of file +#endif /* __DRIVE_H__ */ |