Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client / src / untrusted / irt / irt_dev.h
1 /*
2  * Copyright (c) 2013 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_
7 #define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_
8
9 #include <stdarg.h>
10 #include <stddef.h>
11 #include <sys/types.h>
12
13 /* Use relative path so that irt_dev.h can be installed as a system header. */
14 #include "irt.h"
15
16 /*
17  * This header file is for IRT interfaces that are only available in
18  * Chromium behind a flag, or are not available in Chromium at all.
19  *
20  * For example, the filesystem interfaces and getpid() are only
21  * available when the env var NACL_DANGEROUS_ENABLE_FILE_ACCESS is
22  * set, which enables an unsafe debugging mode.
23  */
24
25 struct dirent;
26 struct stat;
27 struct timeval;
28
29 struct NaClMemMappingInfo;
30
31 #if defined(__cplusplus)
32 extern "C" {
33 #endif
34
35 #define NACL_IRT_DEV_FDIO_v0_2  "nacl-irt-dev-fdio-0.2"
36 struct nacl_irt_dev_fdio_v0_2 {
37   int (*close)(int fd);
38   int (*dup)(int fd, int *newfd);
39   int (*dup2)(int fd, int newfd);
40   int (*read)(int fd, void *buf, size_t count, size_t *nread);
41   int (*write)(int fd, const void *buf, size_t count, size_t *nwrote);
42   int (*seek)(int fd, nacl_irt_off_t offset, int whence,
43               nacl_irt_off_t *new_offset);
44   int (*fstat)(int fd, struct stat *);
45   int (*getdents)(int fd, struct dirent *, size_t count, size_t *nread);
46   int (*fchdir)(int fd);
47   int (*fchmod)(int fd, mode_t mode);
48   int (*fsync)(int fd);
49   int (*fdatasync)(int fd);
50   int (*ftruncate)(int fd, nacl_irt_off_t length);
51 };
52
53 #define NACL_IRT_DEV_FDIO_v0_3  "nacl-irt-dev-fdio-0.3"
54 struct nacl_irt_dev_fdio {
55   int (*close)(int fd);
56   int (*dup)(int fd, int *newfd);
57   int (*dup2)(int fd, int newfd);
58   int (*read)(int fd, void *buf, size_t count, size_t *nread);
59   int (*write)(int fd, const void *buf, size_t count, size_t *nwrote);
60   int (*seek)(int fd, nacl_irt_off_t offset, int whence,
61               nacl_irt_off_t *new_offset);
62   int (*fstat)(int fd, struct stat *);
63   int (*getdents)(int fd, struct dirent *, size_t count, size_t *nread);
64   int (*fchdir)(int fd);
65   int (*fchmod)(int fd, mode_t mode);
66   int (*fsync)(int fd);
67   int (*fdatasync)(int fd);
68   int (*ftruncate)(int fd, nacl_irt_off_t length);
69   int (*isatty)(int fd, int *result);
70 };
71
72 /*
73  * The "irt-dev-filename" is similiar to "irt-filename" but provides
74  * additional functions, including those that do directory manipulation.
75  * Inside Chromium, requests for this interface may fail, or may return
76  * functions which always return errors.
77  */
78 #define NACL_IRT_DEV_FILENAME_v0_2 "nacl-irt-dev-filename-0.2"
79 struct nacl_irt_dev_filename_v0_2 {
80   int (*open)(const char *pathname, int oflag, mode_t cmode, int *newfd);
81   int (*stat)(const char *pathname, struct stat *);
82   int (*mkdir)(const char *pathname, mode_t mode);
83   int (*rmdir)(const char *pathname);
84   int (*chdir)(const char *pathname);
85   int (*getcwd)(char *pathname, size_t len);
86   int (*unlink)(const char *pathname);
87 };
88
89 #define NACL_IRT_DEV_FILENAME_v0_3 "nacl-irt-dev-filename-0.3"
90 struct nacl_irt_dev_filename {
91   int (*open)(const char *pathname, int oflag, mode_t cmode, int *newfd);
92   int (*stat)(const char *pathname, struct stat *);
93   int (*mkdir)(const char *pathname, mode_t mode);
94   int (*rmdir)(const char *pathname);
95   int (*chdir)(const char *pathname);
96   int (*getcwd)(char *pathname, size_t len);
97   int (*unlink)(const char *pathname);
98   int (*truncate)(const char *pathname, nacl_irt_off_t length);
99   int (*lstat)(const char *pathname, struct stat *);
100   int (*link)(const char *oldpath, const char *newpath);
101   int (*rename)(const char *oldpath, const char *newpath);
102   int (*symlink)(const char *oldpath, const char *newpath);
103   int (*chmod)(const char *path, mode_t mode);
104   int (*access)(const char *path, int amode);
105   int (*readlink)(const char *path, char *buf, size_t count, size_t *nread);
106   int (*utimes)(const char *filename, const struct timeval *times);
107 };
108
109 #define NACL_IRT_DEV_LIST_MAPPINGS_v0_1 \
110   "nacl-irt-dev-list-mappings-0.1"
111 struct nacl_irt_dev_list_mappings {
112   int (*list_mappings)(struct NaClMemMappingInfo *regions,
113                        size_t count, size_t *result_count);
114 };
115
116 #define NACL_IRT_DEV_GETPID_v0_1 "nacl-irt-dev-getpid-0.1"
117 struct nacl_irt_dev_getpid {
118   int (*getpid)(int *pid);
119 };
120
121 #if defined(__cplusplus)
122 }
123 #endif
124
125 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H */