MCPcopy Create free account
hub / github.com/bytecodealliance/system-interface / append_vectored

Method append_vectored

src/fs/file_io_ext.rs:560–586  ·  view source on GitHub ↗
(&self, bufs: &[IoSlice])

Source from the content-addressed store, hash-verified

558 }
559
560 fn append_vectored(&self, bufs: &[IoSlice]) -> io::Result<usize> {
561 use rustix::fs::{fcntl_getfl, fcntl_setfl, seek, OFlags, SeekFrom};
562 use rustix::io::writev;
563
564 // On Linux, use `pwritev2`.
565 #[cfg(any(target_os = "android", target_os = "linux"))]
566 {
567 use rustix::io::{pwritev2, Errno, ReadWriteFlags};
568
569 match pwritev2(self, bufs, 0, ReadWriteFlags::APPEND) {
570 Err(Errno::NOSYS) | Err(Errno::NOTSUP) => {}
571 otherwise => return Ok(otherwise?),
572 }
573 }
574
575 // Otherwise use `F_SETFL` to switch the file description to append
576 // mode, do the write, and switch back. This is not atomic with
577 // respect to other users of the file description, but this is
578 // possibility is documented in the trait.
579 let old_flags = fcntl_getfl(self)?;
580 let old_pos = tell(self)?;
581 fcntl_setfl(self, old_flags | OFlags::APPEND)?;
582 let result = writev(self, bufs);
583 fcntl_setfl(self, old_flags).unwrap();
584 seek(self, SeekFrom::Start(old_pos)).unwrap();
585 Ok(result?)
586 }
587
588 #[inline]
589 fn is_append_vectored(&self) -> bool {

Callers 1

append_all_vectoredMethod · 0.45

Calls 2

reopen_appendFunction · 0.85
write_vectoredMethod · 0.80

Tested by

no test coverage detected