Skip to content

Commit

Permalink
lint: correct linting for crate
Browse files Browse the repository at this point in the history
Signed-off-by: BioTheWolff <[email protected]>
  • Loading branch information
BioTheWolff committed Apr 22, 2024
1 parent 6a4c87d commit 9026839
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/fs-gen/src/image_builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{
fs::{self, File},
fs::{self},
io::Result,
option,
path::{Path, PathBuf},
sync::Arc,
thread,
Expand All @@ -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<Server<Arc<OverlayFs>>>,
Expand Down
14 changes: 9 additions & 5 deletions src/fs-gen/src/initramfs_generator.rs
Original file line number Diff line number Diff line change
@@ -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
#
Expand All @@ -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...");

Expand All @@ -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!");
}
8 changes: 4 additions & 4 deletions src/fs-gen/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand All @@ -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()));
}
Expand Down

0 comments on commit 9026839

Please sign in to comment.