From 38ac1304e65b89c295b62a00c3092202d92f8d07 Mon Sep 17 00:00:00 2001 From: Cappy Ishihara Date: Tue, 3 Oct 2023 11:56:40 +0700 Subject: [PATCH] move fstab outside of loop --- src/config.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/config.rs b/src/config.rs index 2f79d52..04ba457 100644 --- a/src/config.rs +++ b/src/config.rs @@ -304,6 +304,20 @@ impl PartitionLayout { let mut fstab = String::new(); + const PREPEND_COMMENT: &str = r#" +# /etc/fstab: static file system information. +# Automatically generated by Katsu Image Builder. See +# katsu::config::PartitionLayout::fstab for more information. + + "#; + + fstab.push_str(PREPEND_COMMENT.trim()); + + const LEGEND: &str = + "# \t\t\t\t\t\n\n"; + + fstab.push_str(LEGEND.trim()); + for part in &ordered.partitions { // get devname by finding from mount, instead of index because we won't be using it as much let mountpoint = PathBuf::from(&part.mountpoint); @@ -334,19 +348,6 @@ impl PartitionLayout { } }; - const PREPEND_COMMENT: &str = r#" -# /etc/fstab: static file system information. -# Automatically generated by Katsu Image Builder. See -# katsu::config::PartitionLayout::fstab for more information. - -"#; - - fstab.push_str(PREPEND_COMMENT.trim()); - - const LEGEND: &str = "# \t\t\t\t\t\n\n"; - - fstab.push_str(LEGEND.trim()); - let fsck = if part.filesystem == "efi" { "0" } else { "2" }; let entry = format!(