From 3895c94eb521c47a9b165d00b504d987a382af62 Mon Sep 17 00:00:00 2001 From: tilpner Date: Thu, 17 Aug 2023 21:08:51 +0200 Subject: [PATCH] tool: only sync ESP filesystem --- rust/tool/src/install.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rust/tool/src/install.rs b/rust/tool/src/install.rs index a827d42..c860dc9 100644 --- a/rust/tool/src/install.rs +++ b/rust/tool/src/install.rs @@ -1,12 +1,13 @@ use std::collections::{BTreeMap, BTreeSet}; -use std::fs; +use std::fs::{self, File}; +use std::os::fd::AsRawFd; use std::os::unix::prelude::PermissionsExt; use std::path::{Path, PathBuf}; use std::process::Command; use std::string::ToString; use anyhow::{anyhow, Context, Result}; -use nix::unistd::sync; +use nix::unistd::syncfs; use tempfile::TempDir; use crate::esp::{EspGenerationPaths, EspPaths}; @@ -110,8 +111,8 @@ impl Installer { Garbage collection is disabled because you have malformed NixOS generations that do not contain a readable bootspec document. - Remove the malformed generations to re-enable garbage collection with - `nix-env --delete-generations {}` + Remove the malformed generations to re-enable garbage collection with + `nix-env --delete-generations {}` ", self.broken_gens.iter().map(ToString::to_string).collect::>().join(" ")}; log::warn!("{warning}"); }; @@ -161,7 +162,8 @@ impl Installer { // Sync files to persistent storage. This may improve the // chance of a consistent boot directory in case the system // crashes. - sync(); + let boot = File::open(&self.esp_paths.esp).context("Failed to open ESP root directory.")?; + syncfs(boot.as_raw_fd()).context("Failed to sync ESP filesystem.")?; Ok(()) }