From bd8f251e7c4b725422a1e513a1882c6719f3de90 Mon Sep 17 00:00:00 2001 From: Xorycode Date: Sat, 13 Apr 2024 14:26:57 +0300 Subject: [PATCH] att 1 --- src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 40bb180..9794e87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,23 +4,29 @@ use std::io::{self, Write}; use std::io::Seek; use std::process::Command; -pub fn handle_client() { - +fn get_block_devices() -> Vec { let output = Command::new("lsblk") .arg("--output=NAME") .arg("--noheadings") .output() .unwrap(); - let mut block_devices: Vec<&str> = vec![]; + let mut block_devices: Vec = vec![]; let mut output_str = String::new(); if output.status.success() { output_str = String::from_utf8(output.stdout).unwrap(); block_devices = output_str.lines() .filter(|line| !line.starts_with('|') && !line.starts_with('├') && !line.starts_with('└')) + .map(|line| line.to_string()) .collect(); } + block_devices +} + +pub fn handle_client() { + + let block_devices: Vec = get_block_devices(); for blockdevice in block_devices { let diskname = format!("/dev/{blockdevice}");