1 /* 2 3 File: gfs2.h 4 5 Copyright (C) 2011 Christophe GRENIER <grenier@cgsecurity.org> 6 7 This software is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License along 18 with this program; if not, write the Free Software Foundation, Inc., 51 19 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 21 */ 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 // Structure from gfs2_ondisk.h 27 #define GFS2_MAGIC 0x01161970 28 #define GFS2_BASIC_BLOCK 512 29 #define GFS2_BASIC_BLOCK_SHIFT 9 30 #define GFS2_FORMAT_SB 100 31 32 /* 33 * An on-disk inode number 34 */ 35 36 struct gfs2_inum { 37 uint64_t no_formal_ino; 38 uint64_t no_addr; 39 }; 40 41 struct gfs2_meta_header { 42 uint32_t mh_magic; 43 uint32_t mh_type; 44 uint64_t __pad0; /* Was generation number in gfs1 */ 45 uint32_t mh_format; 46 /* This union is to keep userspace happy */ 47 union { 48 uint32_t mh_jid; /* Was incarnation number in gfs1 */ 49 uint32_t __pad1; 50 }; 51 }; 52 /* Address of superblock in GFS2 basic blocks */ 53 #define GFS2_SB_ADDR 128 54 #define GFS2_LOCKNAME_LEN 64 55 56 struct gfs2_sb { 57 struct gfs2_meta_header sb_header; 58 59 uint32_t sb_fs_format; 60 uint32_t sb_multihost_format; 61 uint32_t __pad0; /* Was superblock flags in gfs1 */ 62 63 uint32_t sb_bsize; 64 uint32_t sb_bsize_shift; 65 uint32_t __pad1; /* Was journal segment size in gfs1 */ 66 67 struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */ 68 struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */ 69 struct gfs2_inum sb_root_dir; 70 71 char sb_lockproto[GFS2_LOCKNAME_LEN]; 72 char sb_locktable[GFS2_LOCKNAME_LEN]; 73 74 struct gfs2_inum __pad3; /* Was quota inode in gfs1 */ 75 struct gfs2_inum __pad4; /* Was licence inode in gfs1 */ 76 #define GFS2_HAS_UUID 1 77 uint8_t sb_uuid[16]; /* The UUID, maybe 0 for backwards compat */ 78 }; 79 80 // 81 int check_gfs2(disk_t *disk_car, partition_t *partition); 82 int recover_gfs2(disk_t *disk_car, const struct gfs2_sb *sb, partition_t *partition, const int dump_ind); 83 84 #ifdef __cplusplus 85 } /* closing brace for extern "C" */ 86 #endif 87