Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ | 5 #ifndef LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ |
| 6 #define LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ | 6 #define LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ |
| 7 | 7 |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 // path resolution. | 22 // path resolution. |
| 23 class KernelObject { | 23 class KernelObject { |
| 24 public: | 24 public: |
| 25 typedef std::vector<KernelHandle*> HandleMap_t; | 25 typedef std::vector<KernelHandle*> HandleMap_t; |
| 26 typedef std::map<std::string, Mount*> MountMap_t; | 26 typedef std::map<std::string, Mount*> MountMap_t; |
| 27 | 27 |
| 28 KernelObject(); | 28 KernelObject(); |
| 29 virtual ~KernelObject(); | 29 virtual ~KernelObject(); |
| 30 | 30 |
| 31 // Find the mount for the given path, and acquires it | 31 // Find the mount for the given path, and acquires it |
| 32 Mount* AcquireMountAndPath(const std::string& relpath, Path *pobj); | 32 int AcquireMountAndPath(const std::string& relpath, |
|
noelallen1
2013/06/07 21:48:43
Error?
binji
2013/06/07 23:23:11
Done.
| |
| 33 Mount** mount, | |
| 34 Path* pobj); | |
| 33 void ReleaseMount(Mount* mnt); | 35 void ReleaseMount(Mount* mnt); |
| 34 | 36 |
| 35 // Convert from FD to KernelHandle, and acquire the handle. | 37 // Convert from FD to KernelHandle, and acquire the handle. |
| 36 KernelHandle* AcquireHandle(int fd); | 38 int AcquireHandle(int fd, KernelHandle** handle); |
|
noelallen1
2013/06/07 21:48:43
Error?
binji
2013/06/07 23:23:11
Done.
| |
| 37 void ReleaseHandle(KernelHandle* handle); | 39 void ReleaseHandle(KernelHandle* handle); |
| 38 | 40 |
| 39 // Allocate a new fd and assign the handle to it, while | 41 // Allocate a new fd and assign the handle to it, while |
| 40 // ref counting the handle and associated mount. | 42 // ref counting the handle and associated mount. |
| 41 int AllocateFD(KernelHandle* handle); | 43 int AllocateFD(KernelHandle* handle); |
| 42 void FreeAndReassignFD(int fd, KernelHandle* handle); | 44 void FreeAndReassignFD(int fd, KernelHandle* handle); |
| 43 void FreeFD(int fd); | 45 void FreeFD(int fd); |
| 44 | 46 |
| 45 protected: | 47 protected: |
| 46 Path GetAbsPathLocked(const std::string& path); | 48 Path GetAbsPathLocked(const std::string& path); |
| 47 | 49 |
| 48 std::vector<int> free_fds_; | 50 std::vector<int> free_fds_; |
| 49 std::string cwd_; | 51 std::string cwd_; |
| 50 | 52 |
| 51 HandleMap_t handle_map_; | 53 HandleMap_t handle_map_; |
| 52 MountMap_t mounts_; | 54 MountMap_t mounts_; |
| 53 | 55 |
| 54 // Kernel lock protects kernel wide resources such as the mount table... | 56 // Kernel lock protects kernel wide resources such as the mount table... |
| 55 pthread_mutex_t kernel_lock_; | 57 pthread_mutex_t kernel_lock_; |
| 56 | 58 |
| 57 // Process lock protects process wide resources such as CWD, file handles... | 59 // Process lock protects process wide resources such as CWD, file handles... |
| 58 pthread_mutex_t process_lock_; | 60 pthread_mutex_t process_lock_; |
| 59 | 61 |
| 60 DISALLOW_COPY_AND_ASSIGN(KernelObject); | 62 DISALLOW_COPY_AND_ASSIGN(KernelObject); |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ | 65 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ |
| OLD | NEW |