Fix grub-install BOOT_PATH, validate grub-mkconfig timeout, add fat_tool sync
Fix BOOT_PATH logic in grub-install: non-removable installs now use
EFI/${BOOTLOADER_ID} per UEFI spec instead of always EFI/BOOT.
Add timeout validation to grub-mkconfig (must be non-negative integer).
Add sync() method to fat_tool.py and call os.fsync after cp_in to
ensure data reaches disk. Fix misleading block-device error message.
This commit is contained in:
@@ -105,6 +105,10 @@ class Fat32:
|
|||||||
self.f.seek(self.fat_start + i * self.fat_size * self.bytes_per_sector)
|
self.f.seek(self.fat_start + i * self.fat_size * self.bytes_per_sector)
|
||||||
self.f.write(self.fat)
|
self.f.write(self.fat)
|
||||||
|
|
||||||
|
def sync(self):
|
||||||
|
self.f.flush()
|
||||||
|
os.fsync(self.f.fileno())
|
||||||
|
|
||||||
def _cluster_offset(self, cluster):
|
def _cluster_offset(self, cluster):
|
||||||
if not 2 <= cluster <= self.max_cluster:
|
if not 2 <= cluster <= self.max_cluster:
|
||||||
raise RuntimeError(f"FAT32: invalid cluster {cluster}")
|
raise RuntimeError(f"FAT32: invalid cluster {cluster}")
|
||||||
@@ -570,6 +574,7 @@ class Fat32:
|
|||||||
else:
|
else:
|
||||||
self._add_dir_entry(parent_cluster, file_name, first_cluster, False, len(data))
|
self._add_dir_entry(parent_cluster, file_name, first_cluster, False, len(data))
|
||||||
self.f.flush()
|
self.f.flush()
|
||||||
|
os.fsync(self.f.fileno())
|
||||||
except Exception:
|
except Exception:
|
||||||
if clusters:
|
if clusters:
|
||||||
self._free_cluster_chain(clusters[0])
|
self._free_cluster_chain(clusters[0])
|
||||||
|
|||||||
@@ -241,9 +241,10 @@ if [ -n "$DISK_IMAGE" ]; then
|
|||||||
ESP_OFFSET=$((2048 * 512))
|
ESP_OFFSET=$((2048 * 512))
|
||||||
|
|
||||||
# Write GRUB to ESP
|
# Write GRUB to ESP
|
||||||
BOOT_PATH="EFI/BOOT"
|
if [ "$REMOVABLE" -eq 1 ]; then
|
||||||
if [ "$REMOVABLE" -eq 0 ] && [ -n "$BOOTLOADER_ID" ]; then
|
|
||||||
BOOT_PATH="EFI/BOOT"
|
BOOT_PATH="EFI/BOOT"
|
||||||
|
else
|
||||||
|
BOOT_PATH="EFI/${BOOTLOADER_ID}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$FAT_TOOL" mkdir "$DISK_IMAGE" "$ESP_OFFSET" "EFI" 2>/dev/null || true
|
"$FAT_TOOL" mkdir "$DISK_IMAGE" "$ESP_OFFSET" "EFI" 2>/dev/null || true
|
||||||
@@ -265,9 +266,10 @@ fi
|
|||||||
|
|
||||||
# Mode 2: Full image build via Red Bear installer (INSTALL_DEVICE given)
|
# Mode 2: Full image build via Red Bear installer (INSTALL_DEVICE given)
|
||||||
if [ -n "$INSTALL_DEVICE" ]; then
|
if [ -n "$INSTALL_DEVICE" ]; then
|
||||||
echo "$PROG: installing to $INSTALL_DEVICE via Red Bear installer..." >&2
|
echo "$PROG: block device installation is not supported by this wrapper." >&2
|
||||||
echo "$PROG: for Red Bear OS, use: make all CONFIG_NAME=redbear-full-grub" >&2
|
echo "$PROG: For Red Bear OS, use one of:" >&2
|
||||||
echo "$PROG: or: redox_installer -c redbear-full-grub.toml $INSTALL_DEVICE" >&2
|
echo "$PROG: make all CONFIG_NAME=redbear-full-grub" >&2
|
||||||
|
echo "$PROG: redox_installer -c redbear-full-grub.toml $INSTALL_DEVICE" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,10 @@ while [ $# -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
case "$TIMEOUT" in
|
||||||
|
''|*[!0-9]*) echo "$PROG: invalid timeout '$TIMEOUT' (must be a non-negative integer)" >&2; exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
generate_config() {
|
generate_config() {
|
||||||
cat <<GRUBCFG
|
cat <<GRUBCFG
|
||||||
# Generated by $PROG — $(date -Iseconds 2>/dev/null || date)
|
# Generated by $PROG — $(date -Iseconds 2>/dev/null || date)
|
||||||
|
|||||||
Reference in New Issue
Block a user