Skip to content

Commit

Permalink
documentation improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
  • Loading branch information
blt committed Oct 23, 2024
1 parent 1192eef commit a56426e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 4 additions & 5 deletions lading/src/bin/logrotate_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 '..'
Expand All @@ -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
Expand Down
12 changes: 5 additions & 7 deletions lading/src/generator/file_gen/model.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Model the internal logic of a logrotate filesystem.
//use lading_payload::block;

use std::collections::{HashMap, HashSet};

use bytes::Bytes;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -199,7 +197,7 @@ impl std::fmt::Debug for State {
.field("max_bytes_per_file", &self.max_bytes_per_file)
.field("group_names", &self.group_names)
.field("next_inode", &self.next_inode)
.finish()
.finish_non_exhaustive()
}
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
}
};

Expand All @@ -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 });

Expand Down

0 comments on commit a56426e

Please sign in to comment.