From 7e632f51bd79a072b80bc07699195a5711644bd6 Mon Sep 17 00:00:00 2001 From: pjht Date: Sat, 10 Nov 2018 17:28:25 -0600 Subject: [PATCH] Work --- .gitignore | 1 + ext2.img | Bin 33554432 -> 33554432 bytes ext2_structs.h | 137 +++++++++++++++++++++++++++++++++++++++++++++++++ ext2prsr | Bin 13916 -> 0 bytes main.c | 136 +----------------------------------------------- 5 files changed, 139 insertions(+), 135 deletions(-) create mode 100644 ext2_structs.h delete mode 100755 ext2prsr diff --git a/.gitignore b/.gitignore index 5761abc..34e470a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.o +ext2prsr diff --git a/ext2.img b/ext2.img index 21abeb27ac1aed749c0ddca6abb522ff349eb575..1b148bdd27b25e2ac1d12de80ecada25fa8af803 100644 GIT binary patch delta 2758 zcmeIzc~F#P0LSrt-#tWGjJ(>)%t|`6vP{ji>^8a&%}TAX%*s?Owd~Rj5mZ!M5mxa4 zFT79z6}<7j54`Ze`&Lvu5K)os_jQM{`mY&h`ln~+``P!|_uXf9cAt4)x7!`;R%uR~ z*J*Rt3a#Dtcx#Kr=WAYISPYBB;-Bk4gE=Emxm6=&DyzyX-=jx(&(QqDkc{vq)#9&v zjFxd5Z8d6kXmvQq(Xd(LK1FS3Hs~_E6KgmXgS9xraJJ}K8%yb&{N(>|2*kCn% z9QHAUc=_D`<5q3sXl-Nlhl)_W zRix^pqExi%tNN+_Dn<=Z1JxiEs|G8N8lvLVP!+EdlvfQ?!&Rahp+>4vYP3pH$!d%m ztH!DEYJy5p6V)U&Sxr$>RjQh%rmGn$O{J?0HB-$}vsI?bQghT?HBZe~3)DijNM)ksz9An=hX#uQ5C97sz_Z{#p;T>s;;RL zbzPMzUrdMh zLv^?ZYQViv6Yhii;Q^=xA@CqP1P{X_P#fyNqwp9!4t3!PcoOQtQ&1loKtp&M8o@Kr z7@EMd@EkOS=ivo-5nh6q;T3oln!#%j3a`T(@Fu(kZ^JwAF1!ct!w1kDTEK_U5D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Ti^byyuyN7XTPT%AxS)hTsaol$4iIdxuL zP#4uDby;0eSJgFjU8N{b`yi)@R$v1=IN-(!FMfIiT#yMeLl*FctdI?Sz!$PZ4#)|) zzz=f6qu>vZ!Q+qz^1>6451xbo$PZ6J0eBh;!ZYwJ6oSI=929})p(wlnflv&JLkTDe zrJyvt2xZ_Uco|-SSK&2y9m+yEcmv*qx8Q9k5AVRc@E%lv_u&Kh5Guk)Pzfr-$M6YM zfvQjqK85P=8GH_3z?V=1YCka9Q20)Fc1d8U>E{J zVHgaD5ik-)!Dtu*V__VOhj^F(6JZieh6G52DKHhL!E~4bGhr4a!EBfVb73CLhXt?@ z7Qtdz0!v{TEQb}43@c$3tcEqP7S_Rf*Z>=06KsYpuobq!cGv+sVHfO%J+K${!G1UZ y2jLJLh9htkj=^y_0Vm-UoQ5-S7S6$WxBwU75?qEWa22k>bx1Kuo-7_?&iw^N4H%yQ diff --git a/ext2_structs.h b/ext2_structs.h new file mode 100644 index 0000000..6de91a4 --- /dev/null +++ b/ext2_structs.h @@ -0,0 +1,137 @@ +#ifndef EXT2_STRUCTS_H +#define EXT2_STRUCTS_H +typedef struct { + uint32_t s_inodes_count; + uint32_t s_blocks_count; + uint32_t s_r_blocks_count; + uint32_t s_free_blocks_count; + uint32_t s_free_inodes_count; + uint32_t s_first_data_block; + uint32_t s_log_blk_size; + uint32_t s_log_frag_size; + uint32_t s_blocks_per_group; + uint32_t s_frags_per_group; + uint32_t s_inodes_per_group; + uint32_t s_mtime; + uint32_t s_wtime; + uint16_t s_mnt_count; + uint16_t s_max_mnt_count; + uint16_t s_magic; + uint16_t s_state; + uint16_t s_errors; + uint16_t s_minor_rev_level; + uint32_t s_lastcheck; + uint32_t s_checkinterval; + uint32_t s_creator_os; + uint32_t s_rev_level; + uint16_t s_def_resuid; + uint16_t s_def_resgid; + uint32_t s_first_ino; + uint16_t s_inode_size; + uint16_t s_block_group_nr; + uint32_t s_feature_compat; + uint32_t s_feature_incompat; + uint32_t s_feature_ro_compat; + char s_uuid[16]; + char s_volume_name[16]; + char s_last_mounted[64]; + uint32_t s_algo_bitmap; + char s_prealloc_blocks; + char s_prealloc_dir_blocks; + char s_journal_uuid[16]; + uint32_t s_journal_inum; + uint32_t s_journal_dev; + uint32_t s_last_orphan; +} __attribute__((packed)) ext2_superblock; + +typedef enum { + EXT2_FEATURE_COMPAT_DIR_PREALLOC=1, + EXT2_FEATURE_COMPAT_IMAGIC_INODES=2, + EXT2_FEATURE_COMPAT_HAS_JOURNAL=4, + EXT2_FEATURE_COMPAT_EXT_ATTR=8, + EXT2_FEATURE_COMPAT_RESIZE_INO=16, + EXT2_FEATURE_COMPAT_DIR_INDEX=32 +} s_feature_compat; + +typedef enum { + EXT2_FEATURE_INCOMPAT_COMPRESSION=1, + EXT2_FEATURE_INCOMPAT_FILETYPE=2, + EXT2_FEATURE_INCOMPAT_RECOVER=4, + EXT2_FEATURE_INCOMPAT_JOURNAL_DEV=8 +} s_feature_incompat; + +typedef enum { + EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER=1, + EXT2_FEATURE_RO_COMPAT_LARGE_FILE=2, + EXT2_FEATURE_RO_COMPAT_BTREE_DIR=4 +} s_feature_ro_compat; + +typedef struct { + uint32_t bg_blk_bitmap; + uint32_t bg_inode_bitmap; + uint32_t bg_inode_table; + uint16_t bg_free_blocks_count; + uint16_t bg_free_inodes_count; + uint16_t bg_used_dirs_count; + char unused[14]; +} __attribute__((packed)) blk_grp; + +typedef struct { + uint16_t i_mode; + uint16_t i_uid; + uint32_t i_size; + uint32_t i_atime; + uint32_t i_ctime; + uint32_t i_mtime; + uint32_t i_dtime; + uint16_t i_gid; + uint16_t i_links_count; + uint32_t i_blocks; + uint32_t i_flags; + uint32_t i_osd1; + uint32_t i_block[15]; + uint32_t i_generation; + uint32_t i_file_acl; + uint32_t i_dir_acl; + uint32_t i_faddr; + uint32_t i_osd2; + char unused[8]; +} __attribute__((packed)) inode; + +typedef enum { + EXT2_S_IFIFO=0x100, + EXT2_S_IFCHR=0x2000, + EXT2_S_IFDIR=0x4000, + EXT2_S_IFBLK=0x6000, + EXT2_S_IFREG=0x8000, + EXT2_S_IFLNK=0xA000, + EXT2_S_IFSOCK=0xC000 +} i_mode; + +typedef enum { + EXT2_SECRM_FL=0x1, + EXT2_UNRM_FL=0x2, + EXT2_COMPR_FL=0x4, + EXT2_SYNC_FL=0x8, + EXT2_IMMUTABLE_FL=0x10, + EXT2_APPEND_FL=0x20, + EXT2_NODUMP_FL=0x40, + EXT2_NOATIME_FL=0x80, + EXT2_DIRTY_FL=0x100, + EXT2_COMPRBLK_FL=0x200, + EXT2_NOCOMPR_FL=0x400, + EXT2_ECOMPR_FL=0x800, + EXT2_BTREE_FL=0x1000, + EXT2_INDEX_FL=0x1000, + EXT2_IMAGIC_FL=0x2000, + EXT2_JOURNAL_DATA_FL=0x4000, + EXT2_RESERVED_FL=0x80000000 +} i_flags; + +typedef struct { + uint32_t inode; + uint16_t rec_len; + char name_len; + char file_type; +} __attribute__((packed)) dir_entry; +#endif diff --git a/ext2prsr b/ext2prsr deleted file mode 100755 index c334ef04a93818e2d88ec93d1909fba4058e579a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13916 zcmeHOdvH|M89y6d0SOzXV)4=8>HtMW60Ej}re+}*Z#0iJFU5vlHp%88$?j$!l~`#* z!&MH~ZLw3SubKM5j-^bS&X6H0U=Rw}p*(y+Egi#DWpStzkz#5i>F+z|-rc(kIMcs6 zo!K+obI$jDzwbNW_npVG=WY&u@sD#87;}wbtUHG>=Emb4$C$ws^ccGwkA_Fry`DSN z`_!sR;-(i@I(b2g>>LG9*K5>!YtkV?UrFa#!!!8C;Es3*q3coq$|&_@$+TCTk6<90 zHd)Gv9&2GmGnREbNnMXbV-1lcE7M-xRnp#d7Q&`&g8<|ukUtDwroC>< zUY&&}n)043=lRzdiH6$(Efyft-n*8)cPt}BJ4>2v2y{Ibc%UuNq_+i{gMv<?Y^(_Z#wj8-7TGtqwsJm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u3RF&- z^g~~hG97)=w`p{R{(#6+O5aJ7e&Jl`{MWhKL8E$G=eB=Q9J3UGw2sG=uH{)A2R5dGw7We^cxv8UE$Bcb1fdq z#r1gR;<*72HW8KLZ=(7toPxiaIDg;kw9UmH6g{yGb=vbdR&WgH;!L0|EPHYr>k&E$ z92;IToX3GK35@AD7sct8#*rtbebiZpoOQg}2b+DQ*@xMAM`}TB#2=0ng#1x|82>`} zlOJC}i9fO;8VnVL!omA-105-#8*4q}3j@0mG)&+yDRo diff --git a/main.c b/main.c index e42d6ad..e32abbe 100644 --- a/main.c +++ b/main.c @@ -2,141 +2,7 @@ #include #include #include -typedef struct { - uint32_t s_inodes_count; - uint32_t s_blocks_count; - uint32_t s_r_blocks_count; - uint32_t s_free_blocks_count; - uint32_t s_free_inodes_count; - uint32_t s_first_data_block; - uint32_t s_log_blk_size; - uint32_t s_log_frag_size; - uint32_t s_blocks_per_group; - uint32_t s_frags_per_group; - uint32_t s_inodes_per_group; - uint32_t s_mtime; - uint32_t s_wtime; - uint16_t s_mnt_count; - uint16_t s_max_mnt_count; - uint16_t s_magic; - uint16_t s_state; - uint16_t s_errors; - uint16_t s_minor_rev_level; - uint32_t s_lastcheck; - uint32_t s_checkinterval; - uint32_t s_creator_os; - uint32_t s_rev_level; - uint16_t s_def_resuid; - uint16_t s_def_resgid; - uint32_t s_first_ino; - uint16_t s_inode_size; - uint16_t s_block_group_nr; - uint32_t s_feature_compat; - uint32_t s_feature_incompat; - uint32_t s_feature_ro_compat; - char s_uuid[16]; - char s_volume_name[16]; - char s_last_mounted[64]; - uint32_t s_algo_bitmap; - char s_prealloc_blocks; - char s_prealloc_dir_blocks; - char s_journal_uuid[16]; - uint32_t s_journal_inum; - uint32_t s_journal_dev; - uint32_t s_last_orphan; -} __attribute__((packed)) ext2_superblock; - -typedef enum { - EXT2_FEATURE_COMPAT_DIR_PREALLOC=1, - EXT2_FEATURE_COMPAT_IMAGIC_INODES=2, - EXT2_FEATURE_COMPAT_HAS_JOURNAL=4, - EXT2_FEATURE_COMPAT_EXT_ATTR=8, - EXT2_FEATURE_COMPAT_RESIZE_INO=16, - EXT2_FEATURE_COMPAT_DIR_INDEX=32 -} s_feature_compat; - -typedef enum { - EXT2_FEATURE_INCOMPAT_COMPRESSION=1, - EXT2_FEATURE_INCOMPAT_FILETYPE=2, - EXT2_FEATURE_INCOMPAT_RECOVER=4, - EXT2_FEATURE_INCOMPAT_JOURNAL_DEV=8 -} s_feature_incompat; - -typedef enum { - EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER=1, - EXT2_FEATURE_RO_COMPAT_LARGE_FILE=2, - EXT2_FEATURE_RO_COMPAT_BTREE_DIR=4 -} s_feature_ro_compat; - -typedef struct { - uint32_t bg_blk_bitmap; - uint32_t bg_inode_bitmap; - uint32_t bg_inode_table; - uint16_t bg_free_blocks_count; - uint16_t bg_free_inodes_count; - uint16_t bg_used_dirs_count; - char unused[14]; -} __attribute__((packed)) blk_grp; - -typedef struct { - uint16_t i_mode; - uint16_t i_uid; - uint32_t i_size; - uint32_t i_atime; - uint32_t i_ctime; - uint32_t i_mtime; - uint32_t i_dtime; - uint16_t i_gid; - uint16_t i_links_count; - uint32_t i_blocks; - uint32_t i_flags; - uint32_t i_osd1; - uint32_t i_block[15]; - uint32_t i_generation; - uint32_t i_file_acl; - uint32_t i_dir_acl; - uint32_t i_faddr; - uint32_t i_osd2; - char unused[8]; -} __attribute__((packed)) inode; - -typedef enum { - EXT2_S_IFIFO=0x100, - EXT2_S_IFCHR=0x2000, - EXT2_S_IFDIR=0x4000, - EXT2_S_IFBLK=0x6000, - EXT2_S_IFREG=0x8000, - EXT2_S_IFLNK=0xA000, - EXT2_S_IFSOCK=0xC000 -} i_mode; - -typedef enum { - EXT2_SECRM_FL=0x1, - EXT2_UNRM_FL=0x2, - EXT2_COMPR_FL=0x4, - EXT2_SYNC_FL=0x8, - EXT2_IMMUTABLE_FL=0x10, - EXT2_APPEND_FL=0x20, - EXT2_NODUMP_FL=0x40, - EXT2_NOATIME_FL=0x80, - EXT2_DIRTY_FL=0x100, - EXT2_COMPRBLK_FL=0x200, - EXT2_NOCOMPR_FL=0x400, - EXT2_ECOMPR_FL=0x800, - EXT2_BTREE_FL=0x1000, - EXT2_INDEX_FL=0x1000, - EXT2_IMAGIC_FL=0x2000, - EXT2_JOURNAL_DATA_FL=0x4000, - EXT2_RESERVED_FL=0x80000000 -} i_flags; - -typedef struct { - uint32_t inode; - uint16_t rec_len; - char name_len; - char file_type; -} __attribute__((packed)) dir_entry; - +#include "ext2_structs.h" char img[33554432]; ext2_superblock* supblk; uint32_t blk_size;