/// Traverse down a parent-to-child link in the namespace.
Traverse down a parent-to-child link in the namespace.
Traverse down a parent - to - child link in the namespace .
pub fn lookup_child(
        &self,
        context: &mut LookupContext,
        task: &Task,
        basename: &FsStr,
    ) -> Result<NamespaceNode, Errno> {
        if !self.entry.node.is_dir() {
            error!(ENOTDIR)
        } else if basename == b"." || basename == b"" {
            Ok(self.clone())
        } else if basename == b".." {
            // TODO: make sure this can't escape a chroot
            Ok(self.parent().unwrap_or_else(|| self.clone()))
        } else {
            let mut child = self.with_new_entry(self.entry.component_lookup(basename)?);
            while child.entry.node.info().mode.is_lnk() {
                match context.symlink_mode {
                    SymlinkMode::NoFollow => {
                        break;
                    }
                    SymlinkMode::Follow => {
                        if context.remaining_follows == 0 {
                            return error!(ELOOP);
                        }
                        context.remaining_follows -= 1;
                        child = match child.entry.node.readlink(task)? {
                            SymlinkTarget::Path(link_target) => {
                                let link_directory = if link_target[0] == b'/' {
                                    task.fs.root.clone()
                                } else {
                                    self.clone()
                                };
                                task.lookup_path(context, link_directory, &link_target)?
                            }
                            SymlinkTarget::Node(node) => node,
                        }
                    }
                };
            }
            if let Some(namespace) = self.namespace() {
                if let Some(mount) = namespace.mount_points.read().get(&child) {
                    return Ok(mount.root());
                }
            }
            Ok(child)
        }
    }
pub fn lookup_child ( & self , context : & mut LookupContext , task : & Task , basename : & FsStr , ) -> Result < NamespaceNode , Errno > { if ! self . entry . node . is_dir ( ) { error ! ( ENOTDIR ) } else if basename == b" " || basename == b" " { Ok ( self . clone ( ) ) } else if basename == b" " { // TODO: make sure this can't escape a chroot Ok ( self . parent ( ) . unwrap_or_else ( | | self . clone ( ) ) ) } else { let mut child = self . with_new_entry ( self . entry . component_lookup ( basename ) ? ) ; while child . entry . node . info ( ) . mode . is_lnk ( ) { match context . symlink_mode { SymlinkMode :: NoFollow => { break ; } SymlinkMode :: Follow => { if context . remaining_follows == 0 { return error ! ( ELOOP ) ; } context . remaining_follows -= 1 ; child = match child . entry . node . readlink ( task ) ? { SymlinkTarget :: Path ( link_target ) => { let link_directory = if link_target [ 0 ] == b'/' { task . fs . root . clone ( ) } else { self . clone ( ) } ; task . lookup_path ( context , link_directory , & link_target ) ? } SymlinkTarget :: Node ( node ) => node , } } } ; } if let Some ( namespace ) = self . namespace ( ) { if let Some ( mount ) = namespace . mount_points . read ( ) . get ( & child ) { return Ok ( mount . root ( ) ) ; } } Ok ( child ) } }
Traverse down a parent-to-child link in the namespace.
Traverse down a parent - to - child link in the namespace .
&self
context
&mut LookupContext
task
&Task
basename
&FsStr