mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-04 14:11:58 +03:00
72 lines
1.8 KiB
C
72 lines
1.8 KiB
C
#ifndef __FS__NTFS_H__
|
|
#define __FS__NTFS_H__
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
#include <lib/part.h>
|
|
#include <lib/blib.h>
|
|
|
|
struct ntfs_bpb {
|
|
uint8_t jump[3];
|
|
char oem[8];
|
|
uint16_t bytes_per_sector;
|
|
uint8_t sectors_per_cluster;
|
|
uint16_t reserved_sectors;
|
|
uint8_t fats_count;
|
|
uint16_t directory_entries_count;
|
|
uint16_t sector_totals;
|
|
uint8_t media_descriptor_type;
|
|
uint16_t sectors_per_fat_16;
|
|
uint16_t sectors_per_track;
|
|
uint16_t heads_count;
|
|
uint32_t hidden_sectors_count;
|
|
uint32_t large_sectors_count;
|
|
|
|
// ntfs
|
|
uint32_t sectors_per_fat_32;
|
|
uint64_t sectors_count_64;
|
|
uint64_t mft_cluster;
|
|
} __attribute__((packed));
|
|
|
|
struct ntfs_file_handle {
|
|
struct volume *part;
|
|
|
|
struct ntfs_bpb bpb;
|
|
|
|
// file record sizes
|
|
uint64_t file_record_size;
|
|
uint64_t sectors_per_file_record;
|
|
|
|
// MFT info, the offset and its runlist
|
|
uint64_t mft_offset;
|
|
uint8_t mft_run_list[256];
|
|
|
|
// the runlist of the open file/directory
|
|
uint8_t run_list[128];
|
|
|
|
// The resident index, only for directories,
|
|
// could be at the same time as a runlist
|
|
uint8_t resident_index_size;
|
|
|
|
// the resident data
|
|
uint8_t resident_data_size;
|
|
|
|
// we are using a union just for having different names, these
|
|
// won't have need to be used at the same time
|
|
union {
|
|
uint8_t resident_index[1024];
|
|
uint8_t resident_data[1024];
|
|
};
|
|
|
|
// info about the current file
|
|
uint32_t size_bytes;
|
|
};
|
|
|
|
int ntfs_check_signature(struct volume *part);
|
|
|
|
bool ntfs_open(struct ntfs_file_handle *ret, struct volume *part, const char *path);
|
|
int ntfs_read(struct ntfs_file_handle *file, void *buf, uint64_t loc, uint64_t count);
|
|
void ntfs_close(struct ntfs_file_handle *file);
|
|
|
|
#endif |