Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / kernel_intercept.h
blob8a4e5056548b6584aba87c357735904b409fe646
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
3 * found in the LICENSE file. */
5 #ifndef LIBRARIES_NACL_IO_KERNEL_INTERCEPT_H_
6 #define LIBRARIES_NACL_IO_KERNEL_INTERCEPT_H_
8 #include <dirent.h>
9 #include <stdarg.h>
10 #include <sys/time.h>
12 #include <ppapi/c/ppb.h>
13 #include <ppapi/c/pp_instance.h>
15 #include "nacl_io/ossignal.h"
16 #include "nacl_io/ossocket.h"
17 #include "nacl_io/osstat.h"
18 #include "nacl_io/ostermios.h"
19 #include "nacl_io/ostypes.h"
20 #include "nacl_io/osutime.h"
21 #include "sdk_util/macros.h"
23 EXTERN_C_BEGIN
25 #ifdef __cplusplus
26 namespace nacl_io {
27 class KernelProxy;
29 #endif
31 struct fuse_operations;
34 * The kernel intercept module provides a C->C++ thunk between the libc
35 * kernel calls and the KernelProxy singleton.
39 * ki_init must be called with an uninitialized KernelProxy object. Calling
40 * with NULL will instantiate a default kernel proxy object. ki_init must
41 * be called before any other ki_XXX function can be used.
43 int ki_init(void* kernel_proxy);
46 * Saves the current internal state. This is used by test code which can
47 * use this to save the current state before calling ki_init(). The
48 * pushed state is restored by ki_pop_state_for_testing() (or ki_uninit()).
50 int ki_push_state_for_testing(void);
52 int ki_pop_state_for_testing(void);
54 int ki_init_ppapi(void* kernel_proxy,
55 PP_Instance instance,
56 PPB_GetInterface get_browser_interface);
59 * ki_init_interface() is a variant of ki_init() that can be called with
60 * a PepperInterface object.
62 int ki_init_interface(void* kernel_proxy, void* pepper_interface);
64 #ifdef __cplusplus
65 nacl_io::KernelProxy* ki_get_proxy();
66 #endif
68 int ki_is_initialized(void);
69 int ki_uninit(void);
71 int ki_chdir(const char* path);
72 void ki_exit(int status);
73 char* ki_getcwd(char* buf, size_t size);
74 char* ki_getwd(char* buf);
75 int ki_dup(int oldfd);
76 int ki_dup2(int oldfd, int newfd);
77 int ki_chmod(const char* path, mode_t mode);
78 int ki_fchdir(int fd);
79 int ki_fchmod(int fd, mode_t mode);
80 int ki_stat(const char* path, struct stat* buf);
81 int ki_mkdir(const char* path, mode_t mode);
82 int ki_rmdir(const char* path);
83 int ki_mount(const char* source,
84 const char* target,
85 const char* filesystemtype,
86 unsigned long mountflags,
87 const void* data);
88 int ki_umount(const char* path);
89 int ki_open(const char* path, int oflag, mode_t mode);
90 int ki_pipe(int pipefds[2]);
91 ssize_t ki_read(int fd, void* buf, size_t nbyte);
92 ssize_t ki_write(int fd, const void* buf, size_t nbyte);
93 int ki_fstat(int fd, struct stat* buf);
94 int ki_getdents(int fd, struct dirent* buf, unsigned int count);
95 int ki_fsync(int fd);
96 int ki_fdatasync(int fd);
97 int ki_ftruncate(int fd, off_t length);
98 int ki_isatty(int fd);
99 int ki_close(int fd);
100 off_t ki_lseek(int fd, off_t offset, int whence);
101 int ki_remove(const char* path);
102 int ki_unlink(const char* path);
103 int ki_truncate(const char* path, off_t length);
104 int ki_lstat(const char* path, struct stat* buf);
105 int ki_link(const char* oldpath, const char* newpath);
106 int ki_rename(const char* oldpath, const char* newpath);
107 int ki_symlink(const char* oldpath, const char* newpath);
108 int ki_access(const char* path, int amode);
109 int ki_readlink(const char* path, char* buf, size_t count);
110 int ki_utimes(const char* path, const struct timeval times[2]);
111 int ki_futimes(int fd, const struct timeval times[2]);
112 void* ki_mmap(void* addr,
113 size_t length,
114 int prot,
115 int flags,
116 int fd,
117 off_t offset);
118 int ki_munmap(void* addr, size_t length);
119 int ki_open_resource(const char* file);
120 int ki_fcntl(int d, int request, va_list args);
121 int ki_ioctl(int d, int request, va_list args);
122 int ki_chown(const char* path, uid_t owner, gid_t group);
123 int ki_fchown(int fd, uid_t owner, gid_t group);
124 int ki_lchown(const char* path, uid_t owner, gid_t group);
125 int ki_utime(const char* filename, const struct utimbuf* times);
126 int ki_futimens(int fd, const struct timespec times[2]);
127 mode_t ki_umask(mode_t mask);
129 int ki_poll(struct pollfd* fds, nfds_t nfds, int timeout);
130 int ki_select(int nfds,
131 fd_set* readfds,
132 fd_set* writefds,
133 fd_set* exceptfds,
134 struct timeval* timeout);
136 int ki_tcflush(int fd, int queue_selector);
137 int ki_tcgetattr(int fd, struct termios* termios_p);
138 int ki_tcsetattr(int fd, int optional_actions, const struct termios* termios_p);
139 int ki_kill(pid_t pid, int sig);
140 int ki_killpg(pid_t pid, int sig);
141 int ki_sigaction(int signum,
142 const struct sigaction* action,
143 struct sigaction* oaction);
144 int ki_sigpause(int sigmask);
145 int ki_sigpending(sigset_t* set);
146 int ki_sigsuspend(const sigset_t* set);
147 sighandler_t ki_signal(int signum, sighandler_t handler);
148 sighandler_t ki_sigset(int signum, sighandler_t handler);
150 #ifdef PROVIDES_SOCKET_API
151 /* Socket Functions */
152 int ki_accept(int fd, struct sockaddr* addr, socklen_t* len);
153 int ki_bind(int fd, const struct sockaddr* addr, socklen_t len);
154 int ki_connect(int fd, const struct sockaddr* addr, socklen_t len);
155 void ki_freeaddrinfo(struct addrinfo* res);
156 int ki_getaddrinfo(const char* node,
157 const char* service,
158 const struct addrinfo* hints,
159 struct addrinfo** res);
160 struct hostent* ki_gethostbyname(const char* name);
161 int ki_getnameinfo(const struct sockaddr *sa,
162 socklen_t salen,
163 char *host,
164 size_t hostlen,
165 char *serv,
166 size_t servlen,
167 unsigned int flags);
168 int ki_getpeername(int fd, struct sockaddr* addr, socklen_t* len);
169 int ki_getsockname(int fd, struct sockaddr* addr, socklen_t* len);
170 int ki_getsockopt(int fd, int lvl, int optname, void* optval, socklen_t* len);
171 int ki_listen(int fd, int backlog);
172 ssize_t ki_recv(int fd, void* buf, size_t len, int flags);
173 ssize_t ki_recvfrom(int fd,
174 void* buf,
175 size_t len,
176 int flags,
177 struct sockaddr* addr,
178 socklen_t* addrlen);
179 ssize_t ki_recvmsg(int fd, struct msghdr* msg, int flags);
180 ssize_t ki_send(int fd, const void* buf, size_t len, int flags);
181 ssize_t ki_sendto(int fd,
182 const void* buf,
183 size_t len,
184 int flags,
185 const struct sockaddr* addr,
186 socklen_t addrlen);
187 ssize_t ki_sendmsg(int fd, const struct msghdr* msg, int flags);
188 int ki_setsockopt(int fd,
189 int lvl,
190 int optname,
191 const void* optval,
192 socklen_t len);
193 int ki_shutdown(int fd, int how);
194 int ki_socket(int domain, int type, int protocol);
195 int ki_socketpair(int domain, int type, int protocl, int* sv);
196 #endif /* PROVIDES_SOCKET_API */
198 EXTERN_C_END
200 #endif /* LIBRARIES_NACL_IO_KERNEL_INTERCEPT_H_ */