fn parse_node(
        &mut self,
        entry: &TocEntry,
        explicit_uidgid: bool,
        version: RafsVersion,
    ) -> Result<Node> {
        let chunks = Vec::new();
        let entry_path = entry.path()?;
        let mut file_size = entry.size;
        let mut flags = RafsV5InodeFlags::default();

        // Parse symlink
        let mut symlink_size = 0;
        let symlink_link_path = entry.symlink_link_path();
        let symlink = if entry.is_symlink() {
            flags |= RafsV5InodeFlags::SYMLINK;
            symlink_size = symlink_link_path.byte_size() as u16;
            file_size = symlink_size.into();
            Some(symlink_link_path.as_os_str().to_owned())
        } else {
            None
        };

        // Parse xattrs
        let mut xattrs = RafsXAttrs::new();
        if entry.has_xattr() {
            for (name, value) in entry.xattrs.iter() {
                flags |= RafsV5InodeFlags::XATTR;
                let value = base64::decode(value).with_context(|| {
                    format!(
                        "parse xattr name {:?} of file {:?} failed",
                        entry_path, name,
                    )
                })?;
                xattrs.add(name.into(), value);
            }
        }

        // Handle hardlink ino
        let mut ino = (self.path_inode_map.len() + 1) as Inode;
        if entry.is_hardlink() {
            flags |= RafsV5InodeFlags::HARDLINK;
            if let Some(_ino) = self.path_inode_map.get(&entry.hardlink_link_path()) {
                ino = *_ino;
            } else {
                self.path_inode_map.insert(entry.path()?, ino);
            }
        } else {
            self.path_inode_map.insert(entry.path()?, ino);
        }

        // Get file name size
        let name_size = entry.name()?.as_os_str().byte_size() as u16;
        let uid = if explicit_uidgid { entry.uid } else { 0 };
        let gid = if explicit_uidgid { entry.gid } else { 0 };

        // Parse inode info
        let inode = match version {
            RafsVersion::V5 => {
                InodeWrapper::V5(RafsV5Inode {
                    i_digest: RafsDigest::default(),
                    i_parent: 0,
                    i_ino: ino,
                    i_projid: 0,
                    i_uid: uid,
                    i_gid: gid,
                    i_mode: entry.mode(),
                    i_size: file_size,
                    i_nlink: entry.num_link,
                    i_blocks: 0,
                    i_flags: flags,
                    i_child_index: 0,
                    i_child_count: 0,
                    i_name_size: name_size,
                    i_symlink_size: symlink_size,
                    i_rdev: entry.rdev(),
                    // TODO: add mtime from entry.ModTime()
                    i_mtime: 0,
                    i_mtime_nsec: 0,
                    i_reserved: [0; 8],
                })
            }
            RafsVersion::V6 => todo!(),
        };

        let path = entry.path()?;
        let source = PathBuf::from_str("/").unwrap();
        let target = Node::generate_target(&path, &source);
        let target_vec = Node::generate_target_vec(&target);

        Ok(Node {
            index: 0,
            src_ino: ino,
            src_dev: u64::MAX,
            rdev: entry.rdev() as u64,
            overlay: Overlay::UpperAddition,
            explicit_uidgid,
            source,
            target,
            path,
            target_vec,
            inode,
            chunks,
            symlink,
            xattrs,
            ctime: 0,
            offset: 0,
            dirents: Vec::<(u64, OsString, u32)>::new(),
            v6_datalayout: 0,
        })
    }
/// Parse stargz toc entry to Node in builder
Parse stargz toc entry to Node in builder
Parse stargz toc entry to Node in builder
fn parse_node(
        &mut self,
        entry: &TocEntry,
        explicit_uidgid: bool,
        version: RafsVersion,
    ) -> Result<Node> {
        let chunks = Vec::new();
        let entry_path = entry.path()?;
        let mut file_size = entry.size;
        let mut flags = RafsV5InodeFlags::default();
        // Parse symlink
        let mut symlink_size = 0;
        let symlink_link_path = entry.symlink_link_path();
        let symlink = if entry.is_symlink() {
            flags |= RafsV5InodeFlags::SYMLINK;
            symlink_size = symlink_link_path.byte_size() as u16;
            file_size = symlink_size.into();
            Some(symlink_link_path.as_os_str().to_owned())
        } else {
            None
        };
        // Parse xattrs
        let mut xattrs = RafsXAttrs::new();
        if entry.has_xattr() {
            for (name, value) in entry.xattrs.iter() {
                flags |= RafsV5InodeFlags::XATTR;
                let value = base64::decode(value).with_context(|| {
                    format!(
                        "parse xattr name {:?} of file {:?} failed",
                        entry_path, name,
                    )
                })?;
                xattrs.add(name.into(), value);
            }
        }
        // Handle hardlink ino
        let mut ino = (self.path_inode_map.len() + 1) as Inode;
        if entry.is_hardlink() {
            flags |= RafsV5InodeFlags::HARDLINK;
            if let Some(_ino) = self.path_inode_map.get(&entry.hardlink_link_path()) {
                ino = *_ino;
            } else {
                self.path_inode_map.insert(entry.path()?, ino);
            }
        } else {
            self.path_inode_map.insert(entry.path()?, ino);
        }
        // Get file name size
        let name_size = entry.name()?.as_os_str().byte_size() as u16;
        let uid = if explicit_uidgid { entry.uid } else { 0 };
        let gid = if explicit_uidgid { entry.gid } else { 0 };
        // Parse inode info
        let inode = match version {
            RafsVersion::V5 => {
                InodeWrapper::V5(RafsV5Inode {
                    i_digest: RafsDigest::default(),
                    i_parent: 0,
                    i_ino: ino,
                    i_projid: 0,
                    i_uid: uid,
                    i_gid: gid,
                    i_mode: entry.mode(),
                    i_size: file_size,
                    i_nlink: entry.num_link,
                    i_blocks: 0,
                    i_flags: flags,
                    i_child_index: 0,
                    i_child_count: 0,
                    i_name_size: name_size,
                    i_symlink_size: symlink_size,
                    i_rdev: entry.rdev(),
                    // TODO: add mtime from entry.ModTime()
                    i_mtime: 0,
                    i_mtime_nsec: 0,
                    i_reserved: [0; 8],
                })
            }
            RafsVersion::V6 => todo!(),
        };
        let path = entry.path()?;
        let source = PathBuf::from_str("/").unwrap();
        let target = Node::generate_target(&path, &source);
        let target_vec = Node::generate_target_vec(&target);
        Ok(Node {
            index: 0,
            src_ino: ino,
            src_dev: u64::MAX,
            rdev: entry.rdev() as u64,
            overlay: Overlay::UpperAddition,
            explicit_uidgid,
            source,
            target,
            path,
            target_vec,
            inode,
            chunks,
            symlink,
            xattrs,
            ctime: 0,
            offset: 0,
            dirents: Vec::<(u64, OsString, u32)>::new(),
            v6_datalayout: 0,
        })
    }
fn parse_node ( & mut self , entry : & TocEntry , explicit_uidgid : bool , version : RafsVersion , ) -> Result < Node > { let chunks = Vec :: new ( ) ; let entry_path = entry . path ( ) ? ; let mut file_size = entry . size ; let mut flags = RafsV5InodeFlags :: default ( ) ; // Parse symlink let mut symlink_size = 0 ; let symlink_link_path = entry . symlink_link_path ( ) ; let symlink = if entry . is_symlink ( ) { flags |= RafsV5InodeFlags :: SYMLINK ; symlink_size = symlink_link_path . byte_size ( ) as u16 ; file_size = symlink_size . into ( ) ; Some ( symlink_link_path . as_os_str ( ) . to_owned ( ) ) } else { None } ; // Parse xattrs let mut xattrs = RafsXAttrs :: new ( ) ; if entry . has_xattr ( ) { for ( name , value ) in entry . xattrs . iter ( ) { flags |= RafsV5InodeFlags :: XATTR ; let value = base64 :: decode ( value ) . with_context ( | | { format ! ( " " entry_path name ) } ) ? ; xattrs . add ( name . into ( ) , value ) ; } } // Handle hardlink ino let mut ino = ( self . path_inode_map . len ( ) + 1 ) as Inode ; if entry . is_hardlink ( ) { flags |= RafsV5InodeFlags :: HARDLINK ; if let Some ( _ino ) = self . path_inode_map . get ( & entry . hardlink_link_path ( ) ) { ino = * _ino ; } else { self . path_inode_map . insert ( entry . path ( ) ? , ino ) ; } } else { self . path_inode_map . insert ( entry . path ( ) ? , ino ) ; } // Get file name size let name_size = entry . name ( ) ? . as_os_str ( ) . byte_size ( ) as u16 ; let uid = if explicit_uidgid { entry . uid } else { 0 } ; let gid = if explicit_uidgid { entry . gid } else { 0 } ; // Parse inode info let inode = match version { RafsVersion :: V5 => { InodeWrapper :: V5 ( RafsV5Inode { i_digest : RafsDigest :: default ( ) , i_parent : 0 , i_ino : ino , i_projid : 0 , i_uid : uid , i_gid : gid , i_mode : entry . mode ( ) , i_size : file_size , i_nlink : entry . num_link , i_blocks : 0 , i_flags : flags , i_child_index : 0 , i_child_count : 0 , i_name_size : name_size , i_symlink_size : symlink_size , i_rdev : entry . rdev ( ) , // TODO: add mtime from entry.ModTime() i_mtime : 0 , i_mtime_nsec : 0 , i_reserved : [ 0 ; 8 ] , } ) } RafsVersion :: V6 => todo ! ( ) , } ; let path = entry . path ( ) ? ; let source = PathBuf :: from_str ( " " ) . unwrap ( ) ; let target = Node :: generate_target ( & path , & source ) ; let target_vec = Node :: generate_target_vec ( & target ) ; Ok ( Node { index : 0 , src_ino : ino , src_dev : u64 :: MAX , rdev : entry . rdev ( ) as u64 , overlay : Overlay :: UpperAddition , explicit_uidgid , source , target , path , target_vec , inode , chunks , symlink , xattrs , ctime : 0 , offset : 0 , dirents : Vec :: < ( u64 , OsString , u32 ) > :: new ( ) , v6_datalayout : 0 , } ) }
Parse stargz toc entry to Node in builder
Parse stargz toc entry to Node in builder
&mut self
entry
&TocEntry
explicit_uidgid
bool
version
RafsVersion
&mut self
entry
&TocEntry
explicit_uidgid
bool
version
RafsVersion