환경 구성

ramdisk 설치

mkfs.ex2 /dev/ramdisk

mount

  • 마운트 파일 mkdir 이후 mount

파일 시스템 분석.

xxd를 사용하여 ramdisk 파일 시스템을 분석할 수 있다.

options
-s[+/-] offset : 어디서부터 보여줄 것?(시작점)
-l len: 나타낼 길이
-g bytes : 몇 바이트씩 나눠서?
$xxd -g 4 -l 0x100 -s 0x400 /dev/ramdisk

분석

  1. 어디서부터 시작하나?
  • 메타데이터분석 => 슈퍼블럭
  1. 슈퍼블럭

    Examination
    Where to start?
    Metadata for FS è Superblock
    Where is superblock?
    Boot block: data related to booting, 2 sectors (0~0x400)
    Superblock: Start at 0x400, Group desc. : start at 0x1000 (4KB)
    Examine 0x400 using xxd

  • 부트블럭 : 첫 512바이트 (2secter)
  • 슈퍼블럭 : 2개의 섹터가 지난 위치 (1024)
  • 1024를 2진수 4자리씩 끊으면 0x400

  • 자료구조 테이블

inode count : 0x10000
block count : 0x10000
log block size : 0x2
blocks per group : 0x8000
inodes per group : 0x8000
block group number : 0x0

  • LITTLE ENDIAN(인텔)
  • 00 00 01 00 ==> 00 01 00 00 ==> inode count ==> 2^16 = 640000개 정도의 아이노드 존재
  • 00000100 ==> 00010000 ==> 64000개 (블록 카운트)
  • 02000000 ==> 00000002 ==> 0x2
  1. 그룹 디스크립터 (4KB 위치)
  • 자료구조 테이블

Group 0

  • block bitmap : start from 0x11th block (0x11000)
  • Inode bitmap : start from 0x12th block
  • Inode table : start from 0x13th block
    Block group number of an inode: (i_number – 1) / inodes per group ==> 0x8000 2^8 = 32000개
    Root inode number of ext2 is ‘2’ (2nd)
  • From given example ext2 has 0x8000 inodes per group
    The block group number for root: (2 – 1) / 0x8000 = 0 // 0번째 그룹으로 가서 1이라는 인덱스로 접근 가능
    The index of root inode: (2 – 1) % 0x8000 = 1

  1. inode table

The size of an inode is 128 B (0x80B) in ext2
As the index for inode of root is 1
The root inode begins at the 0x80B of the inode table

  • 13000에 inode 테이블이 있다.
  • 13080 ==> root

  • 자료구조 테이블

  • 13080에는 비어있고 13100에 들어있다.
  • 0x41ed = 0100 0001 1110 1101 // 111 101 101 ==> 접근권한을 나타냄 (u/g/o)
    ==> Dir + r wxr- xr-x (0x1ed)
    1st block: 0x8130000 ==> 0x8130000
  • Direct Block : 13080000 (root inode가 가리키는 data block)
  1. 디렉토리 (데이터 블럭)

  • 루트의 데이터 블럭
  • 루트 밑에 a(a1,a2),b(b1),c(c1) 디렉토리가 존재
  • 61000000 => a(아스키코드)(97)
  • 62 => b
  • 02 : 디렉토리 filetype
  • 01800000 => 00008001(inode), 8001 - 1 / 0x8000 = 1(그룹1)
  • inode table index = 8000%8000 = 0

0개의 댓글