1
2
3
4
5
6
7
8#include "generated/config.h"
9#include "lib/portability.h"
10
11
12#include <ctype.h>
13#include <dirent.h>
14#include <errno.h>
15#include <fcntl.h>
16#include <fnmatch.h>
17#include <grp.h>
18#include <inttypes.h>
19#include <limits.h>
20#include <math.h>
21#include <pwd.h>
22#include <regex.h>
23#include <sched.h>
24#include <setjmp.h>
25#include <signal.h>
26#include <stdarg.h>
27#include <stddef.h>
28#include <stdint.h>
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32#include <strings.h>
33#include <sys/mman.h>
34#include <sys/resource.h>
35#include <sys/stat.h>
36#include <sys/statvfs.h>
37#include <sys/time.h>
38#include <sys/times.h>
39#include <sys/utsname.h>
40#include <sys/wait.h>
41#include <syslog.h>
42#include <termios.h>
43#include <time.h>
44#include <unistd.h>
45#include <utime.h>
46
47
48
49#include <arpa/inet.h>
50#include <netdb.h>
51#include <net/if.h>
52#include <netinet/in.h>
53#include <netinet/tcp.h>
54#include <poll.h>
55#include <sys/socket.h>
56#include <sys/un.h>
57
58
59
60#include <locale.h>
61#include <wchar.h>
62#include <wctype.h>
63
64
65#include <pty.h>
66#include <sys/ioctl.h>
67#include <sys/statfs.h>
68#include <sys/sysinfo.h>
69
70#include "lib/lib.h"
71#include "lib/lsm.h"
72#include "lib/toyflags.h"
73#include "toys/e2fs.h"
74
75
76
77#define NEWTOY(name, opts, flags) void name##_main(void);
78#define OLDTOY(name, oldname, flags) void oldname##_main(void);
79#include "generated/newtoys.h"
80#include "generated/flags.h"
81#include "generated/globals.h"
82#include "generated/tags.h"
83
84
85
86struct toy_list *toy_find(char *name);
87void toy_init(struct toy_list *which, char *argv[]);
88void toy_exec(char *argv[]);
89
90
91
92extern struct toy_list {
93 char *name;
94 void (*toy_main)(void);
95 char *options;
96 int flags;
97} toy_list[];
98
99
100
101extern struct toy_context {
102 struct toy_list *which;
103 char **argv;
104 char **optargs;
105 unsigned long long optflags;
106 int exitval;
107 int optc;
108 int old_umask;
109 short toycount;
110 short signal;
111 int signalfd;
112 int wasroot;
113
114
115 jmp_buf *rebound;
116 struct arg_list *xexit;
117 void *stacktop;
118} toys;
119
120
121
122extern char toybuf[4096], libbuf[4096];
123
124extern char **environ;
125
126#define GLOBALS(...)
127#define ARRAY_LEN(array) (sizeof(array)/sizeof(*array))
128#define TAGGED_ARRAY(X, ...) {__VA_ARGS__}
129