-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathcelld.h
224 lines (195 loc) · 5.31 KB
/
celld.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* celld.h
*
* Structures and definitions for the Cells controlling daemon, celld
*
* Copyright (C) 2010-2013 Columbia University
* Authors: Christoffer Dall <[email protected]>
* Jeremy C. Andrus <[email protected]>
* Alexander Van't Hof <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef CELLD_H
#define CELLD_H
#include <pthread.h>
#include <stdarg.h>
#include <unistd.h>
#include <asm/unistd.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/un.h>
#include <linux/sched.h>
#include <linux/socket.h>
#include "cell_console.h"
#define SOCKET_PATH "celld"
#define PRIV_SOCKET_PATH "TODO"
#define CELLD_LOCKFILE "/data/.celldlock"
#define CELL_ETC_PATH "/system/etc/cells"
#define DEFL_CELL_DIR "/data/cells"
#define DEFL_SDCARD_ROOT "/mnt/shell/emulated/cells"
//#define DEFL_START_OPTS "-CMSWdgimptu"
#define DEFL_START_OPTS "-CMSWdgimpwun"
#define FISSION_MOBILE_IF_NAME "rmnet_data0"
#define FISSION1_HOST_IP "172.17.202.5"
#define FISSION2_HOST_IP "172.17.202.37"
#define FISSION_HOST_IP_MASK "255.255.255.252"
#define CONSOLE_READY_MSG "ready"
#define CONSOLE_READY_MSG_LEN 8 /* strlen("0 ready") + sizeof('\0') */
#define MAX_MSG_LEN 512
#define MAX_NAME_LEN 64
#define MAX_ARGS 20
#define MAX_PATH_LEN 256
/* Update CELL_CMD_REV if you change this enum in any way */
enum cell_cmd {
CELL_CREATE,
CELL_DESTROY,
CELL_LIST,
CELL_NEXT,
CELL_PREV,
CELL_START,
CELL_STOP,
CELL_SWITCH,
CELL_CONSOLE,
CELL_AUTOSTART,
CELL_AUTOSWITCH,
CELL_GETID,
CELL_SETID,
CELL_GETACTIVE,
CELL_MOUNT,
CELL_UNMOUNT,
CELL_RUNCMD,
CELL_MAXCOMMAND
};
/* Update CELL_CMD_REV if you change this struct in any way */
struct cell_create_args {
int id; /* -1: unspecified */
};
/* Update CELL_CMD_REV if you change this struct in any way */
struct cell_list_args {
char all;
char running;
char zombie;
};
/* Update CELL_CMD_REV if you change this struct in any way */
struct cell_start_args {
char noopt; /* no start opions - use default or stored */
char uts_ns;
char ipc_ns;
char user_ns;
char net_ns;
char pid_ns;
char mount_ns;
char mnt_rootfs;
char mnt_tmpfs;
char newpts;
char newcgrp;
char share_dalvik_cache;
char sdcard_branch;
char wifiproxy;
char open_console;
char autoswitch;
char pid_file[MAX_PATH_LEN];
char wait;
};
/* Update CELL_CMD_REV if you change this struct in any way */
/* if neither field is set, the status is retrieved */
struct cell_autostart_args {
char on;
char off;
};
/* Update CELL_CMD_REV if you change this struct in any way */
struct cell_setid_args {
int id;
};
/* Update CELL_CMD_REV if you change this struct in any way */
struct cell_mount_args {
int all;
};
/* Update CELL_CMD_REV if you change this struct in any way */
struct cell_runcmd_args {
char cmd[MAX_PATH_LEN];
};
/* Update this number if you change cell_cmd_arg in any way */
#define CELL_CMD_REV (0xbabe0010)
struct cell_cmd_arg {
enum cell_cmd cmd;
char cellname[MAX_NAME_LEN];
union {
struct cell_create_args create_args;
struct cell_list_args list_args;
struct cell_start_args start_args;
struct cell_setid_args setid_args;
struct cell_mount_args mount_args;
struct cell_autostart_args autostart_args;
struct cell_runcmd_args runcmd_args;
};
};
struct cell_args {
struct cell_start_args start_args;
char cellname[MAX_NAME_LEN];
struct timeval start_time;
char *rootdir;
int init_pid;
int restart_pid;
char **argv;
int argc;
int cell_socket;
int wifi_socket;
int child_pipe[2];
int init_pipe[2];
};
struct cell_node {
short init_pid;
char name[MAX_NAME_LEN];
struct pty_info console_pty;
short starting;
short wifi_proxy;
short id;
short non_child;
struct timeval start_time;
struct cell_node *next;
struct cell_node *prev;
};
struct cell_list {
struct cell_node *head;
struct cell_node *tail;
pthread_mutex_t mutex;
};
struct cell_monitor_state {
char name[MAX_NAME_LEN];
int pid;
int child_fd;
int init_fd;
};
extern struct cell_node *active_cell;
struct cell_node *search_cells_path(char *root_path);
void switch_to_next(void);
int init_addr(struct sockaddr_un *addr);
int _send_msg(int fd, const char *fmt, va_list ap);
int send_msg(int fd, const char *fmt, ...);
int recv_msg_len(int fd, char **tok, char **msg, int len);
int recv_msg(int fd, char **tok, char **msg);
int send_fd(int conn_fd, int fd);
int recv_fd(int conn_fd);
extern char *get_rw_path(char *name);
extern char *get_root_path(char *name);
extern int do_share_dalvik_cache(char *root_path);
int mount_cell(char *name, int sdcard_mnt);
int unmount_all(const char *root_path, int mount_fs);
/* non-exported bionic functions */
extern pid_t __pthread_gettid(pthread_t tid);
#endif /* CELLD_H */