| 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_PROXY_H_ | 5 #ifndef LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 
| 6 #define LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 6 #define LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <string> | 9 #include <string> | 
| 10 | 10 | 
|  | 11 #include "nacl_io/event_emitter_signal.h" | 
| 11 #include "nacl_io/host_resolver.h" | 12 #include "nacl_io/host_resolver.h" | 
| 12 #include "nacl_io/kernel_object.h" | 13 #include "nacl_io/kernel_object.h" | 
| 13 #include "nacl_io/mount_factory.h" | 14 #include "nacl_io/mount_factory.h" | 
| 14 #include "nacl_io/mount_socket.h" | 15 #include "nacl_io/mount_stream.h" | 
| 15 #include "nacl_io/ossignal.h" | 16 #include "nacl_io/ossignal.h" | 
| 16 #include "nacl_io/ossocket.h" | 17 #include "nacl_io/ossocket.h" | 
| 17 #include "nacl_io/ostypes.h" | 18 #include "nacl_io/ostypes.h" | 
| 18 #include "nacl_io/osutime.h" | 19 #include "nacl_io/osutime.h" | 
| 19 | 20 | 
| 20 struct timeval; | 21 struct timeval; | 
| 21 | 22 | 
| 22 namespace nacl_io { | 23 namespace nacl_io { | 
| 23 | 24 | 
| 24 class PepperInterface; | 25 class PepperInterface; | 
| 25 class SignalEmitter; |  | 
| 26 | 26 | 
| 27 typedef sdk_util::ScopedRef<SignalEmitter> ScopedSignalEmitter; |  | 
| 28 | 27 | 
| 29 // KernelProxy provide one-to-one mapping for libc kernel calls.  Calls to the | 28 // KernelProxy provide one-to-one mapping for libc kernel calls.  Calls to the | 
| 30 // proxy will result in IO access to the provided Mount and MountNode objects. | 29 // proxy will result in IO access to the provided Mount and MountNode objects. | 
| 31 // | 30 // | 
| 32 // NOTE: The KernelProxy does not directly take any kernel locks, all locking | 31 // NOTE: The KernelProxy does not directly take any kernel locks, all locking | 
| 33 // is done by the parent class KernelObject.  Instead, KernelProxy is | 32 // is done by the parent class KernelObject.  Instead, KernelProxy is | 
| 34 // responsible for taking the locks of the KernelHandle, and MountNode objects. | 33 // responsible for taking the locks of the KernelHandle, and MountNode objects. | 
| 35 // For this reason, a KernelObject call should not be done while holding | 34 // For this reason, a KernelObject call should not be done while holding | 
| 36 // a handle or node lock.  In addition, to ensure locking order, | 35 // a handle or node lock.  In addition, to ensure locking order, | 
| 37 // a KernelHandle lock must never be taken after taking the associated | 36 // a KernelHandle lock must never be taken after taking the associated | 
| 38 // MountNode's lock. | 37 // MountNode's lock. | 
| 39 // | 38 // | 
| 40 // NOTE: The KernelProxy is the only class that should be setting errno. All | 39 // NOTE: The KernelProxy is the only class that should be setting errno. All | 
| 41 // other classes should return Error (as defined by nacl_io/error.h). | 40 // other classes should return Error (as defined by nacl_io/error.h). | 
| 42 class KernelProxy : protected KernelObject { | 41 class KernelProxy : protected KernelObject { | 
| 43  public: | 42  public: | 
| 44   typedef std::map<std::string, MountFactory*> MountFactoryMap_t; | 43   typedef std::map<std::string, MountFactory*> MountFactoryMap_t; | 
| 45 | 44 | 
| 46   KernelProxy(); | 45   KernelProxy(); | 
| 47   virtual ~KernelProxy(); | 46   virtual ~KernelProxy(); | 
| 48 | 47 | 
| 49   // Takes ownership of |ppapi|. | 48   // Takes ownership of |ppapi|. | 
| 50   // |ppapi| may be NULL. If so, no mount that uses pepper calls can be mounted. | 49   // |ppapi| may be NULL. If so, no mount that uses pepper calls can be mounted. | 
| 51   virtual Error Init(PepperInterface* ppapi); | 50   virtual Error Init(PepperInterface* ppapi); | 
| 52 | 51 | 
|  | 52   virtual int pipe(int pipefds[2]); | 
|  | 53 | 
| 53   // NaCl-only function to read resources specified in the NMF file. | 54   // NaCl-only function to read resources specified in the NMF file. | 
| 54   virtual int open_resource(const char* file); | 55   virtual int open_resource(const char* file); | 
| 55 | 56 | 
| 56   // KernelHandle and FD allocation and manipulation functions. | 57   // KernelHandle and FD allocation and manipulation functions. | 
| 57   virtual int open(const char* path, int oflag); | 58   virtual int open(const char* path, int oflag); | 
| 58   virtual int close(int fd); | 59   virtual int close(int fd); | 
| 59   virtual int dup(int fd); | 60   virtual int dup(int fd); | 
| 60   virtual int dup2(int fd, int newfd); | 61   virtual int dup2(int fd, int newfd); | 
| 61 | 62 | 
| 62   // Path related System calls handled by KernelProxy (not mount-specific) | 63   // Path related System calls handled by KernelProxy (not mount-specific) | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 175                          int optname, | 176                          int optname, | 
| 176                          const void* optval, | 177                          const void* optval, | 
| 177                          socklen_t len); | 178                          socklen_t len); | 
| 178   virtual int shutdown(int fd, int how); | 179   virtual int shutdown(int fd, int how); | 
| 179   virtual int socket(int domain, int type, int protocol); | 180   virtual int socket(int domain, int type, int protocol); | 
| 180   virtual int socketpair(int domain, int type, int protocol, int* sv); | 181   virtual int socketpair(int domain, int type, int protocol, int* sv); | 
| 181 #endif  // PROVIDES_SOCKET_API | 182 #endif  // PROVIDES_SOCKET_API | 
| 182 | 183 | 
| 183  protected: | 184  protected: | 
| 184   MountFactoryMap_t factories_; | 185   MountFactoryMap_t factories_; | 
| 185   sdk_util::ScopedRef<MountSocket> socket_mount_; | 186   sdk_util::ScopedRef<MountStream> stream_mount_; | 
| 186   int dev_; | 187   int dev_; | 
| 187   PepperInterface* ppapi_; | 188   PepperInterface* ppapi_; | 
| 188   static KernelProxy *s_instance_; | 189   static KernelProxy *s_instance_; | 
| 189   sighandler_t sigwinch_handler_; | 190   sighandler_t sigwinch_handler_; | 
| 190 #ifdef PROVIDES_SOCKET_API | 191 #ifdef PROVIDES_SOCKET_API | 
| 191   HostResolver host_resolver_; | 192   HostResolver host_resolver_; | 
| 192 #endif | 193 #endif | 
| 193 | 194 | 
| 194 #ifdef PROVIDES_SOCKET_API | 195 #ifdef PROVIDES_SOCKET_API | 
| 195   virtual int AcquireSocketHandle(int fd, ScopedKernelHandle* handle); | 196   virtual int AcquireSocketHandle(int fd, ScopedKernelHandle* handle); | 
| 196 #endif | 197 #endif | 
| 197 | 198 | 
| 198   ScopedSignalEmitter signal_emitter_; | 199   ScopedEmitterSignal signal_emitter_; | 
| 199   DISALLOW_COPY_AND_ASSIGN(KernelProxy); | 200   DISALLOW_COPY_AND_ASSIGN(KernelProxy); | 
| 200 }; | 201 }; | 
| 201 | 202 | 
| 202 }  // namespace nacl_io | 203 }  // namespace nacl_io | 
| 203 | 204 | 
| 204 #endif  // LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 205 #endif  // LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 
| OLD | NEW | 
|---|