Definitions.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) 2022, Undefine <undefine@undefine.pl>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DOSPackedTime.h>
  8. #include <AK/EnumBits.h>
  9. #include <AK/Types.h>
  10. namespace Kernel {
  11. struct [[gnu::packed]] FAT32BootRecord {
  12. u8 boot_jump[3];
  13. char oem_identifier[8];
  14. u16 bytes_per_sector;
  15. u8 sectors_per_cluster;
  16. u16 reserved_sector_count;
  17. u8 fat_count;
  18. u16 root_directory_entry_count;
  19. u16 unused1;
  20. u8 media_descriptor_type;
  21. u16 unused2;
  22. u16 sectors_per_track;
  23. u16 head_count;
  24. u32 hidden_sector_count;
  25. u32 sector_count;
  26. u32 sectors_per_fat;
  27. u16 flags;
  28. u16 fat_version;
  29. u32 root_directory_cluster;
  30. u16 fs_info_sector;
  31. u16 backup_boot_sector;
  32. u8 unused3[12];
  33. u8 drive_number;
  34. u8 unused4;
  35. u8 signature;
  36. u32 volume_id;
  37. char volume_label_string[11];
  38. char system_identifier_string[8];
  39. };
  40. static_assert(sizeof(FAT32BootRecord) == 90);
  41. enum class FATAttributes : u8 {
  42. ReadOnly = 0x01,
  43. Hidden = 0x02,
  44. System = 0x04,
  45. VolumeID = 0x08,
  46. Directory = 0x10,
  47. Archive = 0x20,
  48. LongFileName = 0x0F
  49. };
  50. AK_ENUM_BITWISE_OPERATORS(FATAttributes);
  51. struct [[gnu::packed]] FATEntry {
  52. char filename[8];
  53. char extension[3];
  54. FATAttributes attributes;
  55. u8 unused1;
  56. u8 creation_time_seconds;
  57. DOSPackedTime creation_time;
  58. DOSPackedDate creation_date;
  59. DOSPackedDate last_accessed_date;
  60. u16 first_cluster_high;
  61. DOSPackedTime modification_time;
  62. DOSPackedDate modification_date;
  63. u16 first_cluster_low;
  64. u32 file_size;
  65. };
  66. static_assert(sizeof(FATEntry) == 32);
  67. struct [[gnu::packed]] FATLongFileNameEntry {
  68. u8 entry_index;
  69. u16 characters1[5];
  70. FATAttributes attributes;
  71. u8 entry_type;
  72. u8 checksum;
  73. u16 characters2[6];
  74. u16 zero;
  75. u16 characters3[2];
  76. };
  77. static_assert(sizeof(FATLongFileNameEntry) == 32);
  78. }