You've already forked archr-flasher
mirror of
https://github.com/archr-linux/archr-flasher.git
synced 2026-07-12 18:19:47 -07:00
fix(linux): O_DIRECT fallback for dd on incompatible SD card readers
Some USB SD card readers don't support O_DIRECT, causing dd to fail immediately with EINVAL. Now tries O_DIRECT first and falls back to normal write if dd exits within 1 second. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "archr-flasher"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
description = "Arch R SD Card Flasher"
|
||||
authors = ["Arch R Linux"]
|
||||
edition = "2021"
|
||||
|
||||
@@ -261,9 +261,16 @@ for part in "${DEVICE}"*; do
|
||||
|| true
|
||||
done
|
||||
|
||||
# Write raw image with O_DIRECT (bypasses page cache, like RPi Imager)
|
||||
dd if="$IMAGE" of="$DEVICE" bs=4M oflag=direct conv=fsync status=none &
|
||||
# Write raw image — try O_DIRECT first (bypasses page cache, like RPi Imager),
|
||||
# fall back to normal write if device doesn't support it (EINVAL on some readers)
|
||||
dd if="$IMAGE" of="$DEVICE" bs=4M oflag=direct conv=fsync status=none 2>/dev/null &
|
||||
DD_PID=$!
|
||||
sleep 1
|
||||
if ! kill -0 $DD_PID 2>/dev/null; then
|
||||
# dd with O_DIRECT exited immediately — retry without it
|
||||
dd if="$IMAGE" of="$DEVICE" bs=4M conv=fsync status=none &
|
||||
DD_PID=$!
|
||||
fi
|
||||
|
||||
# Monitor dd progress via /proc/fdinfo
|
||||
while kill -0 $DD_PID 2>/dev/null; do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-config-schema/schema.json",
|
||||
"productName": "Arch R Flasher",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"identifier": "com.archr.flasher",
|
||||
"build": {
|
||||
"frontendDist": "../src",
|
||||
|
||||
Reference in New Issue
Block a user