Skip to content

Commit

Permalink
nydus-image: refactor subcommand "inspect"
Browse files Browse the repository at this point in the history
The code for "nydus-image inspect" are refactored using standard API
in RAFS.

Signed-off-by: YushuoEdge <[email protected]>
  • Loading branch information
YushuoEdge committed Aug 27, 2022
1 parent 557acc0 commit 4ff80f6
Show file tree
Hide file tree
Showing 2 changed files with 339 additions and 701 deletions.
23 changes: 23 additions & 0 deletions rafs/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use serde::Serialize;
use serde_with::{serde_as, DisplayFromStr};
use storage::device::{BlobChunkInfo, BlobInfo, BlobIoMerge, BlobIoVec};

use self::layout::v5::RafsV5PrefetchTable;
use self::layout::v6::RafsV6PrefetchTable;
use self::layout::{XattrName, XattrValue, RAFS_SUPER_VERSION_V5, RAFS_SUPER_VERSION_V6};
use self::noop::NoopSuperBlock;
use crate::fs::{RafsConfig, RAFS_DEFAULT_ATTR_TIMEOUT, RAFS_DEFAULT_ENTRY_TIMEOUT};
Expand Down Expand Up @@ -742,6 +744,27 @@ impl RafsSuper {
Ok(())
}

/// Get prefetched inos
pub fn get_prefetched_inos(&self, bootstrap: &mut RafsIoReader) -> Result<Vec<u32>> {
if self.meta.is_v5() {
let mut pt = RafsV5PrefetchTable::new();
pt.load_prefetch_table_from(
bootstrap,
self.meta.prefetch_table_offset,
self.meta.prefetch_table_entries as usize,
)?;
Ok(pt.inodes)
} else {
let mut pt = RafsV6PrefetchTable::new();
pt.load_prefetch_table_from(
bootstrap,
self.meta.prefetch_table_offset,
self.meta.prefetch_table_entries as usize,
)?;
Ok(pt.inodes)
}
}

/// Walkthrough the file tree rooted at ino, calling cb for each file or directory
/// in the tree by DFS order, including ino, please ensure ino is a directory.
pub fn walk_dir(
Expand Down
Loading

0 comments on commit 4ff80f6

Please sign in to comment.