Index: libraries/nacl-mounts/base/KernelProxy.h |
=================================================================== |
--- libraries/nacl-mounts/base/KernelProxy.h (revision 594) |
+++ libraries/nacl-mounts/base/KernelProxy.h (working copy) |
@@ -8,6 +8,7 @@ |
#include <errno.h> |
#ifdef __GLIBC__ |
+#include <netdb.h> |
#include <poll.h> |
#endif |
#include <pthread.h> |
@@ -18,6 +19,8 @@ |
#include <string> |
#include "../base/Mount.h" |
#include "../base/MountManager.h" |
+#include "../base/PthreadHelpers.h" |
+#include "../net/BaseSocketSubSystem.h" |
#include "../util/Path.h" |
#include "../util/SimpleAutoLock.h" |
#include "../util/SlotAllocator.h" |
@@ -33,12 +36,18 @@ |
// Obtain the singleton instance of the kernel proxy. If no instance |
// has been instantiated, one will be instantiated and returned. |
static KernelProxy *KPInstance(); |
+#ifdef __GLIBC__ |
+ // Set socket subsystem reference (not in constructor because it needs to be |
+ // created separately and only if you need sockets in your app) |
+ void SetSocketSubSystem(BaseSocketSubSystem* bss); |
+#endif |
// System calls handled by KernelProxy (not mount-specific) |
int chdir(const std::string& path); |
bool getcwd(std::string *buf, size_t size); |
bool getwd(std::string *buf); |
int dup(int oldfd); |
+ int dup2(int oldfd, int newfd); |
// System calls that take a path as an argument: |
// The kernel proxy will look for the Node associated to the path. To |
@@ -109,6 +118,7 @@ |
const struct timeval *timeout, void* sigmask); |
int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen); |
int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen); |
+ struct hostent* gethostbyname(const char* name); |
int getsockopt(int sockfd, int level, int optname, void *optval, |
socklen_t* optlen); |
int setsockopt(int sockfd, int level, int optname, const void *optval, |
@@ -128,21 +138,41 @@ |
#endif |
MountManager *mm() { return &mm_; } |
+#ifdef __GLIBC__ |
+ int AddFileStream(FileStream* stream); |
+ void RemoveFileStream(int fd); |
+ |
+ int IsReady(int nfds, fd_set* fds, bool (FileStream::*is_ready)(), |
+ bool apply); |
+ Cond& select_cond() { return select_cond_; } |
+ Mutex& select_mutex() { return select_mutex_; } |
+#endif // __GLIBC__ |
private: |
struct FileDescriptor { |
// An index in open_files_ table |
int handle; |
}; |
+ // used for select() signals |
+ Cond select_cond_; |
Dmitry Polukhin
2012/05/30 15:13:32
It is not good to mix direct pthread work and usin
vissi
2012/05/31 13:35:21
Well, wrapper features (reentrancy) are used in th
|
+ Mutex select_mutex_; |
+ |
struct FileHandle { |
Mount *mount; |
+#ifdef __GLIBC__ |
+ FileStream* stream; |
+#endif |
ino_t node; |
off_t offset; |
int flags; |
int use_count; |
pthread_mutex_t lock; |
}; |
+ FileHandle* GetFileHandle(int fd); |
+#ifdef __GLIBC__ |
+ BaseSocketSubSystem* socket_subsystem_; |
+#endif |
Path cwd_; |
int max_path_len_; |
MountManager mm_; |
@@ -152,7 +182,6 @@ |
SlotAllocator<FileDescriptor> fds_; |
SlotAllocator<FileHandle> open_files_; |
- FileHandle *GetFileHandle(int fd); |
int OpenHandle(Mount *mount, const std::string& path, int oflag, mode_t mode); |
KernelProxy(); |