fn parse_node(&mut self, entry: &TocEntry, explicit_uidgid: bool) -> Result<Node> {
        let chunks = Vec::new();
        let entry_path = entry.path()?;
        let symlink_link_path = entry.symlink_link_path();

        let mut flags = RafsInodeFlags::default();

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

        // Parse xattrs
        let mut xattrs = XAttrs {
            pairs: HashMap::new(),
        };
        if entry.has_xattr() {
            for (name, value) in entry.xattrs.iter() {
                flags |= RafsInodeFlags::XATTR;
                let value = base64::decode(value).map_err(|err| {
                    einval!(format!(
                        "parse value of xattr {:?} failed: {:?}, file {:?}",
                        entry_path, name, err
                    ))
                })?;
                xattrs.pairs.insert(name.into(), value);
            }
        }

        // Handle hardlink ino
        let mut ino = (self.path_inode_map.len() + 1) as Inode;
        if entry.is_hardlink() {
            flags |= RafsInodeFlags::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().as_bytes().len() 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 = OndiskInode {
            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_reserved: [0; 24],
        };

        Ok(Node {
            index: 0,
            real_ino: ino,
            dev: std::u64::MAX,
            overlay: Overlay::UpperAddition,
            explicit_uidgid,
            source: PathBuf::from_str("/").unwrap(),
            path: entry.path()?,
            inode,
            chunks,
            symlink,
            xattrs,
        })
    }
/// 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) -> Result<Node> {
        let chunks = Vec::new();
        let entry_path = entry.path()?;
        let symlink_link_path = entry.symlink_link_path();
        let mut flags = RafsInodeFlags::default();
        // Parse symlink
        let mut file_size = entry.size;
        let mut symlink_size = 0;
        let symlink = if entry.is_symlink() {
            flags |= RafsInodeFlags::SYMLINK;
            symlink_size = symlink_link_path.as_os_str().as_bytes().len() as u16;
            file_size = symlink_size.into();
            Some(symlink_link_path.as_os_str().to_owned())
        } else {
            None
        };
        // Parse xattrs
        let mut xattrs = XAttrs {
            pairs: HashMap::new(),
        };
        if entry.has_xattr() {
            for (name, value) in entry.xattrs.iter() {
                flags |= RafsInodeFlags::XATTR;
                let value = base64::decode(value).map_err(|err| {
                    einval!(format!(
                        "parse value of xattr {:?} failed: {:?}, file {:?}",
                        entry_path, name, err
                    ))
                })?;
                xattrs.pairs.insert(name.into(), value);
            }
        }
        // Handle hardlink ino
        let mut ino = (self.path_inode_map.len() + 1) as Inode;
        if entry.is_hardlink() {
            flags |= RafsInodeFlags::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().as_bytes().len() 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 = OndiskInode {
            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_reserved: [0; 24],
        };
        Ok(Node {
            index: 0,
            real_ino: ino,
            dev: std::u64::MAX,
            overlay: Overlay::UpperAddition,
            explicit_uidgid,
            source: PathBuf::from_str("/").unwrap(),
            path: entry.path()?,
            inode,
            chunks,
            symlink,
            xattrs,
        })
    }
fn parse_node ( & mut self , entry : & TocEntry , explicit_uidgid : bool ) -> Result < Node > { let chunks = Vec :: new ( ) ; let entry_path = entry . path ( ) ? ; let symlink_link_path = entry . symlink_link_path ( ) ; let mut flags = RafsInodeFlags :: default ( ) ; // Parse symlink let mut file_size = entry . size ; let mut symlink_size = 0 ; let symlink = if entry . is_symlink ( ) { flags |= RafsInodeFlags :: SYMLINK ; symlink_size = symlink_link_path . as_os_str ( ) . as_bytes ( ) . len ( ) as u16 ; file_size = symlink_size . into ( ) ; Some ( symlink_link_path . as_os_str ( ) . to_owned ( ) ) } else { None } ; // Parse xattrs let mut xattrs = XAttrs { pairs : HashMap :: new ( ) , } ; if entry . has_xattr ( ) { for ( name , value ) in entry . xattrs . iter ( ) { flags |= RafsInodeFlags :: XATTR ; let value = base64 :: decode ( value ) . map_err ( | err | { einval ! ( format ( " " entry_path name err ) ) } ) ? ; xattrs . pairs . insert ( name . into ( ) , value ) ; } } // Handle hardlink ino let mut ino = ( self . path_inode_map . len ( ) + 1 ) as Inode ; if entry . is_hardlink ( ) { flags |= RafsInodeFlags :: 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 ( ) . as_bytes ( ) . len ( ) 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 = OndiskInode { 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_reserved : [ 0 ; 24 ] , } ; Ok ( Node { index : 0 , real_ino : ino , dev : std :: u64 :: MAX , overlay : Overlay :: UpperAddition , explicit_uidgid , source : PathBuf :: from_str ( " " ) . unwrap ( ) , path : entry . path ( ) ? , inode , chunks , symlink , xattrs , } ) }
Parse stargz toc entry to Node in builder
Parse stargz toc entry to Node in builder
&mut self
entry
&TocEntry
explicit_uidgid
bool
&mut self
entry
&TocEntry
explicit_uidgid
bool