return REAL(munmap)(addr, length);
}
-int WRAP(open)(const char* pathname, int oflag, mode_t cmode, int* newfd) {
- *newfd = ki_open(pathname, oflag);
+int WRAP(open)(const char* pathname, int oflag, mode_t mode, int* newfd) {
+ *newfd = ki_open(pathname, oflag, mode);
ERRNO_RTN(*newfd);
}
}
#define CHECK_REAL(func) \
- if (!REAL(func)) \
- assign_real_pointers();
+ if (!REAL(func)) { \
+ assign_real_pointers(); \
+ if (!REAL(func)) \
+ return ENOSYS; \
+ }
// "real" functions, i.e. the unwrapped original functions.
int _real_lstat(const char* path, struct stat* buf) {
struct nacl_abi_stat st;
- CHECK_REAL(fstat);
+ CHECK_REAL(lstat);
int err = REAL(lstat)(path, (struct stat*)&st);
if (err) {
return REAL(munmap)(addr, length);
}
-int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) {
+int _real_open(const char* pathname, int oflag, mode_t mode, int* newfd) {
CHECK_REAL(open);
- return REAL(open)(pathname, oflag, cmode, newfd);
+ return REAL(open)(pathname, oflag, mode, newfd);
}
int _real_open_resource(const char* file, int* fd) {
return REAL(write)(fd, buf, count, nwrote);
}
+int _real_getcwd(char* pathname, size_t len) {
+ CHECK_REAL(getcwd);
+ return REAL(getcwd)(pathname, len);
+}
+
static bool s_wrapped = false;
+
void kernel_wrap_init() {
if (!s_wrapped) {
assign_real_pointers();
EXTERN_C_END
-#endif // defined(__native_client__) && defined(__GLIBC__)
+#endif // defined(__native_client__) && defined(__BIONIC__)