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.
6 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_
7 #define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_
11 #include <sys/types.h>
13 /* Use relative path so that irt_dev.h can be installed as a system header. */
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.
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.
29 struct NaClMemMappingInfo;
31 #if defined(__cplusplus)
35 #define NACL_IRT_DEV_FDIO_v0_2 "nacl-irt-dev-fdio-0.2"
36 struct nacl_irt_dev_fdio_v0_2 {
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);
49 int (*fdatasync)(int fd);
50 int (*ftruncate)(int fd, nacl_irt_off_t length);
53 #define NACL_IRT_DEV_FDIO_v0_3 "nacl-irt-dev-fdio-0.3"
54 struct nacl_irt_dev_fdio {
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);
67 int (*fdatasync)(int fd);
68 int (*ftruncate)(int fd, nacl_irt_off_t length);
69 int (*isatty)(int fd, int *result);
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.
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);
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);
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);
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);
121 #if defined(__cplusplus)
125 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H */