Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom debug for DirEntry and DirectoryIndex #296

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! For each directory inode, the directory table stores a linear list of all entries,
//! with references back to the inodes that describe those entries.

use core::fmt;
use std::ffi::OsStr;
use std::os::unix::prelude::OsStrExt;
use std::path::{Component, Path};
Expand Down Expand Up @@ -48,8 +47,7 @@ impl Dir {
}
}

// TODO: derive our own Debug, with name()
#[derive(DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[derive(Debug, DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[deku(endian = "endian", ctx = "endian: deku::ctx::Endian")]
pub struct DirEntry {
/// An offset into the uncompressed inode metadata block.
Expand All @@ -66,18 +64,6 @@ pub struct DirEntry {
pub(crate) name: Vec<u8>,
}

impl fmt::Debug for DirEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DirEntry")
.field("offset", &self.offset)
.field("inode_offset", &self.inode_offset)
.field("t", &self.t)
.field("name_size", &self.name_size)
.field("name", &self.name())
.finish()
}
}

impl DirEntry {
pub fn name(&self) -> Result<&Path, BackhandError> {
// allow root and nothing else
Expand All @@ -94,7 +80,7 @@ impl DirEntry {
}
}

#[derive(DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[derive(Debug, DekuRead, DekuWrite, Clone, PartialEq, Eq)]
#[deku(endian = "endian", ctx = "endian: deku::ctx::Endian")]
pub struct DirectoryIndex {
/// This stores a byte offset from the first directory header to the current header,
Expand All @@ -108,17 +94,6 @@ pub struct DirectoryIndex {
pub(crate) name: Vec<u8>,
}

impl fmt::Debug for DirectoryIndex {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DirectoryIndex")
.field("index", &self.index)
.field("start", &self.start)
.field("name_size", &self.name_size)
.field("name", &self.name())
.finish()
}
}

impl DirectoryIndex {
pub fn name(&self) -> String {
std::str::from_utf8(&self.name).unwrap().to_string()
Expand Down