libcros 0.6.5

A Rust library that provides easy-to-use functions for interacting with a Chrome device
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};

use super::{EXT_MAGIC, EXT_MAGIC_OFFSET, EXT_SUPERBLOCK_OFFSET};

pub fn verify_ext(f: &mut File, base: u64) -> bool {
  let mut buf = [0u8; 2];

  if f.seek(SeekFrom::Start(base + EXT_SUPERBLOCK_OFFSET + EXT_MAGIC_OFFSET)).is_err() {
    return false;
  }

  if f.read_exact(&mut buf).is_err() {
    return false;
  }

  buf == EXT_MAGIC
}