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

Side by Side Diff: native_client_sdk/src/libraries/nacl_mounts/kernel_proxy.cc

Issue 10829027: [NaCl SDK] Add nacl_mounts to NaCl SDK build. Experimental for now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync again Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 #include <dirent.h> 5 #include "nacl_mounts/kernel_proxy.h"
6
6 #include <errno.h> 7 #include <errno.h>
7 #include <fcntl.h> 8 #include <fcntl.h>
8 #include <pthread.h> 9 #include <pthread.h>
9 #include <stdint.h> 10 #include <string.h>
10 #include <sys/stat.h>
11
12 #include <string> 11 #include <string>
13 12
14 #include "nacl_mounts/kernel_handle.h" 13 #include "nacl_mounts/kernel_handle.h"
15 #include "nacl_mounts/kernel_proxy.h"
16 #include "nacl_mounts/mount.h" 14 #include "nacl_mounts/mount.h"
17 #include "nacl_mounts/mount_mem.h" 15 #include "nacl_mounts/mount_mem.h"
18 #include "nacl_mounts/mount_node.h" 16 #include "nacl_mounts/mount_node.h"
19 #include "nacl_mounts/mount_url.h" 17 #include "nacl_mounts/osstat.h"
18 // TODO(binji): implement MountURL
19 //#include "nacl_mounts/mount_url.h"
20 #include "nacl_mounts/path.h" 20 #include "nacl_mounts/path.h"
21
22 #include "utils/auto_lock.h" 21 #include "utils/auto_lock.h"
23 #include "utils/ref_object.h" 22 #include "utils/ref_object.h"
24 23
25 #ifndef MAXPATHLEN 24 #ifndef MAXPATHLEN
26 #define MAXPATHLEN 256 25 #define MAXPATHLEN 256
27 #endif 26 #endif
28 27
29 // TODO(noelallen) : Grab/Redefine these in the kernel object once available. 28 // TODO(noelallen) : Grab/Redefine these in the kernel object once available.
30 #define USR_ID 1002 29 #define USR_ID 1002
31 #define GRP_ID 1003 30 #define GRP_ID 1003
32 31
33 32
34 KernelProxy::KernelProxy() : dev_(0) {} 33 KernelProxy::KernelProxy() : dev_(0) {}
35 KernelProxy::~KernelProxy() {} 34 KernelProxy::~KernelProxy() {}
36 35
37 void KernelProxy::Init() { 36 void KernelProxy::Init() {
38 cwd_ = "/"; 37 cwd_ = "/";
39 dev_ = 1; 38 dev_ = 1;
40 39
41 factories_["memfs"] = MountMem::Create; 40 factories_["memfs"] = MountMem::Create;
42 factories_["urlfs"] = MountURL::Create; 41 // TODO(binji): implement MountURL
42 //factories_["urlfs"] = MountURL::Create;
43 43
44 // Create memory mount at root 44 // Create memory mount at root
45 StringMap_t smap; 45 StringMap_t smap;
46 mounts_["/"] = MountMem::Create(dev_++, smap); 46 mounts_["/"] = MountMem::Create(dev_++, smap);
47 } 47 }
48 48
49 49
50 int KernelProxy::open(const char *path, int oflags) { 50 int KernelProxy::open(const char *path, int oflags) {
51 Path rel; 51 Path rel;
52 52
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 287
288 int KernelProxy::fstat(int fd, struct stat* buf) { 288 int KernelProxy::fstat(int fd, struct stat* buf) {
289 KernelHandle* handle = AcquireHandle(fd); 289 KernelHandle* handle = AcquireHandle(fd);
290 290
291 // check if fd is valid and handle exists 291 // check if fd is valid and handle exists
292 if (NULL == handle) return -1; 292 if (NULL == handle) return -1;
293 293
294 int ret = handle->node_->GetStat(buf); 294 int ret = handle->node_->GetStat(buf);
295 ReleaseHandle(handle); 295 ReleaseHandle(handle);
296 return ret; 296 return ret;
297 }; 297 }
298 298
299 int KernelProxy::getdents(int fd, void* buf, unsigned int count) { 299 int KernelProxy::getdents(int fd, void* buf, unsigned int count) {
300 KernelHandle* handle = AcquireHandle(fd); 300 KernelHandle* handle = AcquireHandle(fd);
301 301
302 // check if fd is valid and handle exists 302 // check if fd is valid and handle exists
303 if (NULL == handle) return -1; 303 if (NULL == handle) return -1;
304 304
305 AutoLock lock(&handle->lock_); 305 AutoLock lock(&handle->lock_);
306 int cnt = handle->node_->GetDents(handle->offs_, 306 int cnt = handle->node_->GetDents(handle->offs_,
307 static_cast<dirent *>(buf), count); 307 static_cast<dirent *>(buf), count);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 return -1; 348 return -1;
349 } 349 }
350 int KernelProxy::access(const char*path, int amode) { 350 int KernelProxy::access(const char*path, int amode) {
351 errno = EINVAL; 351 errno = EINVAL;
352 return -1; 352 return -1;
353 } 353 }
354 off_t KernelProxy::lseek(int fd, off_t offset, int whence) { 354 off_t KernelProxy::lseek(int fd, off_t offset, int whence) {
355 errno = EINVAL; 355 errno = EINVAL;
356 return -1; 356 return -1;
357 } 357 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_mounts/kernel_proxy.h ('k') | native_client_sdk/src/libraries/nacl_mounts/library.dsc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698