2013-04-16 23:57:41 -04:00
|
|
|
#include <toku_portability.h>
|
2013-04-16 23:57:38 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
static ssize_t (*t_pwrite)(int, const void *, size_t, off_t) = 0;
|
|
|
|
|
2013-04-16 23:57:41 -04:00
|
|
|
int
|
|
|
|
toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_t)) {
|
2013-04-16 23:57:38 -04:00
|
|
|
t_pwrite = pwrite_fun;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t
|
2013-04-16 23:57:41 -04:00
|
|
|
toku_os_pwrite (int fd, const void *buf, size_t len, off_t off) {
|
2013-04-16 23:57:38 -04:00
|
|
|
if (t_pwrite) {
|
|
|
|
return t_pwrite(fd, buf, len, off);
|
|
|
|
} else {
|
|
|
|
return pwrite(fd, buf, len, off);
|
|
|
|
}
|
|
|
|
}
|
2013-04-16 23:57:41 -04:00
|
|
|
|
|
|
|
static ssize_t (*t_write)(int, const void *, size_t) = 0;
|
|
|
|
|
|
|
|
int
|
|
|
|
toku_set_func_write (ssize_t (*write_fun)(int, const void *, size_t)) {
|
|
|
|
t_write = write_fun;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:41 -04:00
|
|
|
ssize_t
|
|
|
|
toku_os_write (int fd, const void *buf, size_t len) {
|
|
|
|
if (t_pwrite) {
|
|
|
|
return t_write(fd, buf, len);
|
|
|
|
} else {
|
|
|
|
return write(fd, buf, len);
|
|
|
|
}
|
|
|
|
}
|
2013-04-16 23:57:41 -04:00
|
|
|
|
|
|
|
|
|
|
|
|