📄 fs_ext2.h
字号:
/* * GRUB -- GRand Unified Bootloader * Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. * Copyright 2006 Pawel Kolodziejski - adopted to linux native bootloader * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#ifndef __GRUB_EXT2_H__#define __GRUB_EXT2_H__/* Magic value used to identify an ext2 filesystem. */#define EXT2_MAGIC 0xEF53/* Amount of indirect blocks in an inode. */#define INDIRECT_BLOCKS 12/* Maximum lenght of a pathname. */#define EXT2_PATH_MAX 4096/* Maximum nesting of symlinks, used to prevent a loop. */#define EXT2_MAX_SYMLINKCNT 8/* Filetype used in directory entry. */#define FILETYPE_UNKNOWN 0#define FILETYPE_REG 1#define FILETYPE_DIRECTORY 2#define FILETYPE_SYMLINK 7/* Filetype information as used in inodes. */#define FILETYPE_INO_MASK 0170000#define FILETYPE_INO_REG 0100000#define FILETYPE_INO_DIRECTORY 0040000#define FILETYPE_INO_SYMLINK 0120000/* Log2 size of ext2 block in 512 blocks. */#define LOG2_EXT2_BLOCK_SIZE(data) \ (grub_le_to_cpu32 (data->sblock.log2_block_size) + 1) /* Log2 size of ext2 block in bytes. */#define LOG2_BLOCK_SIZE(data) \ (grub_le_to_cpu32 (data->sblock.log2_block_size) + 10)/* The size of an ext2 block in bytes. */#define EXT2_BLOCK_SIZE(data) (1 << LOG2_BLOCK_SIZE(data))/* The ext2 superblock. */struct grub_ext2_sblock { grub_uint32_t total_inodes; grub_uint32_t total_blocks; grub_uint32_t reserved_blocks; grub_uint32_t free_blocks; grub_uint32_t free_inodes; grub_uint32_t first_data_block; grub_uint32_t log2_block_size; grub_uint32_t log2_fragment_size; grub_uint32_t blocks_per_group; grub_uint32_t fragments_per_group; grub_uint32_t inodes_per_group; grub_uint32_t mtime; grub_uint32_t utime; grub_uint16_t mnt_count; grub_uint16_t max_mnt_count; grub_uint16_t magic; grub_uint16_t fs_state; grub_uint16_t error_handling; grub_uint16_t minor_revision_level; grub_uint32_t lastcheck; grub_uint32_t checkinterval; grub_uint32_t creator_os; grub_uint32_t revision_level; grub_uint16_t uid_reserved; grub_uint16_t gid_reserved; grub_uint32_t first_inode; grub_uint16_t inode_size; grub_uint16_t block_group_number; grub_uint32_t feature_compatibility; grub_uint32_t feature_incompat; grub_uint32_t feature_ro_compat; grub_uint32_t unique_id[4]; char volume_name[16]; char last_mounted_on[64]; grub_uint32_t compression_info;};/* The ext2 blockgroup. */struct grub_ext2_block_group { grub_uint32_t block_id; grub_uint32_t inode_id; grub_uint32_t inode_table_id; grub_uint16_t free_blocks; grub_uint16_t free_inodes; grub_uint16_t pad; grub_uint32_t reserved[3];};/* The ext2 inode. */struct grub_ext2_inode { grub_uint16_t mode; grub_uint16_t uid; grub_uint32_t size; grub_uint32_t atime; grub_uint32_t ctime; grub_uint32_t mtime; grub_uint32_t dtime; grub_uint16_t gid; grub_uint16_t nlinks; grub_uint32_t blockcnt; /* Blocks of 512 bytes!! */ grub_uint32_t flags; grub_uint32_t osd1; union { struct datablocks { grub_uint32_t dir_blocks[INDIRECT_BLOCKS]; grub_uint32_t indir_block; grub_uint32_t double_indir_block; grub_uint32_t tripple_indir_block; } blocks; char symlink[60]; }; grub_uint32_t version; grub_uint32_t acl; grub_uint32_t dir_acl; grub_uint32_t fragment_addr; grub_uint32_t osd2[3];};/* The header of an ext2 directory entry. */struct ext2_dirent { grub_uint32_t inode; grub_uint16_t direntlen; grub_uint8_t namelen; grub_uint8_t filetype;};struct grub_fshelp_node { struct grub_ext2_data *data; struct grub_ext2_inode inode; int ino; int inode_read;};typedef struct grub_fshelp_node *grub_fshelp_node_t;/* Information about a "mounted" ext2 filesystem. */struct grub_ext2_data { struct grub_ext2_sblock sblock; grub_disk_t disk; struct grub_ext2_inode *inode; struct grub_fshelp_node diropen;};grub_ssize_t grub_fshelp_read_file(grub_disk_t disk, grub_fshelp_node_t node, void (*read_hook)(grub_disk_addr_t sector, unsigned offset, unsigned length), int pos, grub_size_t len, char *buf, int (*get_block)(grub_fshelp_node_t node, int block), grub_off_t filesize, int log2blocksize);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -