pub fn sys_openat(
        &self,
        dir_fd: FileDesc,
        path: UserInPtr<u8>,
        flags: usize,
        mode: usize,
    ) -> SysResult {
        let proc = self.linux_process();
        let path = path.read_cstring()?;
        let flags = OpenFlags::from_bits_truncate(flags);
        info!(
            "openat: dir_fd={:?}, path={:?}, flags={:?}, mode={:#o}",
            dir_fd, path, flags, mode
        );

        let inode = if flags.contains(OpenFlags::CREATE) {
            let (dir_path, file_name) = split_path(&path);
            // relative to cwd
            let dir_inode = proc.lookup_inode_at(dir_fd, dir_path, true)?;
            match dir_inode.find(file_name) {
                Ok(file_inode) => {
                    if flags.contains(OpenFlags::EXCLUSIVE) {
                        return Err(LxError::EEXIST);
                    }
                    file_inode
                }
                Err(FsError::EntryNotFound) => {
                    dir_inode.create(file_name, FileType::File, mode as u32)?
                }
                Err(e) => return Err(LxError::from(e)),
            }
        } else {
            proc.lookup_inode_at(dir_fd, &path, true)?
        };

        let file = File::new(inode, flags, path);
        let fd = proc.add_file(file)?;
        Ok(fd.into())
    }
/// open file relative to directory file descriptor
open file relative to directory file descriptor
open file relative to directory file descriptor
pub fn sys_openat(
        &self,
        dir_fd: FileDesc,
        path: UserInPtr<u8>,
        flags: usize,
        mode: usize,
    ) -> SysResult {
        let proc = self.linux_process();
        let path = path.read_cstring()?;
        let flags = OpenFlags::from_bits_truncate(flags);
        info!(
            "openat: dir_fd={:?}, path={:?}, flags={:?}, mode={:#o}",
            dir_fd, path, flags, mode
        );
        let inode = if flags.contains(OpenFlags::CREATE) {
            let (dir_path, file_name) = split_path(&path);
            // relative to cwd
            let dir_inode = proc.lookup_inode_at(dir_fd, dir_path, true)?;
            match dir_inode.find(file_name) {
                Ok(file_inode) => {
                    if flags.contains(OpenFlags::EXCLUSIVE) {
                        return Err(LxError::EEXIST);
                    }
                    file_inode
                }
                Err(FsError::EntryNotFound) => {
                    dir_inode.create(file_name, FileType::File, mode as u32)?
                }
                Err(e) => return Err(LxError::from(e)),
            }
        } else {
            proc.lookup_inode_at(dir_fd, &path, true)?
        };
        let file = File::new(inode, flags, path);
        let fd = proc.add_file(file)?;
        Ok(fd.into())
    }
pub fn sys_openat ( & self , dir_fd : FileDesc , path : UserInPtr < u8 > , flags : usize , mode : usize , ) -> SysResult { let proc = self . linux_process ( ) ; let path = path . read_cstring ( ) ? ; let flags = OpenFlags :: from_bits_truncate ( flags ) ; info ! ( " " dir_fd path flags mode ) ; let inode = if flags . contains ( OpenFlags :: CREATE ) { let ( dir_path , file_name ) = split_path ( & path ) ; // relative to cwd let dir_inode = proc . lookup_inode_at ( dir_fd , dir_path , true ) ? ; match dir_inode . find ( file_name ) { Ok ( file_inode ) => { if flags . contains ( OpenFlags :: EXCLUSIVE ) { return Err ( LxError :: EEXIST ) ; } file_inode } Err ( FsError :: EntryNotFound ) => { dir_inode . create ( file_name , FileType :: File , mode as u32 ) ? } Err ( e ) => return Err ( LxError :: from ( e ) ) , } } else { proc . lookup_inode_at ( dir_fd , & path , true ) ? } ; let file = File :: new ( inode , flags , path ) ; let fd = proc . add_file ( file ) ? ; Ok ( fd . into ( ) ) }
open file relative to directory file descriptor
open file relative to directory file descriptor
&self
dir_fd
FileDesc
path
UserInPtr<u8>
flags
usize
mode
usize
&self
dir_fd
FileDesc
path
UserInPtr<u8>
flags
usize
mode
usize