Skip to content
Snippets Groups Projects
Verified Commit d818a8d1 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Add pwrite

parent 8a042a22
No related branches found
No related tags found
No related merge requests found
Pipeline #1909 passed with warnings
...@@ -417,14 +417,30 @@ pub extern "C" fn pthread_atfork( ...@@ -417,14 +417,30 @@ pub extern "C" fn pthread_atfork(
unimplemented!(); unimplemented!();
} }
// #[no_mangle] #[no_mangle]
pub extern "C" fn pwrite( pub extern "C" fn pwrite(
fildes: c_int, fildes: c_int,
buf: *const c_void, buf: *const c_void,
nbyte: size_t, nbyte: size_t,
offset: off_t, offset: off_t,
) -> ssize_t { ) -> ssize_t {
unimplemented!(); //TODO: better pwrite using system calls
let previous = lseek(fildes, offset, SEEK_SET);
if previous == -1 {
return -1;
}
let res = write(fildes, buf, nbyte);
if res < 0 {
return res;
}
if lseek(fildes, previous, SEEK_SET) == -1 {
return -1;
}
res
} }
#[no_mangle] #[no_mangle]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment