diff options
author | sbc <sbc@chromium.org> | 2015-01-13 13:33:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-13 21:35:01 +0000 |
commit | 4fad785312ac90ea3dd6e34926f30adee442ff89 (patch) | |
tree | 3096fd8acf088ba06aee224ee7eb2ce878996e67 /native_client_sdk | |
parent | 523d40e3b328ed3d3d16a9c6fb3bd9a9d2691956 (diff) | |
download | chromium_src-4fad785312ac90ea3dd6e34926f30adee442ff89.zip chromium_src-4fad785312ac90ea3dd6e34926f30adee442ff89.tar.gz chromium_src-4fad785312ac90ea3dd6e34926f30adee442ff89.tar.bz2 |
NaCl SDK] nacl_io: remove getcwd() implemenation (rely on glibc/newlib versions)
The newlib version of getcwd in libnacl now supports
passing NULL of buffer, and recent version of gtest
will gracefully handle getcwd failure in static
constructors so we no longer need our own getcwd
implementation.
This is the second attempt and landing this change. The
first was reverted:
https://codereview.chromium.org/756333005
R=bradnelson
Review URL: https://codereview.chromium.org/851723004
Cr-Commit-Position: refs/heads/master@{#311329}
Diffstat (limited to 'native_client_sdk')
3 files changed, 1 insertions, 47 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc index 4d1e1b6..394cea6 100644 --- a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc +++ b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc @@ -149,22 +149,7 @@ void ki_exit(int status) { } char* ki_getcwd(char* buf, size_t size) { - // gtest uses getcwd in a static initializer and expects it to always - // succeed. If we haven't initialized kernel-intercept yet, then try - // the IRT's getcwd, and fall back to just returning ".". - if (!ki_is_initialized()) { - int rtn = _real_getcwd(buf, size); - if (rtn != 0) { - if (rtn == ENOSYS) { - buf[0] = '.'; - buf[1] = 0; - } else { - errno = rtn; - return NULL; - } - } - return buf; - } + ON_NOSYS_RETURN(NULL); return s_state.kp->getcwd(buf, size); } diff --git a/native_client_sdk/src/libraries/nacl_io/library.dsc b/native_client_sdk/src/libraries/nacl_io/library.dsc index ddf1ba5..2fce549 100644 --- a/native_client_sdk/src/libraries/nacl_io/library.dsc +++ b/native_client_sdk/src/libraries/nacl_io/library.dsc @@ -72,7 +72,6 @@ "syscalls/fcntl.c", "syscalls/ftruncate.c", "syscalls/futimes.c", - "syscalls/getcwd.c", "syscalls/getwd.c", "syscalls/ioctl.c", "syscalls/isatty.c", diff --git a/native_client_sdk/src/libraries/nacl_io/syscalls/getcwd.c b/native_client_sdk/src/libraries/nacl_io/syscalls/getcwd.c deleted file mode 100644 index 5e702ca..0000000 --- a/native_client_sdk/src/libraries/nacl_io/syscalls/getcwd.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. */ - -#include <limits.h> -#include <string.h> - -#include "nacl_io/kernel_intercept.h" -#include "nacl_io/kernel_wrap.h" - -/* - * This interception should not really be needed under glibc since we can - * hook the internal calls to getcwd. However, we need to intercept it here - * since gtest call getcwd in a static constructor which general runs before - * nacl_io is initiliased. - */ -char* getcwd(char* buf, size_t size) { - // If size is 0, allocate as much as we need. - if (size == 0) { - char stack_buf[PATH_MAX + 1]; - if (!ki_getcwd(stack_buf, PATH_MAX)) - return NULL; - size = strlen(stack_buf) + 1; - } - // Allocate the buffer if needed - if (buf == NULL) { - buf = (char*)malloc(size); - } - return ki_getcwd(buf, size); -} |