MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / is_writable

Method is_writable

block/src/qcow/raw_file.rs:125–133  ·  view source on GitHub ↗

Returns true if the file was opened with write access.

(&self)

Source from the content-addressed store, hash-verified

123
124 /// Returns true if the file was opened with write access.
125 pub fn is_writable(&self) -> bool {
126 // SAFETY: fcntl with F_GETFL is safe and doesn't modify the file descriptor
127 let flags = unsafe { libc::fcntl(self.file.as_raw_fd(), libc::F_GETFL) };
128 if flags < 0 {
129 return false;
130 }
131 let access_mode = flags & libc::O_ACCMODE;
132 access_mode == libc::O_WRONLY || access_mode == libc::O_RDWR
133 }
134}
135
136impl Read for RawFile {

Callers 3

parse_qcowFunction · 0.80
dropMethod · 0.80
shutdownMethod · 0.80

Calls 2

fcntlFunction · 0.85
as_raw_fdMethod · 0.45

Tested by

no test coverage detected