This source file includes following definitions.
- aout_compat_setup
- aout_sys_open
- aout_sys_link
- aout_sys_unlink
- aout_sys_rename
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 #include <sys/param.h>
28 #include <sys/syscall.h>
29 #include <sys/signalvar.h>
30 #include <sys/mount.h>
31 #include <sys/syscallargs.h>
32 #include <sys/fcntl.h>
33 #include <compat/common/compat_util.h>
34
35 void aout_compat_setup(struct exec_package *epp);
36
37 extern char sigcode[], esigcode[];
38
39 struct sysent aout_sysent[SYS_MAXSYSCALL];
40
41 struct emul emul_aout = {
42 "aout",
43 NULL,
44 sendsig,
45 SYS_syscall,
46 SYS_MAXSYSCALL,
47 NULL,
48 #ifdef SYSCALL_DEBUG
49 syscallnames,
50 #else
51 NULL,
52 #endif
53 0,
54 copyargs,
55 setregs,
56 NULL,
57 sigcode,
58 esigcode,
59 };
60
61 #ifdef syscallarg
62 #undef syscallarg
63 #endif
64
65 #define syscallarg(x) \
66 union { \
67 register_t pad; \
68 struct { x datum; } le; \
69 struct { \
70 int8_t pad[ (sizeof (register_t) < sizeof (x)) \
71 ? 0 \
72 : sizeof (register_t) - sizeof (x)]; \
73 x datum; \
74 } be; \
75 }
76
77
78 struct aout_sys_open_args {
79 syscallarg(char *) path;
80 syscallarg(int) flags;
81 syscallarg(int) mode;
82 };
83
84 struct aout_sys_link_args {
85 syscallarg(char *) path;
86 syscallarg(char *) link;
87 };
88
89 struct aout_sys_unlink_args {
90 syscallarg(char *) path;
91 };
92
93 struct aout_sys_rename_args {
94 syscallarg(char *) from;
95 syscallarg(char *) to;
96 };
97
98 int aout_sys_open(struct proc *, void *, register_t *);
99 int aout_sys_link(struct proc *, void *, register_t *);
100 int aout_sys_unlink(struct proc *, void *, register_t *);
101 int aout_sys_rename(struct proc *, void *, register_t *);
102
103 const char aout_path[] = "/emul/a.out";
104
105 #define AOUT_CHECK_ALT_EXIST(p, sgp, path) \
106 CHECK_ALT_EXIST(p, sgp, aout_path, path)
107
108 #define AOUT_CHECK_ALT_CREAT(p, sgp, path) \
109 CHECK_ALT_CREAT(p, sgp, aout_path, path)
110
111
112
113 void
114 aout_compat_setup(struct exec_package *epp)
115 {
116 if (emul_aout.e_sysent == NULL) {
117 memcpy(aout_sysent, sysent, sizeof aout_sysent);
118 aout_sysent[SYS_open].sy_call = aout_sys_open;
119 aout_sysent[SYS_link].sy_call = aout_sys_link;
120 aout_sysent[SYS_unlink].sy_call = aout_sys_unlink;
121 aout_sysent[SYS_rename].sy_call = aout_sys_rename;
122 emul_aout.e_sysent = aout_sysent;
123 }
124 epp->ep_emul = &emul_aout;
125 }
126
127 int
128 aout_sys_open(p, v, retval)
129 struct proc *p;
130 void *v;
131 register_t *retval;
132 {
133 struct aout_sys_open_args
134
135
136
137 *uap = v;
138 caddr_t sg = stackgap_init(p->p_emul);
139
140 if (SCARG(uap, flags) & O_CREAT)
141 AOUT_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
142 else
143 AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
144 return sys_open(p, uap, retval);
145 }
146
147 int
148 aout_sys_link(p, v, retval)
149 struct proc *p;
150 void *v;
151 register_t *retval;
152 {
153 struct aout_sys_link_args
154
155
156 *uap = v;
157 caddr_t sg = stackgap_init(p->p_emul);
158
159 AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
160 AOUT_CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
161 return sys_link(p, uap, retval);
162 }
163
164 int
165 aout_sys_unlink(p, v, retval)
166 struct proc *p;
167 void *v;
168 register_t *retval;
169 {
170 struct aout_sys_unlink_args
171
172 *uap = v;
173 caddr_t sg = stackgap_init(p->p_emul);
174
175 AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
176 return sys_unlink(p, uap, retval);
177 }
178
179
180 int
181 aout_sys_rename(p, v, retval)
182 struct proc *p;
183 void *v;
184 register_t *retval;
185 {
186 struct aout_sys_rename_args
187
188
189 *uap = v;
190 caddr_t sg = stackgap_init(p->p_emul);
191
192 AOUT_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
193 AOUT_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
194 return sys_rename(p, uap, retval);
195 }