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.write(self.fat)
|
||||
|
||||
def sync(self):
|
||||
self.f.flush()
|
||||
os.fsync(self.f.fileno())
|
||||
|
||||
def _cluster_offset(self, cluster):
|
||||
if not 2 <= cluster <= self.max_cluster:
|
||||
raise RuntimeError(f"FAT32: invalid cluster {cluster}")
|
||||
@@ -570,6 +574,7 @@ class Fat32:
|
||||
else:
|
||||
self._add_dir_entry(parent_cluster, file_name, first_cluster, False, len(data))
|
||||
self.f.flush()
|
||||
os.fsync(self.f.fileno())
|
||||
except Exception:
|
||||
if clusters:
|
||||
self._free_cluster_chain(clusters[0])
|
||||
|
||||
@@ -241,9 +241,10 @@ if [ -n "$DISK_IMAGE" ]; then
|
||||
ESP_OFFSET=$((2048 * 512))
|
||||
|
||||
# Write GRUB to ESP
|
||||
if [ "$REMOVABLE" -eq 1 ]; then
|
||||
BOOT_PATH="EFI/BOOT"
|
||||
if [ "$REMOVABLE" -eq 0 ] && [ -n "$BOOTLOADER_ID" ]; then
|
||||
BOOT_PATH="EFI/BOOT"
|
||||
else
|
||||
BOOT_PATH="EFI/${BOOTLOADER_ID}"
|
||||
fi
|
||||
|
||||
"$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)
|
||||
if [ -n "$INSTALL_DEVICE" ]; then
|
||||
echo "$PROG: installing to $INSTALL_DEVICE via Red Bear installer..." >&2
|
||||
echo "$PROG: for Red Bear OS, use: make all CONFIG_NAME=redbear-full-grub" >&2
|
||||
echo "$PROG: or: redox_installer -c redbear-full-grub.toml $INSTALL_DEVICE" >&2
|
||||
echo "$PROG: block device installation is not supported by this wrapper." >&2
|
||||
echo "$PROG: For Red Bear OS, use one of:" >&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
|
||||
fi
|
||||
|
||||
|
||||
@@ -85,6 +85,10 @@ while [ $# -gt 0 ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
case "$TIMEOUT" in
|
||||
''|*[!0-9]*) echo "$PROG: invalid timeout '$TIMEOUT' (must be a non-negative integer)" >&2; exit 1;;
|
||||
esac
|
||||
|
||||
generate_config() {
|
||||
cat <<GRUBCFG
|
||||
# Generated by $PROG — $(date -Iseconds 2>/dev/null || date)
|
||||
|
||||
Reference in New Issue
Block a user