From 9026839a953b58de9309e62b2a2fec4a627f3179 Mon Sep 17 00:00:00 2001 From: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:24:54 +0200 Subject: [PATCH] lint: correct linting for crate Signed-off-by: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com> --- src/fs-gen/src/image_builder.rs | 4 +--- src/fs-gen/src/initramfs_generator.rs | 14 +++++++++----- src/fs-gen/src/main.rs | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/fs-gen/src/image_builder.rs b/src/fs-gen/src/image_builder.rs index 7fc6384..f723eab 100644 --- a/src/fs-gen/src/image_builder.rs +++ b/src/fs-gen/src/image_builder.rs @@ -1,7 +1,6 @@ use std::{ - fs::{self, File}, + fs::{self}, io::Result, - option, path::{Path, PathBuf}, sync::Arc, thread, @@ -13,7 +12,6 @@ use fuse_backend_rs::{ passthrough::{self, PassthroughFs}, transport::{FuseChannel, FuseSession}, }; -use signal_hook::{consts::TERM_SIGNALS, iterator::Signals}; pub struct FuseServer { server: Arc>>, diff --git a/src/fs-gen/src/initramfs_generator.rs b/src/fs-gen/src/initramfs_generator.rs index 3fedf8d..76027dc 100644 --- a/src/fs-gen/src/initramfs_generator.rs +++ b/src/fs-gen/src/initramfs_generator.rs @@ -1,10 +1,10 @@ use std::fs::{File, Permissions}; -use std::os::unix::fs::PermissionsExt; use std::io::Write; +use std::os::unix::fs::PermissionsExt; use std::path::Path; use std::process::{Command, Stdio}; -const INIT_FILE: &[u8;211] = b"#! /bin/sh +const INIT_FILE: &[u8; 211] = b"#! /bin/sh # # Cloudlet initramfs generation # @@ -21,13 +21,15 @@ pub fn create_init_file(path: &Path) { let file_path = path.join("init"); let mut file = File::create(file_path).unwrap(); - file.write_all(INIT_FILE).expect("Could not write init file"); + file.write_all(INIT_FILE) + .expect("Could not write init file"); file.set_permissions(Permissions::from_mode(0o755)).unwrap(); } pub fn generate_initramfs(root_directory: &Path, output: &Path) { let file = File::create(output).unwrap(); - file.set_permissions(Permissions::from_mode(0o644)).expect("Could not set permissions"); + file.set_permissions(Permissions::from_mode(0o644)) + .expect("Could not set permissions"); println!("Generating initramfs..."); @@ -38,7 +40,9 @@ pub fn generate_initramfs(root_directory: &Path, output: &Path) { .arg("find . -print0 | cpio -0 --create --owner=root:root --format=newc | xz -9 --format=lzma") .spawn() .expect("Failed to package initramfs"); - command.wait().expect("Failed to wait for initramfs to finish"); + command + .wait() + .expect("Failed to wait for initramfs to finish"); println!("Initramfs generated!"); } diff --git a/src/fs-gen/src/main.rs b/src/fs-gen/src/main.rs index 6394ce5..8229e85 100644 --- a/src/fs-gen/src/main.rs +++ b/src/fs-gen/src/main.rs @@ -1,7 +1,7 @@ -use std::{fs::remove_dir_all, path::Path, str::FromStr}; +use std::{fs::remove_dir_all, path::Path}; -use image_builder::merge_layer; use crate::initramfs_generator::{create_init_file, generate_initramfs}; +use image_builder::merge_layer; mod cli_args; mod image_builder; @@ -20,7 +20,7 @@ fn main() { Err(e) => { eprintln!("Error: {}", e); return; - }, + } Ok(layers_paths) => { println!("Image downloaded successfully! Layers' paths:"); for path in &layers_paths { @@ -30,7 +30,7 @@ fn main() { // FIXME: use a subdir of the temp directory instead let path = Path::new(overlay_subdir.as_path()); - merge_layer(&layers_paths, path); + merge_layer(&layers_paths, path).expect("Merging layers failed"); create_init_file(path); generate_initramfs(path, Path::new(args.output_file.as_path())); }