📄 fs_types.h
字号:
/* * GRUB -- GRand Unified Bootloader * Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc. * Copyright 2006-2007 Pawel Kolodziejski - adopted to linux native bootloader * * GRUB is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GRUB; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#ifndef __GRUB_TYPES_H__#define __GRUB_TYPES_H__//#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2)))#define NESTED_FUNC_ATTR/* cylinder/head/sector address */typedef struct _chs_ { int c, h, s;} chs_t;/* partition descriptor */typedef struct _pentry_ { unsigned char boot; chs_t begin; unsigned char type; chs_t end; int sector_start; int sector_length;} pentry_t;#define GRUB_DISK_SECTOR_BITS 9#define GRUB_DISK_SECTOR_SIZE (1 << GRUB_DISK_SECTOR_BITS)#define GRUB_DISK_SECTOR_MASK (GRUB_DISK_SECTOR_SIZE - 1)typedef signed char grub_int8_t;typedef short grub_int16_t;typedef int grub_int32_t;typedef long long grub_int64_t;typedef unsigned char grub_uint8_t;typedef unsigned short grub_uint16_t;typedef unsigned grub_uint32_t;typedef unsigned long long grub_uint64_t;typedef grub_uint32_t grub_target_addr_t;typedef grub_uint32_t grub_target_off_t;typedef grub_uint32_t grub_target_size_t;typedef grub_int32_t grub_target_ssize_t;typedef grub_uint32_t grub_addr_t;typedef grub_uint32_t grub_size_t;typedef grub_int32_t grub_ssize_t; /* The type for representing a file offset. */typedef grub_uint64_t grub_off_t;/* The type for representing a disk block address. */typedef grub_uint64_t grub_disk_addr_t;typedef enum { GRUB_ERR_NONE = 0, GRUB_ERR_TEST_FAILURE, GRUB_ERR_BAD_MODULE, GRUB_ERR_OUT_OF_MEMORY, GRUB_ERR_BAD_FILE_TYPE, GRUB_ERR_FILE_NOT_FOUND, GRUB_ERR_FILE_READ_ERROR, GRUB_ERR_BAD_FILENAME, GRUB_ERR_UNKNOWN_FS, GRUB_ERR_BAD_FS, GRUB_ERR_BAD_NUMBER, GRUB_ERR_OUT_OF_RANGE, GRUB_ERR_UNKNOWN_DEVICE, GRUB_ERR_BAD_DEVICE, GRUB_ERR_READ_ERROR, GRUB_ERR_WRITE_ERROR, GRUB_ERR_UNKNOWN_COMMAND, GRUB_ERR_INVALID_COMMAND, GRUB_ERR_BAD_ARGUMENT, GRUB_ERR_BAD_PART_TABLE, GRUB_ERR_UNKNOWN_OS, GRUB_ERR_BAD_OS, GRUB_ERR_NO_KERNEL, GRUB_ERR_BAD_FONT, GRUB_ERR_NOT_IMPLEMENTED_YET, GRUB_ERR_SYMLINK_LOOP, GRUB_ERR_BAD_GZIP_DATA,} grub_err_t;/* Byte-orders. */#define grub_swap_bytes16(x) \({ \ grub_uint16_t _x = (x); \ (grub_uint16_t) ((_x << 8) | (_x >> 8)); \})#define grub_swap_bytes32(x) \({ \ grub_uint32_t _x = (x); \ (grub_uint32_t) ((_x << 24) \ | ((_x & (grub_uint32_t) 0xFF00UL) << 8) \ | ((_x & (grub_uint32_t) 0xFF0000UL) >> 8) \ | (_x >> 24)); \})#define grub_swap_bytes64(x) \({ \ grub_uint64_t _x = (x); \ (grub_uint64_t) ((_x << 56) \ | ((_x & (grub_uint64_t) 0xFF00ULL) << 40) \ | ((_x & (grub_uint64_t) 0xFF0000ULL) << 24) \ | ((_x & (grub_uint64_t) 0xFF000000ULL) << 8) \ | ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8) \ | ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24) \ | ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) \ | (_x >> 56)); \})#define grub_cpu_to_le16(x) ((grub_uint16_t) (x))#define grub_cpu_to_le32(x) ((grub_uint32_t) (x))#define grub_cpu_to_le64(x) ((grub_uint64_t) (x))#define grub_le_to_cpu16(x) ((grub_uint16_t) (x))#define grub_le_to_cpu32(x) ((grub_uint32_t) (x))#define grub_le_to_cpu64(x) ((grub_uint64_t) (x))struct grub_disk;/* Disk. */struct grub_disk { /* The total number of sectors. */ grub_uint64_t total_sectors; int pcount; int cur_ptable; pentry_t ptable[20]; int card_type; int fs_type; int (*read)(char *buffer, unsigned long sector); /* Called when a sector was read. OFFSET is between 0 and the sector size minus 1, and LENGTH is between 0 and the sector size. */ void (*read_hook)(grub_disk_addr_t sector, unsigned offset, unsigned length);};typedef struct grub_disk *grub_disk_t;/* File description. */struct grub_file { /* The current offset. */ grub_off_t offset; grub_disk_t disk; void *data; /* The file size. */ grub_off_t size; /* This is called when a sector is read. Used only for a disk device. */ void (*read_hook)(grub_disk_addr_t sector, unsigned offset, unsigned length);};typedef struct grub_file *grub_file_t; enum grub_fshelp_filetype { GRUB_FSHELP_UNKNOWN, GRUB_FSHELP_REG, GRUB_FSHELP_DIR, GRUB_FSHELP_SYMLINK}; void grub_set_error(grub_err_t n);grub_err_t grub_error(grub_err_t n, const char *fmt, ...);grub_err_t grub_get_error();void grub_debug(const char *fmt, ...);#define grub_errno grub_get_error()grub_err_t grub_disk_read(grub_disk_t disk, grub_disk_addr_t sector, grub_off_t offset, grub_size_t length, char *buf);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -