Integrate metadata documentation and jhalfs manifests
This commit is contained in:
parent
74bf8a32d6
commit
3ce470e019
34 changed files with 5544 additions and 240 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// src/tui/disk_manager.rs
|
||||
use std::{
|
||||
fs::{File, read_dir},
|
||||
io::{self, Seek, SeekFrom, Write},
|
||||
io::{self, Seek, SeekFrom},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
|
|
@ -186,12 +186,12 @@ impl DiskManager {
|
|||
},
|
||||
};
|
||||
|
||||
// Create list of lines to display:
|
||||
// Create list of lines to display using public GPT API:
|
||||
let mut lines: Vec<String> = Vec::new();
|
||||
lines.push(format!("Partitions on {}:", disk.display()));
|
||||
for (i, entry_opt) in gpt.partitions.iter().enumerate() {
|
||||
if let Some(entry) = entry_opt {
|
||||
let name = entry.partition_name.to_string();
|
||||
for (i, entry) in gpt.iter() {
|
||||
if entry.is_used() {
|
||||
let name = entry.partition_name.as_str();
|
||||
lines.push(format!(
|
||||
"{}: {} -> {} (type: {})",
|
||||
i,
|
||||
|
|
@ -388,9 +388,9 @@ impl DiskManager {
|
|||
let sectors = (size_mb as u128 * 1024 * 1024 / 512) as u64;
|
||||
// choose starting LBA: find max ending_lba among existing partitions; align to 2048
|
||||
let last_end = gpt
|
||||
.partitions
|
||||
.iter()
|
||||
.filter_map(|p| p.as_ref().map(|e| e.ending_lba))
|
||||
.filter(|(_, e)| e.is_used())
|
||||
.map(|(_, e)| e.ending_lba)
|
||||
.max()
|
||||
.unwrap_or(2048);
|
||||
let start = ((last_end + 2048) / 2048) * 2048 + 1;
|
||||
|
|
@ -410,15 +410,15 @@ impl DiskManager {
|
|||
};
|
||||
new_entry.partition_type_guid = type_guid;
|
||||
|
||||
// find first empty partition slot
|
||||
let idx_opt = gpt.partitions.iter().position(|p| p.is_none());
|
||||
// find first empty partition slot (indexing is 1-based for gptman::GPT)
|
||||
let idx_opt = gpt.iter().find(|(_, e)| e.is_unused()).map(|(i, _)| i);
|
||||
let idx = match idx_opt {
|
||||
Some(i) => i,
|
||||
None => return Err("No free GPT partition entries (maxed out)".into()),
|
||||
};
|
||||
|
||||
// assign and write
|
||||
gpt.partitions[idx] = Some(new_entry);
|
||||
gpt[idx] = new_entry;
|
||||
|
||||
// Seek to start (important)
|
||||
file.seek(SeekFrom::Start(0))?;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::tui::disk_manager::DiskManager;
|
||||
use crossterm::event::{self, Event, KeyCode};
|
||||
use std::error::Error;
|
||||
use std::io::Stdout;
|
||||
use tui::{
|
||||
Terminal,
|
||||
backend::CrosstermBackend,
|
||||
|
|
@ -11,7 +10,7 @@ use tui::{
|
|||
};
|
||||
|
||||
pub fn show_main_menu() -> Result<(), Box<dyn Error>> {
|
||||
let mut stdout = std::io::stdout();
|
||||
let stdout = std::io::stdout();
|
||||
let backend = CrosstermBackend::new(stdout);
|
||||
let mut terminal = Terminal::new(backend)?;
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ pub fn show_main_menu() -> Result<(), Box<dyn Error>> {
|
|||
if event::poll(std::time::Duration::from_millis(100))? {
|
||||
if let Event::Key(key) = event::read()? {
|
||||
match key.code {
|
||||
KeyCode::Char('1') => DiskManager::show_disk_manager(&mut terminal)?,
|
||||
KeyCode::Char('1') => DiskManager::run_tui()?,
|
||||
KeyCode::Char('0') => break,
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ impl Theme {
|
|||
}
|
||||
|
||||
impl Settings {
|
||||
#[instrument(skip(terminal))]
|
||||
#[instrument(skip(_terminal))]
|
||||
pub fn show_settings(
|
||||
terminal: &mut Terminal<CrosstermBackend<Stdout>>,
|
||||
_terminal: &mut Terminal<CrosstermBackend<Stdout>>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Render settings UI here
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue