Implement blkreader crate for direct block device reading via FIEMAP#1
Implement blkreader crate for direct block device reading via FIEMAP#1
Conversation
Co-authored-by: SF-Zhou <7477599+SF-Zhou@users.noreply.github.com>
Co-authored-by: SF-Zhou <7477599+SF-Zhou@users.noreply.github.com>
|
@copilot 注意 CLI 工具中,你应该注意内存、offset 和 length 的 direct io 的对齐问题。并且文件可能很大,无法一次性读取完成,你需要考虑分批逐步读取。crate 接口的文档中增加对对齐的要求。另外现有的 CI pipeline 拆分的太细了,可以适当简化,这里有另外一个 CI pipeline 可以参考: name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build & Run
run: |
cargo fmt --all -- --check
cargo clippy -- -D warnings
cargo test
cargo run --release -- README.md |
Co-authored-by: SF-Zhou <7477599+SF-Zhou@users.noreply.github.com>
Fixed in 87b6d91:
|
…rename zero_unwritten Co-authored-by: SF-Zhou <7477599+SF-Zhou@users.noreply.github.com>
Optionsstruct with configuration optionsStatestruct with read results and extent infoBlkReadertrait withblk_read_atandblk_read_at_optmethodsblkmapcrate for extent query viaFIEMAPioctlblkpathcrate for block device discoveryPath,PathBufandFiletypes--offset,--length,-v,-OoptionsChanges from code review:
Cache refactoring:
get_or_create_cached_devicenow takes&Fileand callsresolve_device()internally, so the expensive path resolution is only done when the device is not in cache.Fallback returns extents:
State::fallback()now takes extents parameter, so extent information is available even when using regular file I/O.Renamed
fill_unwrittentozero_unwritten: Better reflects the behavior - when disabled (default), unwritten extents are read from block device returning raw data. When enabled, they're filled with zeros.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.