fn check_flags()

in integrations/virtiofs/src/filesystem.rs [244:260]


    fn check_flags(&self, flags: u32) -> Result<(bool, bool)> {
        let is_trunc = flags & libc::O_TRUNC as u32 != 0 || flags & libc::O_CREAT as u32 != 0;
        let is_append = flags & libc::O_APPEND as u32 != 0;

        let mode = flags & libc::O_ACCMODE as u32;
        let is_write = mode == libc::O_WRONLY as u32 || mode == libc::O_RDWR as u32 || is_append;

        let capability = self.core.info().full_capability();
        if is_trunc && !capability.write {
            Err(Error::from(libc::EACCES))?;
        }
        if is_append && !capability.write_can_append {
            Err(Error::from(libc::EACCES))?;
        }

        Ok((is_write, is_append))
    }