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

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

Issue 18644009: [NaCl SDK] Upate atomic ops in nacl_io (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add declartions for newval and oldval Created 7 years, 5 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_handle.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
index 322bd9e4af583b52f181c6547879c32e9ba75cf4..12b83a3dcdb23e66c5d1ace1c517c8959a0aa933 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
@@ -12,6 +12,8 @@
#include "nacl_io/mount_node.h"
#include "nacl_io/osunistd.h"
+#include "sdk_util/auto_lock.h"
+
// It is only legal to construct a handle while the kernel lock is held.
KernelHandle::KernelHandle()
: mount_(NULL), node_(NULL), offs_(0) {}
@@ -33,9 +35,10 @@ Error KernelHandle::Init(int open_mode) {
Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
// By default, don't move the offset.
*out_offset = offset;
-
size_t base;
size_t node_size;
+
+ AUTO_LOCK(offs_lock_);
Error error = node_->GetSize(&node_size);
if (error)
return error;
@@ -71,3 +74,29 @@ Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
return 0;
}
+Error KernelHandle::Read(void* buf, size_t nbytes, int* cnt) {
+ AUTO_LOCK(offs_lock_);
+ Error error = node_->Read(offs_, buf, nbytes, cnt);
+ if (0 == error)
+ offs_ += *cnt;
+ return error;
+}
+
+Error KernelHandle::Write(const void* buf, size_t nbytes, int* cnt) {
+ AUTO_LOCK(offs_lock_);
+ Error error = node_->Write(offs_, buf, nbytes, cnt);
+ if (0 == error)
+ offs_ += *cnt;
+ return error;
+}
+
+Error KernelHandle::GetDents(struct dirent* pdir, size_t nbytes, int* cnt) {
+ AUTO_LOCK(offs_lock_);
+ Error error = node_->GetDents(offs_, pdir, nbytes, cnt);
+ if (0 == error)
+ offs_ += *cnt;
+ return error;
+}
+
+const ScopedRef<MountNode>& KernelHandle::node() { return node_; }
+const ScopedRef<Mount>& KernelHandle::mount() { return mount_; }

Powered by Google App Engine
This is Rietveld 408576698