Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Unified Diff: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc

Issue 99203014: [NaCl SDK] Map active fds to absolute paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Conform to style guide Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
index 672f51c30825aa1c9a8b4febf07f1047128e7b0c..8fe8f9aab879f0fb368eebbd65b722a4d8abf98c 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -172,7 +172,7 @@ int KernelProxy::open_resource(const char* path) {
return -1;
}
- return AllocateFD(handle);
+ return AllocateFD(handle, path);
}
int KernelProxy::open(const char* path, int open_flags) {
@@ -192,7 +192,7 @@ int KernelProxy::open(const char* path, int open_flags) {
return -1;
}
- return AllocateFD(handle);
+ return AllocateFD(handle, path);
}
int KernelProxy::pipe(int pipefds[2]) {
@@ -233,13 +233,13 @@ int KernelProxy::close(int fd) {
int KernelProxy::dup(int oldfd) {
ScopedKernelHandle handle;
- Error error = AcquireHandle(oldfd, &handle);
+ std::string path;
+ Error error = AcquireHandleAndPath(oldfd, &handle, &path);
if (error) {
errno = error;
return -1;
}
-
- return AllocateFD(handle);
+ return AllocateFD(handle, path);
}
int KernelProxy::dup2(int oldfd, int newfd) {
@@ -248,13 +248,14 @@ int KernelProxy::dup2(int oldfd, int newfd) {
return newfd;
ScopedKernelHandle old_handle;
- Error error = AcquireHandle(oldfd, &old_handle);
+ std::string old_path;
+ Error error = AcquireHandleAndPath(oldfd, &old_handle, &old_path);
if (error) {
errno = error;
return -1;
}
- FreeAndReassignFD(newfd, old_handle);
+ FreeAndReassignFD(newfd, old_handle, old_path);
return newfd;
}
@@ -514,8 +515,31 @@ int KernelProxy::getdents(int fd, void* buf, unsigned int count) {
}
int KernelProxy::fchdir(int fd) {
- errno = ENOSYS;
- return -1;
+ ScopedKernelHandle handle;
+ std::string path;
+ Error error = AcquireHandleAndPath(fd, &handle, &path);
+ if (error) {
+ errno = error;
+ return -1;
+ }
+
+ if (!handle->node()->IsaDir()) {
+ errno = ENOTDIR;
+ return -1;
+ }
+
+ if (path.empty()) {
+ errno = EBADF;
+ return -1;
+ }
+
+ error = SetCWD(path);
+ if (error) {
+ // errno is return value from SetCWD
+ errno = error;
+ return -1;
+ }
+ return 0;
}
int KernelProxy::ftruncate(int fd, off_t length) {

Powered by Google App Engine
This is Rietveld 408576698