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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/kernel_object.h

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 unified diff | Download patch
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/kernel_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 13 matching lines...) Expand all
24 24
25 // KernelObject provides basic functionality for threadsafe access to kernel 25 // KernelObject provides basic functionality for threadsafe access to kernel
26 // objects such as the CWD, mount points, file descriptors and file handles. 26 // objects such as the CWD, mount points, file descriptors and file handles.
27 // All Kernel locks are private to ensure the lock order. 27 // All Kernel locks are private to ensure the lock order.
28 // 28 //
29 // All calls are assumed to be a relative path. 29 // All calls are assumed to be a relative path.
30 class KernelObject { 30 class KernelObject {
31 public: 31 public:
32 struct Descriptor_t { 32 struct Descriptor_t {
33 Descriptor_t() : flags(0) {} 33 Descriptor_t() : flags(0) {}
34 explicit Descriptor_t(const ScopedKernelHandle& h) : handle(h), flags(0) {} 34 explicit Descriptor_t(const ScopedKernelHandle& h,
35 const std::string& open_path)
36 : handle(h), flags(0), path(open_path) {}
35 37
36 ScopedKernelHandle handle; 38 ScopedKernelHandle handle;
37 int flags; 39 int flags;
40 std::string path;
38 }; 41 };
39 typedef std::vector<Descriptor_t> HandleMap_t; 42 typedef std::vector<Descriptor_t> HandleMap_t;
40 typedef std::map<std::string, ScopedFilesystem> FsMap_t; 43 typedef std::map<std::string, ScopedFilesystem> FsMap_t;
41 44
42 KernelObject(); 45 KernelObject();
43 virtual ~KernelObject(); 46 virtual ~KernelObject();
44 47
45 // Attach the given Filesystem object at the specified path. 48 // Attach the given Filesystem object at the specified path.
46 Error AttachFsAtPath(const ScopedFilesystem& fs, const std::string& path); 49 Error AttachFsAtPath(const ScopedFilesystem& fs, const std::string& path);
47 50
(...skipping 16 matching lines...) Expand all
64 ScopedNode* out_node); 67 ScopedNode* out_node);
65 68
66 // Get FD-specific flags (currently only FD_CLOEXEC is supported). 69 // Get FD-specific flags (currently only FD_CLOEXEC is supported).
67 Error GetFDFlags(int fd, int* out_flags); 70 Error GetFDFlags(int fd, int* out_flags);
68 // Set FD-specific flags (currently only FD_CLOEXEC is supported). 71 // Set FD-specific flags (currently only FD_CLOEXEC is supported).
69 Error SetFDFlags(int fd, int flags); 72 Error SetFDFlags(int fd, int flags);
70 73
71 // Convert from FD to KernelHandle, and acquire the handle. 74 // Convert from FD to KernelHandle, and acquire the handle.
72 // Assumes |out_handle| is non-NULL. 75 // Assumes |out_handle| is non-NULL.
73 Error AcquireHandle(int fd, ScopedKernelHandle* out_handle); 76 Error AcquireHandle(int fd, ScopedKernelHandle* out_handle);
77 Error AcquireHandleAndPath(int fd, ScopedKernelHandle *out_handle,
78 std::string* out_path);
74 79
75 // Allocate a new fd and assign the handle to it, while 80 // Allocate a new fd and assign the handle to it, while
76 // ref counting the handle and associated filesystem. 81 // ref counting the handle and associated filesystem.
77 // Assumes |handle| is non-NULL; 82 // Assumes |handle| is non-NULL;
78 int AllocateFD(const ScopedKernelHandle& handle); 83 int AllocateFD(const ScopedKernelHandle& handle,
84 const std::string& path=std::string());
79 85
80 // Assumes |handle| is non-NULL; 86 // Assumes |handle| is non-NULL;
81 void FreeAndReassignFD(int fd, const ScopedKernelHandle& handle); 87 void FreeAndReassignFD(int fd, const ScopedKernelHandle& handle,
88 const std::string& path);
82 void FreeFD(int fd); 89 void FreeFD(int fd);
83 90
84 // Returns or sets CWD 91 // Returns or sets CWD
85 std::string GetCWD(); 92 std::string GetCWD();
86 Error SetCWD(const std::string& path); 93 Error SetCWD(const std::string& path);
87 94
88 // Returns parts of the absolute path for the given relative path 95 // Returns parts of the absolute path for the given relative path
89 Path GetAbsParts(const std::string& path); 96 Path GetAbsParts(const std::string& path);
90 97
91 private: 98 private:
(...skipping 10 matching lines...) Expand all
102 109
103 // Lock to protect cwd_. 110 // Lock to protect cwd_.
104 sdk_util::SimpleLock cwd_lock_; 111 sdk_util::SimpleLock cwd_lock_;
105 112
106 DISALLOW_COPY_AND_ASSIGN(KernelObject); 113 DISALLOW_COPY_AND_ASSIGN(KernelObject);
107 }; 114 };
108 115
109 } // namespace nacl_io 116 } // namespace nacl_io
110 117
111 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ 118 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/kernel_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698