2N/A/* ntfs.h - header for the NTFS filesystem */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2007,2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#ifndef GRUB_NTFS_H
2N/A#define GRUB_NTFS_H 1
2N/A
2N/Aenum
2N/A {
2N/A GRUB_NTFS_FILE_MFT = 0,
2N/A GRUB_NTFS_FILE_MFTMIRR = 1,
2N/A GRUB_NTFS_FILE_LOGFILE = 2,
2N/A GRUB_NTFS_FILE_VOLUME = 3,
2N/A GRUB_NTFS_FILE_ATTRDEF = 4,
2N/A GRUB_NTFS_FILE_ROOT = 5,
2N/A GRUB_NTFS_FILE_BITMAP = 6,
2N/A GRUB_NTFS_FILE_BOOT = 7,
2N/A GRUB_NTFS_FILE_BADCLUS = 8,
2N/A GRUB_NTFS_FILE_QUOTA = 9,
2N/A GRUB_NTFS_FILE_UPCASE = 10,
2N/A };
2N/A
2N/Aenum
2N/A {
2N/A GRUB_NTFS_AT_STANDARD_INFORMATION = 0x10,
2N/A GRUB_NTFS_AT_ATTRIBUTE_LIST = 0x20,
2N/A GRUB_NTFS_AT_FILENAME = 0x30,
2N/A GRUB_NTFS_AT_OBJECT_ID = 0x40,
2N/A GRUB_NTFS_AT_SECURITY_DESCRIPTOR = 0x50,
2N/A GRUB_NTFS_AT_VOLUME_NAME = 0x60,
2N/A GRUB_NTFS_AT_VOLUME_INFORMATION = 0x70,
2N/A GRUB_NTFS_AT_DATA = 0x80,
2N/A GRUB_NTFS_AT_INDEX_ROOT = 0x90,
2N/A GRUB_NTFS_AT_INDEX_ALLOCATION = 0xA0,
2N/A GRUB_NTFS_AT_BITMAP = 0xB0,
2N/A GRUB_NTFS_AT_SYMLINK = 0xC0,
2N/A GRUB_NTFS_AT_EA_INFORMATION = 0xD0,
2N/A GRUB_NTFS_AT_EA = 0xE0,
2N/A };
2N/A
2N/Aenum
2N/A {
2N/A GRUB_NTFS_ATTR_READ_ONLY = 0x1,
2N/A GRUB_NTFS_ATTR_HIDDEN = 0x2,
2N/A GRUB_NTFS_ATTR_SYSTEM = 0x4,
2N/A GRUB_NTFS_ATTR_ARCHIVE = 0x20,
2N/A GRUB_NTFS_ATTR_DEVICE = 0x40,
2N/A GRUB_NTFS_ATTR_NORMAL = 0x80,
2N/A GRUB_NTFS_ATTR_TEMPORARY = 0x100,
2N/A GRUB_NTFS_ATTR_SPARSE = 0x200,
2N/A GRUB_NTFS_ATTR_REPARSE = 0x400,
2N/A GRUB_NTFS_ATTR_COMPRESSED = 0x800,
2N/A GRUB_NTFS_ATTR_OFFLINE = 0x1000,
2N/A GRUB_NTFS_ATTR_NOT_INDEXED = 0x2000,
2N/A GRUB_NTFS_ATTR_ENCRYPTED = 0x4000,
2N/A GRUB_NTFS_ATTR_DIRECTORY = 0x10000000,
2N/A GRUB_NTFS_ATTR_INDEX_VIEW = 0x20000000
2N/A };
2N/A
2N/Aenum
2N/A {
2N/A GRUB_NTFS_FLAG_COMPRESSED = 1,
2N/A GRUB_NTFS_FLAG_ENCRYPTED = 0x4000,
2N/A GRUB_NTFS_FLAG_SPARSE = 0x8000
2N/A };
2N/A
2N/A#define GRUB_NTFS_BLK_SHR GRUB_DISK_SECTOR_BITS
2N/A
2N/A#define GRUB_NTFS_MAX_MFT (1024 >> GRUB_NTFS_BLK_SHR)
2N/A#define GRUB_NTFS_MAX_IDX (16384 >> GRUB_NTFS_BLK_SHR)
2N/A
2N/A#define GRUB_NTFS_COM_LEN 4096
2N/A#define GRUB_NTFS_COM_LOG_LEN 12
2N/A#define GRUB_NTFS_COM_SEC (GRUB_NTFS_COM_LEN >> GRUB_NTFS_BLK_SHR)
2N/A
2N/Aenum
2N/A {
2N/A GRUB_NTFS_AF_ALST = 1,
2N/A GRUB_NTFS_AF_MMFT = 2,
2N/A GRUB_NTFS_AF_GPOS = 4,
2N/A };
2N/A
2N/Aenum
2N/A {
2N/A GRUB_NTFS_RF_COMP = 1,
2N/A GRUB_NTFS_RF_CBLK = 2,
2N/A GRUB_NTFS_RF_BLNK = 4
2N/A };
2N/A
2N/Astruct grub_ntfs_bpb
2N/A{
2N/A grub_uint8_t jmp_boot[3];
2N/A grub_uint8_t oem_name[8];
2N/A grub_uint16_t bytes_per_sector;
2N/A grub_uint8_t sectors_per_cluster;
2N/A grub_uint8_t reserved_1[7];
2N/A grub_uint8_t media;
2N/A grub_uint16_t reserved_2;
2N/A grub_uint16_t sectors_per_track;
2N/A grub_uint16_t num_heads;
2N/A grub_uint32_t num_hidden_sectors;
2N/A grub_uint32_t reserved_3;
2N/A grub_uint8_t bios_drive;
2N/A grub_uint8_t reserved_4[3];
2N/A grub_uint64_t num_total_sectors;
2N/A grub_uint64_t mft_lcn;
2N/A grub_uint64_t mft_mirr_lcn;
2N/A grub_int8_t clusters_per_mft;
2N/A grub_int8_t reserved_5[3];
2N/A grub_int8_t clusters_per_index;
2N/A grub_int8_t reserved_6[3];
2N/A grub_uint64_t num_serial;
2N/A grub_uint32_t checksum;
2N/A} __attribute__ ((packed));
2N/A
2N/Astruct grub_ntfs_attr
2N/A{
2N/A int flags;
2N/A char *emft_buf, *edat_buf;
2N/A char *attr_cur, *attr_nxt, *attr_end;
2N/A grub_uint32_t save_pos;
2N/A char *sbuf;
2N/A struct grub_ntfs_file *mft;
2N/A};
2N/A
2N/Astruct grub_ntfs_file
2N/A{
2N/A struct grub_ntfs_data *data;
2N/A char *buf;
2N/A grub_uint64_t size;
2N/A grub_uint64_t mtime;
2N/A grub_uint32_t ino;
2N/A int inode_read;
2N/A struct grub_ntfs_attr attr;
2N/A};
2N/A
2N/Astruct grub_ntfs_data
2N/A{
2N/A struct grub_ntfs_file cmft;
2N/A struct grub_ntfs_file mmft;
2N/A grub_disk_t disk;
2N/A grub_uint32_t mft_size;
2N/A grub_uint32_t idx_size;
2N/A grub_uint32_t spc;
2N/A grub_uint32_t blocksize;
2N/A grub_uint32_t mft_start;
2N/A grub_uint64_t uuid;
2N/A};
2N/A
2N/Astruct grub_ntfs_comp
2N/A{
2N/A grub_disk_t disk;
2N/A int comp_head, comp_tail;
2N/A grub_uint32_t comp_table[16][2];
2N/A grub_uint32_t cbuf_ofs, cbuf_vcn, spc;
2N/A char *cbuf;
2N/A};
2N/A
2N/Astruct grub_ntfs_rlst
2N/A{
2N/A int flags;
2N/A grub_disk_addr_t target_vcn, curr_vcn, next_vcn, curr_lcn;
2N/A char *cur_run;
2N/A struct grub_ntfs_attr *attr;
2N/A struct grub_ntfs_comp comp;
2N/A};
2N/A
2N/Atypedef grub_err_t (*grub_ntfscomp_func_t) (struct grub_ntfs_attr * at,
2N/A char *dest,
2N/A grub_uint32_t ofs,
2N/A grub_uint32_t len,
2N/A struct grub_ntfs_rlst * ctx,
2N/A grub_uint32_t vcn);
2N/A
2N/Aextern grub_ntfscomp_func_t grub_ntfscomp_func;
2N/A
2N/Agrub_err_t grub_ntfs_read_run_list (struct grub_ntfs_rlst *ctx);
2N/A
2N/A#endif /* ! GRUB_NTFS_H */