This source file includes following definitions.
- IrtClose
- IrtDup
- IrtDup2
- IrtRead
- IrtWrite
- IrtSeek
- IrtFstat
- IrtGetDents
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "base/logging.h"
#include "components/nacl/loader/nonsfi/abi_conversion.h"
#include "components/nacl/loader/nonsfi/irt_interfaces.h"
#include "components/nacl/loader/nonsfi/irt_util.h"
#include "native_client/src/trusted/service_runtime/include/sys/dirent.h"
#include "native_client/src/trusted/service_runtime/include/sys/stat.h"
#include "native_client/src/trusted/service_runtime/include/sys/unistd.h"
namespace nacl {
namespace nonsfi {
namespace {
int IrtClose(int fd) {
return CheckError(close(fd));
}
int IrtDup(int fd, int* newfd) {
return CheckErrorWithResult(dup(fd), newfd);
}
int IrtDup2(int fd, int newfd) {
return CheckError(dup2(fd, newfd));
}
int IrtRead(int fd, void* buf, size_t count, size_t* nread) {
return CheckErrorWithResult(read(fd, buf, count), nread);
}
int IrtWrite(int fd, const void* buf, size_t count, size_t* nwrote) {
return CheckErrorWithResult(write(fd, buf, count), nwrote);
}
int IrtSeek(int fd, nacl_abi_off_t offset, int whence,
nacl_abi_off_t* new_offset) {
return CheckErrorWithResult(lseek(fd, offset, whence), new_offset);
}
int IrtFstat(int fd, struct nacl_abi_stat* st) {
struct stat host_st;
if (fstat(fd, &host_st))
return errno;
StatToNaClAbiStat(host_st, st);
return 0;
}
int IrtGetDents(int fd, struct nacl_abi_dirent* buf, size_t count,
size_t* nread) {
return ENOSYS;
}
}
const nacl_irt_fdio kIrtFdIO = {
IrtClose,
IrtDup,
IrtDup2,
IrtRead,
IrtWrite,
reinterpret_cast<int(*)(int, off_t, int, off_t*)>(IrtSeek),
reinterpret_cast<int(*)(int, struct stat*)>(IrtFstat),
reinterpret_cast<int(*)(int, struct dirent*, size_t, size_t*)>(IrtGetDents),
};
}
}