From da74cc98bb34481dad4a31ad65c6479a3cfcb78c Mon Sep 17 00:00:00 2001 From: "Brian L. Troutwine" Date: Wed, 23 Oct 2024 16:48:48 -0700 Subject: [PATCH] documentation improvements Signed-off-by: Brian L. Troutwine --- lading/src/bin/logrotate_fs.rs | 9 ++++----- lading/src/generator/file_gen/model.rs | 10 ++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lading/src/bin/logrotate_fs.rs b/lading/src/bin/logrotate_fs.rs index 84c45be57..ce7f377a2 100644 --- a/lading/src/bin/logrotate_fs.rs +++ b/lading/src/bin/logrotate_fs.rs @@ -119,10 +119,6 @@ fn getattr_helper( ino: attr.inode as u64, size: attr.size, blocks: (attr.size + 511) / 512, - // TODO these times should reflect those in the model, will need to - // be translated from the tick to systemtime. Implies we'll need to - // adjust up from start_time, knowing that a tick is one second - // wide. atime, mtime, ctime, @@ -233,6 +229,9 @@ impl Filesystem for LogrotateFS { // TODO building up a vec of entries here to handle offset really does // suggest that the model needs to be exposed in such a way that this // needn't be done. + // + // Ah, actually, the right buffer to push into is reply.add. There's no + // need for `entries` at all. let mut entries = Vec::new(); // '.' and '..' @@ -248,7 +247,7 @@ impl Filesystem for LogrotateFS { )); } - // reaming children + // remaining children if let Some(child_inodes) = state.readdir(ino as usize) { for child_ino in child_inodes { let file_type = state diff --git a/lading/src/generator/file_gen/model.rs b/lading/src/generator/file_gen/model.rs index cb78f91f6..a544633bd 100644 --- a/lading/src/generator/file_gen/model.rs +++ b/lading/src/generator/file_gen/model.rs @@ -1,7 +1,5 @@ //! Model the internal logic of a logrotate filesystem. -//use lading_payload::block; - use std::collections::{HashMap, HashSet}; use bytes::Bytes; @@ -60,7 +58,7 @@ pub struct File { /// The group ID of this File. So for instance all File instances that are /// called foo.log, foo.log.1 etc have the same group ID. - group_id: u8, + group_id: u16, } impl File { @@ -284,7 +282,7 @@ impl State { let mut names = Vec::new(); names.push(base_name.clone()); // Ordinal 0 for i in 1..=max_rotations { - names.push(format!("{}.{}", base_name, i)); // Ordinal i + names.push(format!("{base_name}.{i}")); // Ordinal i } state.group_names.push(names); } @@ -349,7 +347,7 @@ impl State { new_inode } } else { - panic!("current_inode {} is not a directory", current_inode); + panic!("current_inode {current_inode} is not a directory"); } }; @@ -372,7 +370,7 @@ impl State { read_only: false, ordinal: 0, peer: None, - group_id: group_id as u8, + group_id, }; state.nodes.insert(file_inode, Node::File { file });