mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-08-04 01:36:10 -04:00
Cleanup FAT32
This commit is contained in:
parent
06b700d0c5
commit
51a3d34004
@ -14,86 +14,10 @@
|
|||||||
|
|
||||||
#include "disks.hpp"
|
#include "disks.hpp"
|
||||||
#include "file_system.hpp"
|
#include "file_system.hpp"
|
||||||
|
#include "fat32_specs.hpp"
|
||||||
|
|
||||||
namespace fat32 {
|
namespace fat32 {
|
||||||
|
|
||||||
//FAT 32 Boot Sector
|
|
||||||
struct fat_bs_t {
|
|
||||||
uint8_t jump[3];
|
|
||||||
char oem_name[8];
|
|
||||||
uint16_t bytes_per_sector;
|
|
||||||
uint8_t sectors_per_cluster;
|
|
||||||
uint16_t reserved_sectors;
|
|
||||||
uint8_t number_of_fat;
|
|
||||||
uint16_t root_directories_entries;
|
|
||||||
uint16_t total_sectors;
|
|
||||||
uint8_t media_descriptor;
|
|
||||||
uint16_t sectors_per_fat;
|
|
||||||
uint16_t sectors_per_track;
|
|
||||||
uint16_t heads;
|
|
||||||
uint32_t hidden_sectors;
|
|
||||||
uint32_t total_sectors_long;
|
|
||||||
uint32_t sectors_per_fat_long;
|
|
||||||
uint16_t drive_description;
|
|
||||||
uint16_t version;
|
|
||||||
uint32_t root_directory_cluster_start;
|
|
||||||
uint16_t fs_information_sector;
|
|
||||||
uint16_t boot_sectors_copy_sector;
|
|
||||||
uint8_t filler[12];
|
|
||||||
uint8_t physical_drive_number;
|
|
||||||
uint8_t reserved;
|
|
||||||
uint8_t extended_boot_signature;
|
|
||||||
uint32_t volume_id;
|
|
||||||
char volume_label[11];
|
|
||||||
char file_system_type[8];
|
|
||||||
uint8_t boot_code[420];
|
|
||||||
uint16_t signature;
|
|
||||||
}__attribute__ ((packed));
|
|
||||||
|
|
||||||
//FAT 32 Information sector
|
|
||||||
struct fat_is_t {
|
|
||||||
uint32_t signature_start;
|
|
||||||
uint8_t reserved[480];
|
|
||||||
uint32_t signature_middle;
|
|
||||||
uint32_t free_clusters;
|
|
||||||
uint32_t allocated_clusters;
|
|
||||||
uint8_t reserved_2[12];
|
|
||||||
uint32_t signature_end;
|
|
||||||
}__attribute__ ((packed));
|
|
||||||
|
|
||||||
static_assert(sizeof(fat_bs_t) == 512, "FAT Boot Sector is exactly one disk sector");
|
|
||||||
|
|
||||||
//An entry in the directory cluster
|
|
||||||
struct cluster_entry {
|
|
||||||
char name[11];
|
|
||||||
uint8_t attrib;
|
|
||||||
uint8_t reserved;
|
|
||||||
uint8_t creation_time_seconds;
|
|
||||||
uint16_t creation_time;
|
|
||||||
uint16_t creation_date;
|
|
||||||
uint16_t accessed_date;
|
|
||||||
uint16_t cluster_high;
|
|
||||||
uint16_t modification_time;
|
|
||||||
uint16_t modification_date;
|
|
||||||
uint16_t cluster_low;
|
|
||||||
uint32_t file_size;
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
//A long file name text entry in the directory cluster
|
|
||||||
struct long_entry {
|
|
||||||
uint8_t sequence_number;
|
|
||||||
uint16_t name_first[5];
|
|
||||||
uint8_t attrib;
|
|
||||||
uint8_t reserved;
|
|
||||||
uint8_t alias_checksum;
|
|
||||||
uint16_t name_second[6];
|
|
||||||
uint16_t starting_cluster;
|
|
||||||
uint16_t name_third[2];
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
static_assert(sizeof(cluster_entry) == 32, "A cluster entry is 32 bytes");
|
|
||||||
static_assert(sizeof(long_entry) == 32, "A cluster entry is 32 bytes");
|
|
||||||
|
|
||||||
typedef const disks::disk_descriptor& dd;
|
typedef const disks::disk_descriptor& dd;
|
||||||
|
|
||||||
struct fat32_file_system : vfs::file_system {
|
struct fat32_file_system : vfs::file_system {
|
||||||
|
94
kernel/include/fat32_specs.hpp
Normal file
94
kernel/include/fat32_specs.hpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
//=======================================================================
|
||||||
|
// Copyright Baptiste Wicht 2013-2014.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
#ifndef FAT32_SPECS_H
|
||||||
|
#define FAT32_SPECS_H
|
||||||
|
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
|
namespace fat32 {
|
||||||
|
|
||||||
|
//FAT 32 Boot Sector
|
||||||
|
struct fat_bs_t {
|
||||||
|
uint8_t jump[3];
|
||||||
|
char oem_name[8];
|
||||||
|
uint16_t bytes_per_sector;
|
||||||
|
uint8_t sectors_per_cluster;
|
||||||
|
uint16_t reserved_sectors;
|
||||||
|
uint8_t number_of_fat;
|
||||||
|
uint16_t root_directories_entries;
|
||||||
|
uint16_t total_sectors;
|
||||||
|
uint8_t media_descriptor;
|
||||||
|
uint16_t sectors_per_fat;
|
||||||
|
uint16_t sectors_per_track;
|
||||||
|
uint16_t heads;
|
||||||
|
uint32_t hidden_sectors;
|
||||||
|
uint32_t total_sectors_long;
|
||||||
|
uint32_t sectors_per_fat_long;
|
||||||
|
uint16_t drive_description;
|
||||||
|
uint16_t version;
|
||||||
|
uint32_t root_directory_cluster_start;
|
||||||
|
uint16_t fs_information_sector;
|
||||||
|
uint16_t boot_sectors_copy_sector;
|
||||||
|
uint8_t filler[12];
|
||||||
|
uint8_t physical_drive_number;
|
||||||
|
uint8_t reserved;
|
||||||
|
uint8_t extended_boot_signature;
|
||||||
|
uint32_t volume_id;
|
||||||
|
char volume_label[11];
|
||||||
|
char file_system_type[8];
|
||||||
|
uint8_t boot_code[420];
|
||||||
|
uint16_t signature;
|
||||||
|
}__attribute__ ((packed));
|
||||||
|
|
||||||
|
//FAT 32 Information sector
|
||||||
|
struct fat_is_t {
|
||||||
|
uint32_t signature_start;
|
||||||
|
uint8_t reserved[480];
|
||||||
|
uint32_t signature_middle;
|
||||||
|
uint32_t free_clusters;
|
||||||
|
uint32_t allocated_clusters;
|
||||||
|
uint8_t reserved_2[12];
|
||||||
|
uint32_t signature_end;
|
||||||
|
}__attribute__ ((packed));
|
||||||
|
|
||||||
|
static_assert(sizeof(fat_bs_t) == 512, "FAT Boot Sector is exactly one disk sector");
|
||||||
|
|
||||||
|
//An entry in the directory cluster
|
||||||
|
struct cluster_entry {
|
||||||
|
char name[11];
|
||||||
|
uint8_t attrib;
|
||||||
|
uint8_t reserved;
|
||||||
|
uint8_t creation_time_seconds;
|
||||||
|
uint16_t creation_time;
|
||||||
|
uint16_t creation_date;
|
||||||
|
uint16_t accessed_date;
|
||||||
|
uint16_t cluster_high;
|
||||||
|
uint16_t modification_time;
|
||||||
|
uint16_t modification_date;
|
||||||
|
uint16_t cluster_low;
|
||||||
|
uint32_t file_size;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
//A long file name text entry in the directory cluster
|
||||||
|
struct long_entry {
|
||||||
|
uint8_t sequence_number;
|
||||||
|
uint16_t name_first[5];
|
||||||
|
uint8_t attrib;
|
||||||
|
uint8_t reserved;
|
||||||
|
uint8_t alias_checksum;
|
||||||
|
uint16_t name_second[6];
|
||||||
|
uint16_t starting_cluster;
|
||||||
|
uint16_t name_third[2];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
static_assert(sizeof(cluster_entry) == 32, "A cluster entry is 32 bytes");
|
||||||
|
static_assert(sizeof(long_entry) == 32, "A cluster entry is 32 bytes");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user