Pristine Ack-5.5
[Ack-5.5.git] / mach / minixST / libsys / libmon_s.a
1 eÿaccess.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
2 .sect .text
3 .define _access
4 _access:
5         jmp __access
6 alarm.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
7 .sect .text
8 .define _alarm
9 _alarm:
10         jmp __alarm
11 sbrk.s\0s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0|\0.sect .text; .sect .rom; .sect .data; .sect .bss
12 .sect .text
13 .define _brk
14 .define _sbrk
15 _brk:
16         jmp __brk
17 _sbrk:
18         jmp __sbrk
19 chdir.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
20 .sect .text
21 .define _chdir
22 _chdir:
23         jmp __chdir
24 pchmod.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
25 .sect .text
26 .define _chmod
27 _chmod:
28         jmp __chmod
29 pchown.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
30 .sect .text
31 .define _chown
32 _chown:
33         jmp __chown
34 pchroot.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
35 .sect .text
36 .define _chroot
37 _chroot:
38         jmp __chroot
39 close.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
40 .sect .text
41 .define _close
42 _close:
43         jmp __close
44 ocreat.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
45 .sect .text
46 .define _creat
47 _creat:
48         jmp __creat
49 odup.s\0s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0[\0.sect .text; .sect .rom; .sect .data; .sect .bss
50 .sect .text
51 .define _dup
52 _dup:
53         jmp __dup
54 cdup2.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
55 .sect .text
56 .define _dup2
57 _dup2:
58         jmp __dup2
59 exec.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ó\0.sect .text; .sect .rom; .sect .data; .sect .bss
60 .sect .text
61 .define _execl
62 .define _execle
63 .define _execv
64 .define _execve
65 _execl:
66         jmp __execl
67 _execle:
68         jmp __execle
69 _execv:
70         jmp __execv
71 _execve:
72         jmp __execve
73 \0execn.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
74 .sect .text
75 .define _execn
76 _execn:
77         jmp __execn
78 nexecnl.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\88\0.sect .text; .sect .rom; .sect .data; .sect .bss
79 .sect .text
80 .define _execn
81 .define _execnl
82 _execn:
83         jmp __execn
84 _execnl:
85         jmp __execnl
86 fcntl.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
87 .sect .text
88 .define _fcntl
89 _fcntl:
90         jmp __fcntl
91 nfork.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
92 .sect .text
93 .define _fork
94 _fork:
95         jmp __fork
96 fstat.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
97 .sect .text
98 .define _fstat
99 _fstat:
100         jmp __fstat
101 ngetcwd.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
102 .sect .text
103 .define _getcwd
104 _getcwd:
105         jmp __getcwd
106 getegid.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0g\0.sect .text; .sect .rom; .sect .data; .sect .bss
107 .sect .text
108 .define _getegid
109 _getegid:
110         jmp __getegid
111 pgeteuid.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0g\0.sect .text; .sect .rom; .sect .data; .sect .bss
112 .sect .text
113 .define _geteuid
114 _geteuid:
115         jmp __geteuid
116 pgetgid.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
117 .sect .text
118 .define _getgid
119 _getgid:
120         jmp __getgid
121 getpid.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
122 .sect .text
123 .define _getpid
124 _getpid:
125         jmp __getpid
126 getppid.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0g\0.sect .text; .sect .rom; .sect .data; .sect .bss
127 .sect .text
128 .define _getppid
129 _getppid:
130         jmp __getppid
131 pgetuid.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
132 .sect .text
133 .define _getuid
134 _getuid:
135         jmp __getuid
136 gtty.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
137 .sect .text
138 .define _gtty
139 _gtty:
140         jmp __gtty
141 ioctl.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
142 .sect .text
143 .define _ioctl
144 _ioctl:
145         jmp __ioctl
146 ikill.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
147 .sect .text
148 .define _kill
149 _kill:
150         jmp __kill
151 link.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
152 .sect .text
153 .define _link
154 _link:
155         jmp __link
156 lseek.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
157 .sect .text
158 .define _lseek
159 _lseek:
160         jmp __lseek
161 imkdir.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
162 .sect .text
163 .define _mkdir
164 _mkdir:
165         jmp __mkdir
166 imkfifo.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
167 .sect .text
168 .define _mkfifo
169 _mkfifo:
170         jmp __mkfifo
171 mknod.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
172 .sect .text
173 .define _mknod
174 _mknod:
175         jmp __mknod
176 fmknod4.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
177 .sect .text
178 .define _mknod4
179 _mknod4:
180         jmp __mknod4
181 mount.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
182 .sect .text
183 .define _mount
184 _mount:
185         jmp __mount
186 dopen.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
187 .sect .text
188 .define _open
189 _open:
190         jmp __open
191 pause.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
192 .sect .text
193 .define _pause
194 _pause:
195         jmp __pause
196 dpipe.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
197 .sect .text
198 .define _pipe
199 _pipe:
200         jmp __pipe
201 ptrace.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
202 .sect .text
203 .define _ptrace
204 _ptrace:
205         jmp __ptrace
206 read.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
207 .sect .text
208 .define _read
209 _read:
210         jmp __read
211 rename.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
212 .sect .text
213 .define _rename
214 _rename:
215         jmp __rename
216 rmdir.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
217 .sect .text
218 .define _rmdir
219 _rmdir:
220         jmp __rmdir
221 msetgid.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
222 .sect .text
223 .define _setgid
224 _setgid:
225         jmp __setgid
226 setuid.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
227 .sect .text
228 .define _setuid
229 _setuid:
230         jmp __setuid
231 signal.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
232 .sect .text
233 .define _signal
234 _signal:
235         jmp __signal
236 stat.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
237 .sect .text
238 .define _stat
239 _stat:
240         jmp __stat
241 stime.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
242 .sect .text
243 .define _stime
244 _stime:
245         jmp __stime
246 astty.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
247 .sect .text
248 .define _stty
249 _stty:
250         jmp __stty
251 sync.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
252 .sect .text
253 .define _sync
254 _sync:
255         jmp __sync
256 time.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
257 .sect .text
258 .define _time
259 _time:
260         jmp __time
261 times.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
262 .sect .text
263 .define _times
264 _times:
265         jmp __times
266 aumask.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
267 .sect .text
268 .define _umask
269 _umask:
270         jmp __umask
271 aumount.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
272 .sect .text
273 .define _umount
274 _umount:
275         jmp __umount
276 unlink.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0d\0.sect .text; .sect .rom; .sect .data; .sect .bss
277 .sect .text
278 .define _unlink
279 _unlink:
280         jmp __unlink
281 utime.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
282 .sect .text
283 .define _utime
284 _utime:
285         jmp __utime
286 nwait.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0^\0.sect .text; .sect .rom; .sect .data; .sect .bss
287 .sect .text
288 .define _wait
289 _wait:
290         jmp __wait
291 write.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0a\0.sect .text; .sect .rom; .sect .data; .sect .bss
292 .sect .text
293 .define _write
294 _write:
295         jmp __write
296 nexit.c\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Y\0#include <lib.h>
297
298 PUBLIC int exit(status)
299 int status;
300 {
301   _cleanup();
302   _exit(status);
303 }
304 _cleanup.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ f\0_cleanup()
305 {
306 }
307 >_exit.c\0c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\8e\0#include <lib.h>
308 #include <unistd.h>
309
310 PUBLIC void _exit(status)
311 int status;
312 {
313   _callm1(MM, EXIT, status, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
314 }
315 _access.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0 \0#include <lib.h>
316 #define access  _access
317 #include <unistd.h>
318
319 PUBLIC int access(name, mode)
320 char *name;
321 int mode;
322 {
323   return(_callm3(FS, ACCESS, mode, name));
324 }
325 _alarm.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0º\0#include <lib.h>
326 #define alarm   _alarm
327 #include <unistd.h>
328
329 PUBLIC unsigned int alarm(sec)
330 unsigned int sec;
331 {
332   return(_callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
333 }
334 _brk.c\0c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\02\ 2#include <lib.h>
335 #define brk     _brk
336 #define sbrk    _sbrk
337 #include <unistd.h>
338
339 extern char *_brksize;
340
341 PUBLIC char *brk(addr)
342 char *addr;
343 {
344   if (_callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR) == 0) {
345         _brksize = _M.m2_p1;
346         return(NIL_PTR);
347   } else {
348         return((char *) -1);
349   }
350 }
351
352
353 PUBLIC char *sbrk(incr)
354 int incr;
355 {
356   char *newsize, *oldsize;
357
358   oldsize = _brksize;
359   newsize = _brksize + incr;
360   if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize)
361         return((char *) -1);
362   if (_brk(newsize) == 0)
363         return(oldsize);
364   else
365         return((char *) -1);
366 }
367 call.c\0c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\14\b#include <lib.h>
368
369 PUBLIC int _callm1(proc, syscallnr, int1, int2, int3, ptr1, ptr2, ptr3)
370 int proc;                       /* FS or MM */
371 int syscallnr;                  /* which system call */
372 int int1;                       /* first integer parameter */
373 int int2;                       /* second integer parameter */
374 int int3;                       /* third integer parameter */
375 char *ptr1;                     /* pointer parameter */
376 char *ptr2;                     /* pointer parameter */
377 char *ptr3;                     /* pointer parameter */
378 {
379 /* Send a message and get the response.  The '_M.m_type' field of the
380  * reply contains a value (>= 0) or an error code (<0). Use message format m1.
381  */
382   _M.m1_i1 = int1;
383   _M.m1_i2 = int2;
384   _M.m1_i3 = int3;
385   _M.m1_p1 = ptr1;
386   _M.m1_p2 = ptr2;
387   _M.m1_p3 = ptr3;
388   return _callx(proc, syscallnr);
389 }
390
391
392 PUBLIC int _callm3(proc, syscallnr, int1, name)
393 int proc;                       /* FS or MM */
394 int syscallnr;                  /* which system call */
395 int int1;                       /* integer parameter */
396 _CONST char *name;              /* string */
397 {
398 /* This form of system call is used for those calls that contain at most
399  * one integer parameter along with a string.  If the string fits in the
400  * message, it is copied there.  If not, a pointer to it is passed.
401  */
402   register int k;
403   register char *rp;
404   k = _len(name);
405   _M.m3_i1 = k;
406   _M.m3_i2 = int1;
407   _M.m3_p1 = (char *) name;
408   rp = &_M.m3_ca1[0];
409   if (k <= M3_STRING) while (k--)
410                 *rp++ = *name++;
411   return _callx(proc, syscallnr);
412 }
413
414
415 PUBLIC int _callx(proc, syscallnr)
416 int proc;                       /* FS or MM */
417 int syscallnr;                  /* which system call */
418 {
419 /* Send a message and get the response.  The '_M.m_type' field of the
420  * reply contains a value (>= 0) or an error code (<0).
421  */
422   int k;
423
424   _M.m_type = syscallnr;
425   k = _sendrec(proc, &_M);
426   if (k != 0) return(k);        /* _send() itself failed */
427   if (_M.m_type < 0) {
428         errno = -_M.m_type;
429         return(-1);
430   }
431   return(_M.m_type);
432 }
433
434
435 PUBLIC int _len(s)
436 _CONST register char *s;        /* character string whose length is needed */
437 {
438 /* Return the length of a character string, including the 0 at the end. */
439   register int k;
440
441   k = 0;
442   while (*s++ != 0) k++;
443   return(k + 1);                /* return length including the 0-byte at end */
444 }
445 _chdir.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\89\0#include <lib.h>
446 #define chdir   _chdir
447 #include <unistd.h>
448
449 PUBLIC int chdir(name)
450 char *name;
451 {
452   return(_callm3(FS, CHDIR, 0, name));
453 }
454 w_chmod.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¨\0#include <lib.h>
455 #define chmod   _chmod
456 #include <sys/stat.h>
457
458 PUBLIC int chmod(name, mode)
459 _CONST char *name;
460 mode_t mode;
461 {
462   return(_callm3(FS, CHMOD, mode, name));
463 }
464 _chown.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ì\0#include <lib.h>
465 #define chown   _chown
466 #include <unistd.h>
467
468 PUBLIC int chown(name, owner, grp)
469 char *name;
470 int owner, grp;
471 {
472   return(_callm1(FS, CHOWN, _len(name), owner, grp, name, NIL_PTR, NIL_PTR));
473 }
474 _chroot.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\94\0#include <lib.h>
475 #define chroot  _chroot
476 #include <unistd.h>
477
478 PUBLIC int chroot(name)
479 _CONST char *name;
480 {
481   return(_callm3(FS, CHROOT, 0, name));
482 }
483 _close.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\9f\0#include <lib.h>
484 #define close   _close
485 #include <unistd.h>
486
487 PUBLIC int close(fd)
488 int fd;
489 {
490   return(_callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
491 }
492 m_creat.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¥\0#include <lib.h>
493 #define creat   _creat
494 #include <fcntl.h>
495
496 PUBLIC int creat(name, mode)
497 _CONST char *name;
498 mode_t mode;
499 {
500   return(_callm3(FS, CREAT, mode, name));
501 }
502 w_dup.c\0c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\8a\0#include <lib.h>
503 #define dup     _dup
504 #include <unistd.h>
505 #include <fcntl.h>
506
507 PUBLIC int dup(fd)
508 int fd;
509 {
510   return(fcntl(fd, F_DUPFD, 0));
511 }
512 _dup2.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0.\ 2#include <lib.h>
513 #define dup2     _dup2
514 #include <unistd.h>
515 #include <fcntl.h>
516 #include <limits.h>
517 #include <errno.h>
518
519 PUBLIC int dup2(fd, fd2)
520 int fd, fd2;
521 {
522 /* The behavior of dup2 is defined by POSIX in 6.2.1.2 as almost, but not
523  * quite the same as fcntl.
524  */
525
526   if (fd2 < 0 || fd2 > OPEN_MAX) {
527         errno = EBADF;
528         return(-1);
529   }
530
531   /* Check to see if fildes is valid. */
532   if (fcntl(fd, F_GETFL) < 0) {
533         /* fd is not valid. */
534         return(-1);
535   } else {
536         /* fd is valid. */
537         if (fd == fd2) return(fd2);
538         close(fd2);
539         return(fcntl(fd, F_DUPFD, fd2));
540   }
541 }
542 _exec.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ã\ f#include <lib.h>
543 #include <unistd.h>
544 #define execl   _execl
545 #define execle  _execle
546 #define execv   _execv
547 #define execve  _execve
548
549 extern char **environ;          /* environment pointer */
550
551 #define PTRSIZE (sizeof(char *))
552 _PROTOTYPE( char *_sbrk, (int _incr)                                    );
553
554 #if _ANSI
555 #include        <stdarg.h>
556
557 PUBLIC int execl(char *name, ...)
558 {
559         int retval;
560         va_list ap;
561
562         va_start(ap, name);
563         retval = execve(name, (char **)ap, environ);
564         va_end(ap);
565         return retval;
566 }
567 #else
568 PUBLIC int execl(name, arg0)
569 char *name;
570 char *arg0;
571 {
572   return(execve(name, &arg0, environ));
573 }
574 #endif
575
576 #if _ANSI
577 PUBLIC int execle(char *name, ...)
578 {
579         int retval;
580         va_list ap;
581         char *p;
582
583         va_start(ap, name);
584         do {
585             p = va_arg(ap, char *);
586         } while(p);
587         p = (char *)va_arg(ap, char **);
588         va_end(ap);
589         va_start(ap, name);
590         retval = execve(name, (char **)ap, (char **) p);
591         va_end(ap);
592         return retval;
593 }
594 #else
595 PUBLIC int execle(name, argv)
596 char *name, *argv;
597 {
598   char **p;
599   p = (char **) &argv;
600   while (*p++)                  /* null statement */
601         ;
602   return(execve(name, &argv, (char **) *p));
603 }
604 #endif
605
606 PUBLIC int execv(name, argv)
607 char *name, *argv[];
608 {
609
610   return(execve(name, argv, environ));
611 }
612
613 PUBLIC int execve(path, argv, envp)
614 char *path;                     /* pointer to name of file to be executed */
615 char *argv[];                   /* pointer to argument array */
616 char *envp[];                   /* pointer to environment */
617 {
618   register char **argtop;
619   register char **envtop;
620
621         /* Count the argument pointers and environment pointers. */
622   for (argtop = argv; *argtop != (char *) NULL; ) argtop++;
623   for (envtop = envp; *envtop != (char *) NULL; ) envtop++;
624   return(__execve(path, argv, envp, (int)(argtop - argv), (int)(envtop - envp)));
625 }
626
627 PUBLIC int __execve(path, argv, envp, nargs, nenvps)
628 char *path;                     /* pointer to name of file to be executed */
629 char *argv[];                   /* pointer to argument array */
630 char *envp[];                   /* pointer to environment */
631 int nargs;                      /* number of args */
632 int nenvps;                     /* number of environment strings */
633 {
634 /* This is split off from execve to be called from execvp, so execvp does not
635  * have to allocate up to ARG_MAX bytes just to prepend "sh" to the arg array.
636  */
637
638   char *hp, **ap, *p;
639   int i, stackbytes, npointers, overflow, temp;
640   char *stack;
641   /* Decide how big a stack is needed. Be paranoid about overflow. */
642 #if ARG_MAX > INT_MAX
643 #error /* overflow checks and sbrk depend on sizes being ints */
644 #endif
645   overflow = FALSE;
646   npointers = 1 + nargs + 1 + nenvps + 1;       /* 1's for argc and NULLs */
647   stackbytes = 0;       /* changed because _len is used now */
648   if (nargs < 0 || nenvps < 0 || nargs+nenvps < 0 || npointers < 0)
649         overflow = TRUE;
650   for (i = PTRSIZE; i != 0; i--) {
651         temp = stackbytes + npointers;
652         if (temp < stackbytes) overflow = TRUE;
653         stackbytes = temp;
654   }
655   for (i = 0, ap = argv; i < nargs; i++) {
656         temp = stackbytes + _len(*ap++);
657         if (temp < stackbytes) overflow = TRUE;
658         stackbytes = temp;
659   }
660   for (i = 0, ap = envp; i < nenvps; i++) {
661         temp = stackbytes + _len(*ap++);
662         if (temp < stackbytes) overflow = TRUE;
663         stackbytes = temp;
664   }
665   temp = stackbytes + PTRSIZE - 1;
666   if (temp < stackbytes) overflow = TRUE;
667   stackbytes = (temp / PTRSIZE) * PTRSIZE;
668
669   /* Check for overflow before committing sbrk. */
670   if (overflow || stackbytes > ARG_MAX) {
671         errno = E2BIG;
672         return(-1);
673   }
674
675   /* Allocate the stack. */
676   stack = _sbrk(stackbytes);
677   if (stack == (char *) -1) {
678         errno = E2BIG;
679         return(-1);
680   }
681
682   /* Prepare the stack vector and argc. */
683   ap = (char **) stack;
684   hp = &stack[npointers * PTRSIZE];
685   *ap++ = (char *) nargs;
686
687   /* Prepare the argument pointers and strings. */
688   for (i = 0; i < nargs; i++) {
689         *ap++ = (char *) (hp - stack);
690         p = *argv++;
691         while ((*hp++ = *p++) != 0)
692                 ;
693   }
694   *ap++ = (char *) NULL;
695
696   /* Prepare the environment pointers and strings. */
697   for (i = 0; i < nenvps; i++) {
698         *ap++ = (char *) (hp - stack);
699         p = *envp++;
700         while ((*hp++ = *p++) != 0)
701                 ;
702   }
703   *ap++ = (char *) NULL;
704
705   /* Do the real work. */
706   temp = _callm1(MM, EXEC, _len(path), stackbytes, 0, path, stack, NIL_PTR);
707   _sbrk(-stackbytes);
708   return(temp);
709 }
710 \0_execn.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0´\ 1#include <lib.h>
711
712 #define PTRSIZE sizeof(char *)
713 _PROTOTYPE( int _execn, (char * name));
714
715 PUBLIC int _execn(name)
716 char *name;                     /* pointer to file to be exec'd */
717 {
718 /* Special version used when there are no args and no environment.  This call
719  * is principally used by INIT, to avoid having to allocate ARG_MAX.
720  */
721
722   PRIVATE char stack[3 * PTRSIZE];
723
724   return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR));
725 }
726 _execnl.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\09\a/*
727  * This file contains two functions that can be used to perform
728  * an EXEC call without the need for a "big" stack of MAX_ARG
729  * bytes.  It is primarily used by the INIT module of the system.
730  */
731 #include <lib.h>
732 #include <sys/types.h>
733 #include <unistd.h>
734
735 #define MAXSTK  256             /* maximum EXEC stack size */
736 #define PTRSIZE sizeof(char *)
737
738 _PROTOTYPE(int _execn,(char *name));
739 _PROTOTYPE(int _execnl,(char *name, char *arg0));
740 PRIVATE _PROTOTYPE(int _nexec,(char *name, char *argv[]));
741
742 PUBLIC int _execn(name)
743 char *name;                     /* pointer to file to be exec'd */
744 {
745 /* This funcion uses no arguments at all. */
746   PRIVATE char stack[3 * PTRSIZE];
747
748   return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR));
749 }
750
751
752 PUBLIC int _execnl(name, arg0)
753 char *name;
754 char *arg0;
755 {
756   /* This function resembles execl(2). */
757
758   return(_nexec(name, &arg0));
759 }
760
761 PRIVATE int _nexec(name, argv)
762 char *name;                     /* pointer to name of file to be executed */
763 char *argv[];                   /* pointer to argument array */
764 {
765   char stack[MAXSTK];
766   char **argorg, *hp, **ap, *p;
767   int i, nargs, stackbytes, offset;
768
769   /* Count the argument pointers. */
770   nargs = 0;
771   argorg = argv;
772   while (*argorg++ != NIL_PTR) nargs++;
773
774   /* Prepare to set up the initial stack. */
775   hp = &stack[(nargs + 3) * PTRSIZE];
776   if (hp + nargs >= &stack[MAXSTK]) {
777         errno = E2BIG;
778         return(-1);
779   }
780   ap = (char **) stack;
781   *ap++ = (char *) nargs;
782
783   /* Prepare the argument pointers and strings. */
784   for (i = 0; i < nargs; i++) {
785         offset = hp - stack;
786         *ap++ = (char *) offset;
787         p = *argv++;
788         while (*p) {
789                 *hp++ = *p++;
790                 if (hp >= &stack[MAXSTK]) {
791                         errno = E2BIG;
792                         return(-1);
793                 }
794         }
795         *hp++ = (char) 0;
796   }
797   *ap++ = NIL_PTR;
798
799   stackbytes = (((int) (hp - stack) + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
800   return(_callm1(MM, EXEC, _len(name), stackbytes, 0, name, stack, NIL_PTR));
801 }
802 m_fcntl.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 2\ 4#include <lib.h>
803 #define fcntl _fcntl
804 #include <fcntl.h>
805 #if _ANSI
806 #endif
807
808 #if _ANSI
809 #include <stdarg.h>
810 PUBLIC int fcntl(int fd, int cmd, ...)
811 {
812 #else
813 #include <varargs.h>
814 PUBLIC int fcntl(va_alist)
815 va_dcl
816 {
817 int fd;
818 int cmd;
819 #endif
820   va_list ap;
821   int int3;                     /* third integer parameter for callm1 */
822   char *ptr1;                   /* first pointer parameter for callm1 */
823
824 #if _ANSI
825   va_start(ap, cmd);
826 #else
827   va_start(ap);
828   fd = va_arg(ap, int);
829   cmd = va_arg(ap, int);
830 #endif
831
832   /* Set up for the sensible case where there is no variable parameter.  This
833    * covers F_GETFD, F_GETFL and invalid commands.
834    */
835   int3 = 0;
836   ptr1 = NIL_PTR;
837
838   /* Adjust for the stupid cases. */
839   switch(cmd) {
840      case F_DUPFD:
841      case F_SETFD:
842      case F_SETFL:
843         int3 = va_arg(ap, int);
844         break;
845      case F_GETLK:
846      case F_SETLK:
847      case F_SETLKW:
848         ptr1 = (char *) va_arg(ap, struct flock *);
849         break;
850   }
851
852   /* Clean up and make the system call. */  
853   va_end(ap);   
854   return(_callm1(FS, FCNTL, fd, cmd, int3, ptr1, NIL_PTR, NIL_PTR));
855 }
856 _fork.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\90\0#include <lib.h>
857 #define fork    _fork
858 #include <unistd.h>
859
860 PUBLIC int fork()
861 {
862   return(_callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
863 }
864 fpathconf.c\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\83\ 5/* POSIX fpathconf (Sec. 5.7.1)               Author: Andy Tanenbaum */
865
866 #include <lib.h>
867 #include <unistd.h>
868 #include <sys/types.h>
869 #define fstat   _fstat
870 #include <sys/stat.h>
871 #include <errno.h>
872 #include <limits.h>
873
874 PUBLIC long fpathconf(fd, name)
875 int fd;                         /* file descriptor being interrogated */
876 int name;                       /* property being inspected */
877 {
878 /* POSIX allows some of the values in <limits.h> to be increased at
879  * run time.  The pathconf and fpathconf functions allow these values
880  * to be checked at run time.  MINIX does not use this facility.
881  * The run-time limits are those given in <limits.h>.
882  */
883
884   struct stat stbuf;
885
886   switch(name) {
887         case _PC_LINK_MAX:
888                 /* Fstat the file.  If that fails, return -1. */
889                 if (fstat(fd, &stbuf) != 0) return(-1L);
890                 if (S_ISDIR(stbuf.st_mode))
891                         return(1L);     /* no links to directories */
892                 else
893                         return( (long) LINK_MAX);
894
895         case _PC_MAX_CANON:
896                 return( (long) MAX_CANON);
897
898         case _PC_MAX_INPUT:
899                 return( (long) MAX_INPUT);
900
901         case _PC_NAME_MAX:
902                 return( (long) NAME_MAX);
903
904         case _PC_PATH_MAX:
905                 return( (long) PATH_MAX);
906
907         case _PC_PIPE_BUF:
908                 return( (long) PIPE_BUF);
909
910         case _PC_CHOWN_RESTRICTED:
911                 return( (long) 1);      /* MINIX defines CHOWN_RESTRICTED */
912
913         case _PC_NO_TRUNC:              /* MINIX does not define NO_TRUNC */
914                 return( (long) 0);
915
916         case _PC_VDISABLE:              /* MINIX defines VDISABLE */
917                 return( (long) _POSIX_VDISABLE);
918
919         default:
920                 errno = EINVAL;
921                 return(-1L);
922   }
923 }
924 *_fstat.c\0.c\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ü\0#include <lib.h>
925 #include <sys/types.h>
926 #define fstat   _fstat
927 #include <sys/stat.h>
928
929 PUBLIC int fstat(fd, buffer)
930 int fd;
931 struct stat *buffer;
932 {
933   return(_callm1(FS, FSTAT, fd, 0, 0, (char *)buffer, NIL_PTR, NIL_PTR));
934 }
935 _getcwd.c\0c\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\v/*  getcwd - get current working directory    Author: Terrence W. Holm */
936
937 /* Directly derived from Adri Koppes' pwd(1).
938  * Modified by Andy Tanenbaum for POSIX (29 Oct. 1989)
939  */
940
941 #include <lib.h>
942 #include <sys/stat.h>
943 #include <fcntl.h>
944 #include <sys/dir.h>
945 #include <string.h>
946 #define getcwd  _getcwd
947
948 #define  DIRECT_SIZE  (sizeof (struct direct))
949
950 PRIVATE _PROTOTYPE(void  go_back, (char *path) );
951
952 char *getcwd(buffer, size)
953 char *buffer;
954 int size;
955 /* Get current working directory. */
956 {
957   int same_device, found, fd;
958   char *r, path[PATH_MAX + 1], temp_name[NAME_MAX + 1];
959   struct stat current, parent, dir_entry;
960   struct direct d;
961
962   if (buffer == (char *)NULL || size <= 0) {
963         errno = EINVAL;
964         return((char *)NULL);
965   }
966   path[0] = '\0';
967
968   /* Get the inode for the current directory  */
969   if (stat(".", &current) == -1) return((char *)NULL);
970   if ((current.st_mode & S_IFMT) != S_IFDIR) return((char *)NULL);
971
972   /* Run backwards up the directory tree, grabbing dir names on the way. */
973   while (1) {
974         same_device = 0;
975         found = 0;
976
977         /* Get the inode for the parent directory  */
978         if (chdir("..") == -1) return((char *)NULL);
979         if (stat(".", &parent) == -1) return((char *)NULL);
980         if ((parent.st_mode & S_IFMT) != S_IFDIR) return((char *)NULL);
981         if (current.st_dev == parent.st_dev) same_device = 1;
982
983         /* At the root, "." is the same as ".."  */
984         if (same_device && current.st_ino == parent.st_ino) break;
985
986         /* Search the parent directory for the current entry  */
987         if ((fd = open(".", O_RDONLY)) == -1) return((char *)NULL);
988         while (!found && read(fd, (char *)&d, DIRECT_SIZE) == DIRECT_SIZE) {
989                 if (d.d_ino == 0L) continue;    /* empty slot */
990                 if (same_device) {
991                         if (current.st_ino == d.d_ino) found = 1;
992                 } else {
993                         temp_name[0] = '\0';
994                         strncat(temp_name, d.d_name, NAME_MAX);
995                         if (stat(temp_name, &dir_entry) == -1) {
996                                 close(fd);
997                                 go_back(path);
998                                 return((char *)NULL);
999                         }
1000                         if (current.st_dev == dir_entry.st_dev &&
1001                             current.st_ino == dir_entry.st_ino)
1002                                 found = 1;
1003                 }
1004         }
1005
1006         close(fd);
1007         if (!found) {
1008                 go_back(path);
1009                 return((char *)NULL);
1010         }
1011         if (strlen(path) + NAME_MAX + 1 > PATH_MAX) {
1012                 errno = ERANGE;
1013                 go_back(path);
1014                 return((char *)NULL);
1015         }
1016         strcat(path, "/");
1017         strncat(path, d.d_name, NAME_MAX);
1018         current.st_dev = parent.st_dev;
1019         current.st_ino = parent.st_ino;
1020   }
1021
1022   /* Copy the reversed path name into <buffer>  */
1023   if (strlen(path) + 1 > size) {
1024         errno = ERANGE;
1025         go_back(path);
1026         return((char *)NULL);
1027   }
1028   if (strlen(path) == 0) {
1029         strcpy(buffer, "/");
1030         return(buffer);
1031   }
1032   *buffer = '\0';
1033   while ((r = strrchr(path, '/')) != (char *)NULL) {
1034         strcat(buffer, r);
1035         *r = '\0';
1036   }
1037   return(chdir(buffer) ? (char *)NULL : buffer);
1038 }
1039
1040 PRIVATE void go_back(path)
1041 char *path;
1042 {
1043 /* If getcwd() gets in trouble and can't complete normally, reverse the
1044  * path built so far and change there so we end up in the directory that
1045  * we started in.
1046  */
1047
1048   char *r;
1049
1050   while ((r = strrchr(path, '/')) != (char *)NULL) {
1051         chdir(r+1);
1052         *r = '\0';
1053   }
1054 }
1055 _getegid.c\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0õ\0#include <lib.h>
1056 #include <sys/types.h>
1057 #define getegid _getegid
1058 #include <unistd.h>
1059
1060 PUBLIC gid_t getegid()
1061 {
1062   int k;
1063   k = _callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1064   if (k < 0) return((gid_t) k);
1065   return((gid_t) _M.m2_i1);
1066 }
1067 <_geteuid.c\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0õ\0#include <lib.h>
1068 #include <sys/types.h>
1069 #define geteuid _geteuid
1070 #include <unistd.h>
1071
1072 PUBLIC uid_t geteuid()
1073 {
1074   int k;
1075   k = _callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1076   if (k < 0) return((uid_t) k);
1077   return((uid_t) _M.m2_i1);
1078 }
1079 <_getgid.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¸\0#include <lib.h>
1080 #include <sys/types.h>
1081 #define getgid  _getgid
1082 #include <unistd.h>
1083
1084 PUBLIC gid_t getgid()
1085 {
1086   return((gid_t)_callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1087 }
1088 _getpid.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\98\0#include <lib.h>
1089 #define getpid  _getpid
1090 #include <unistd.h>
1091
1092 PUBLIC int getpid()
1093 {
1094   return(_callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1095 }
1096 _getppid.c\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Í\0#include <lib.h>
1097 #define getppid _getppid
1098 #include <unistd.h>
1099
1100 PUBLIC int getppid()
1101 {
1102   int p;
1103
1104   p = _callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1105   if (p < 0) return(p);
1106   return(_M.m2_i1);
1107 }
1108 i_getuid.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¸\0#include <lib.h>
1109 #include <sys/types.h>
1110 #define getuid  _getuid
1111 #include <unistd.h>
1112
1113 PUBLIC uid_t getuid()
1114 {
1115   return((uid_t)_callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1116 }
1117 _gtty.c\0c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0­\0#include <lib.h>
1118 #define gtty    _gtty
1119 #define ioctl   _ioctl
1120 #include <sgtty.h>
1121
1122 PUBLIC int gtty(fd, argp)
1123 int fd;
1124 struct sgttyb *argp;
1125 {
1126   return(ioctl(fd, TIOCGETP, argp));
1127 }
1128 L_ioctl.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\7f\b#include <lib.h>
1129 #include <minix/com.h>
1130 #define ioctl   _ioctl
1131 #include <sgtty.h>
1132
1133 PUBLIC int ioctl(fd, request, argp)
1134 int fd;
1135 int request;
1136 struct sgttyb *argp;
1137 {
1138   int n;
1139   long erase, kill, intr, quit, xon, xoff, eof, brk, speed;
1140   struct tchars *argt;
1141
1142   _M.TTY_REQUEST = request;
1143   _M.TTY_LINE = fd;
1144
1145   switch(request) {
1146      case TIOCSETP:
1147         erase = argp->sg_erase & BYTE;
1148         kill = argp->sg_kill & BYTE;
1149         speed = ((argp->sg_ospeed & BYTE) << 8) | (argp->sg_ispeed & BYTE);
1150         _M.TTY_SPEK = (speed << 16) | (erase << 8) | kill;
1151         _M.TTY_FLAGS = argp->sg_flags;
1152         n = _callx(FS, IOCTL);
1153         return(n);
1154  
1155      case TIOCSETC:
1156         argt = (struct tchars * /* kludge */) argp;
1157         intr = argt->t_intrc & BYTE;
1158         quit = argt->t_quitc & BYTE;
1159         xon  = argt->t_startc & BYTE;
1160         xoff = argt->t_stopc & BYTE;
1161         eof  = argt->t_eofc & BYTE;
1162         brk  = argt->t_brkc & BYTE;             /* not used at the moment */
1163         _M.TTY_SPEK = (intr<<24) | (quit<<16) | (xon<<8) | (xoff<<0);
1164         _M.TTY_FLAGS = (eof<<8) | (brk<<0);
1165         n = _callx(FS, IOCTL);
1166         return(n);
1167         
1168      case TIOCGETP:
1169         n = _callx(FS, IOCTL);
1170         argp->sg_erase = (_M.TTY_SPEK >> 8) & BYTE;
1171         argp->sg_kill  = (_M.TTY_SPEK >> 0) & BYTE;
1172         argp->sg_flags = _M.TTY_FLAGS & 0xFFFFL;
1173         speed = (_M.TTY_SPEK >> 16) & 0xFFFFL;
1174         argp->sg_ispeed = speed & BYTE;
1175         argp->sg_ospeed = (speed >> 8) & BYTE;
1176         return(n);
1177
1178      case TIOCGETC:
1179         n = _callx(FS, IOCTL);
1180         argt = (struct tchars *) argp;
1181         argt->t_intrc  = (_M.TTY_SPEK >> 24) & BYTE;
1182         argt->t_quitc  = (_M.TTY_SPEK >> 16) & BYTE;
1183         argt->t_startc = (_M.TTY_SPEK >>  8) & BYTE;
1184         argt->t_stopc  = (_M.TTY_SPEK >>  0) & BYTE;
1185         argt->t_eofc   = (_M.TTY_FLAGS >> 8) & BYTE;
1186         argt->t_brkc   = (_M.TTY_FLAGS >> 8) & BYTE;
1187         return(n);
1188
1189 /* This is silly, do we want to add 1001 cases and _M.TTY_XYZ's here?
1190  * We should just pop argp into the message for low-level interpretation.
1191  */
1192
1193      case TIOCFLUSH:
1194         _M.TTY_FLAGS = (int /* kludge */) argp;
1195         return _callx(FS, IOCTL);
1196
1197 /* decided to pop argp in the ADDRESS field. Left TIOCFLUSH a special case
1198  * since it affects other platforms and old software too. FM
1199  */
1200      default:
1201         _M.ADDRESS = (char *)argp;
1202         return _callx(FS, IOCTL);
1203   }
1204 }
1205 (_kill.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ö\0#include <lib.h>
1206 #define kill    _kill
1207 #include <signal.h>
1208
1209 PUBLIC int kill(proc, sig)
1210 int proc;                       /* which process is to be sent the signal */
1211 int sig;                        /* signal number */
1212 {
1213   return(_callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1214 }
1215 _link.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ÿ\0#include <lib.h>
1216 #define link    _link
1217 #include <unistd.h>
1218
1219 PUBLIC int link(name, name2)
1220 _CONST char *name, *name2;
1221 {
1222   return(_callm1(FS, LINK, _len(name), _len(name2), 0,
1223          (char *) name, (char *) name2, /* perhaps callm1 preserves these */
1224          NIL_PTR));
1225 }
1226  _lseek.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0T\ 1#include <lib.h>
1227 #include <sys/types.h>
1228 #define lseek   _lseek
1229 #include <unistd.h>
1230
1231 PUBLIC off_t lseek(fd, offset, whence)
1232 int fd;
1233 off_t offset;
1234 int whence;
1235 {
1236   int k;
1237   _M.m2_i1 = fd;
1238   _M.m2_l1 = offset;
1239   _M.m2_i2 = whence;
1240   k = _callx(FS, LSEEK);
1241   if (k != 0) return((off_t) k);        /* _send() itself failed */
1242   return((off_t)_M.m2_l1);
1243 }
1244 message.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0l\0#include <lib.h>
1245
1246 /* Some compilers require an initializer to force storage allocation */
1247 message _M = {0};
1248 _mkdir.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Î\0#include <lib.h>
1249 #define mkdir   _mkdir
1250 #include <sys/stat.h>
1251
1252 PUBLIC int mkdir(name, mode)
1253 _CONST char *name;
1254 int mode;
1255 {
1256   return(_callm1(FS, MKDIR, _len(name), mode, 0, (char *)name, NIL_PTR, NIL_PTR));
1257 }
1258 _mkfifo.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\11\ 1#include <lib.h>
1259 #include <sys/types.h>
1260 #define mkfifo  _mkfifo
1261 #include <sys/stat.h>
1262
1263 PUBLIC int mkfifo(name, mode)
1264 _CONST char *name;
1265 int mode;
1266 {
1267   mode = (mode & 0777) | S_IFIFO;
1268   return(_callm1(FS, MKNOD, _len(name), (int)mode, 0,
1269          (char *)name, NIL_PTR, NIL_PTR));
1270 }
1271 f_mknod.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ä\0#include <lib.h>
1272 #define mknod   _mknod
1273 #include <unistd.h>
1274
1275 PUBLIC int mknod(name, mode, addr)
1276 _CONST char *name;
1277 int mode, addr;
1278 {
1279   return(_callm1(FS, MKNOD, _len(name), mode, addr,
1280                                         (char *) name, (char *) 0, NIL_PTR));
1281 }
1282 _mknod4.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0
1283 \ 1#include <lib.h>
1284 #define mknod4  _mknod4
1285 #include <unistd.h>
1286
1287 PUBLIC int mknod4(name, mode, addr, size)
1288 _CONST char *name;
1289 int mode, addr;
1290 unsigned int size;
1291 {
1292   return(_callm1(FS, MKNOD, _len(name), mode, addr, 
1293                                        (char *) name, (char *) size, NIL_PTR));
1294 }
1295 _mount.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0â\0#include <lib.h>
1296 #define mount   _mount
1297 #include <unistd.h>
1298
1299 PUBLIC int mount(special, name, rwflag)
1300 char *name, *special;
1301 int rwflag;
1302 {
1303   return(_callm1(FS, MOUNT, _len(special), _len(name), rwflag, special, name, NIL_PTR));
1304 }
1305 _open.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\90\ 2#include <lib.h>
1306 #include <sys/types.h>
1307 #define open    _open
1308 #include <fcntl.h>
1309
1310 #if _ANSI
1311 #include <stdarg.h>
1312
1313 PUBLIC int open(const char *name, int flags, ...)
1314 {
1315         int i;
1316         va_list ap;
1317
1318         if (flags & O_CREAT) {
1319                 va_start(ap, flags);
1320                 i = va_arg(ap, int);
1321                 i = _callm1(FS, OPEN, _len(name), flags, i,
1322                             (char *)name, NIL_PTR, NIL_PTR);
1323                 va_end(ap);
1324                 return i;
1325         }
1326         return _callm3(FS, OPEN, flags, name);
1327 }
1328 #else
1329 PUBLIC int open(name, flags, mode)
1330 _CONST char *name;
1331 int flags, mode;
1332 {
1333   if (flags & O_CREAT)
1334         return _callm1(FS, OPEN, _len(name), flags, mode,
1335                       (char *)name, NIL_PTR, NIL_PTR);
1336   return(_callm3(FS, OPEN, flags, name));
1337 }
1338 #endif
1339 pathconf.c\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Â\ 2/* POSIX pathconf (Sec. 5.7.1)                Author: Andy Tanenbaum */
1340
1341 #include <lib.h>
1342 #include <sys/types.h>
1343 #define open    _open
1344 #include <fcntl.h>
1345 #include <errno.h>
1346 #define close   _close
1347
1348 PUBLIC long pathconf(path, name)
1349 char *path;                     /* name of file being interrogated */
1350 int name;                       /* property being inspected */
1351 {
1352 /* POSIX allows some of the values in <limits.h> to be increased at
1353  * run time.  The pathconf and fpathconf functions allow these values
1354  * to be checked at run time.  MINIX does not use this facility.
1355  * The run-time limits are those given in <limits.h>.
1356  */
1357
1358   int fd;
1359   long val;
1360
1361   if ( (fd = open(path, O_RDONLY)) < 0) return(-1L);
1362   val = fpathconf(fd, name);
1363   close(fd);
1364   return(val);
1365 }
1366 _pause.c\0c\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\94\0#include <lib.h>
1367 #define pause   _pause
1368 #include <unistd.h>
1369
1370 PUBLIC int pause()
1371 {
1372   return(_callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1373 }
1374 _pipe.c\0\0c\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 1\ 1#include <lib.h>
1375 #define pipe    _pipe
1376 #include <unistd.h>
1377
1378 PUBLIC int pipe(fild)
1379 int fild[2];
1380 {
1381   int k;
1382   k = _callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1383   if (k >= 0) {
1384         fild[0] = _M.m1_i1;
1385         fild[1] = _M.m1_i2;
1386         return(0);
1387   } else
1388         return(k);
1389 }
1390 t_ptrace.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0J\ 1#include <lib.h>
1391 #define ptrace _ptrace
1392 #include <unistd.h>
1393
1394 PUBLIC long ptrace(req, pid, addr, data)
1395 int req, pid;
1396 long addr, data;
1397 {
1398   _M.m2_i1 = pid;
1399   _M.m2_i2 = req;
1400   _M.m2_l1 = addr;
1401   _M.m2_l2 = data;
1402   if (_callx(MM, PTRACE) == -1) return(-1L);
1403   if (_M.m2_l2 == -1) {
1404         errno = 0;
1405         return(-1L);
1406   }
1407   return(_M.m2_l2);
1408 }
1409 _read.c\0c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Î\0#include <lib.h>
1410 #define read    _read
1411 #include <unistd.h>
1412
1413 PUBLIC int read(fd, buffer, nbytes)
1414 int fd;
1415 char *buffer;
1416 unsigned nbytes;
1417 {
1418   return(_callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR));
1419 }
1420 _rename.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 6\ 1#include <lib.h>
1421 #define rename  _rename
1422 #include <stdio.h>
1423
1424 PUBLIC int rename(name, name2)
1425 _CONST char *name, *name2;
1426 {
1427   return(_callm1(FS, RENAME, _len(name), _len(name2), 0,
1428          (char *) name, (char *) name2, /* perhaps callm1 preserves these */
1429          NIL_PTR));
1430 }
1431 _rmdir.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\90\0#include <lib.h>
1432 #define rmdir   _rmdir
1433 #include <unistd.h>
1434
1435 PUBLIC int rmdir(name)
1436 _CONST char *name;
1437 {
1438   return(_callm3(FS, RMDIR, 0, name));
1439 }
1440 _setgid.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ä\0#include <lib.h>
1441 #include <sys/types.h>
1442 #define setgid  _setgid
1443 #include <unistd.h>
1444
1445 PUBLIC int setgid(grp)
1446 gid_t grp;
1447 {
1448   return(_callm1(MM, SETGID, (int)grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1449 }
1450 _setuid.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Â\0#include <lib.h>
1451 #include <sys/types.h>
1452 #define setuid  _setuid
1453 #include <unistd.h>
1454
1455 PUBLIC int setuid(usr)
1456 int usr;
1457 {
1458   return(_callm1(MM, SETUID, (int)usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1459 }
1460 _signal.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ð\ 4#include <lib.h>
1461 #define signal  _signal
1462 #include <signal.h>
1463
1464 extern _PROTOTYPE(void (*_vectab[_NSIG]), (int));       /* array of funcs to catch signals */
1465
1466 /* The definition of signal really should be
1467  *  PUBLIC void (*signal(signr, func))()
1468  * but some compilers refuse to accept this, even though it is correct.
1469  * The only thing to do if you are stuck with such a defective compiler is
1470  * change it to
1471  *  PUBLIC void *signal(signr, func)
1472  * and change ../h/signal.h accordingly.
1473  */
1474
1475 PUBLIC void (*signal(signr, func))()
1476 int signr;                      /* which signal is being set */
1477 _PROTOTYPE( void (*func), (int));       /* pointer to function that catches signal */
1478 {
1479   int r;
1480   _PROTOTYPE( void (*old), (int));
1481
1482   old = _vectab[signr - 1];
1483   _M.m6_i1 = signr;
1484   if (func == SIG_IGN || func == SIG_DFL)
1485         /* Keep old signal catcher until it is completely de-installed */
1486         _M.m6_f1 = func;
1487   else {
1488         /* Use new signal catcher immediately (old one may not exist) */
1489         _vectab[signr - 1] = func;
1490         _M.m6_f1 = _begsig;
1491   }
1492   r = _callx(MM, SIGNAL);
1493   if (r < 0) {
1494         _vectab[signr - 1] = old;/* undo any pre-installation */
1495         return((void (*) ()) r);
1496   }
1497   _vectab[signr - 1] = func;    /* redo any pre-installation */
1498   if (r == 1) return(SIG_IGN);
1499   return(old);
1500 }
1501 _stat.c\0c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ß\0#include <lib.h>
1502 #define stat    _stat
1503 #include <sys/stat.h>
1504
1505 PUBLIC int stat(name, buffer)
1506 _CONST char *name;
1507 struct stat *buffer;
1508 {
1509   return(_callm1(FS, STAT, _len(name), 0, 0,
1510                 (char *)name, (char *)buffer, NIL_PTR));
1511 }
1512 n_stime.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\90\0#include <lib.h>
1513 #define stime _stime
1514 #include <unistd.h>
1515
1516 PUBLIC int stime(top)
1517 long *top;
1518 {
1519   _M.m2_l1 = *top;
1520   return(_callx(FS, STIME));
1521 }
1522 _stty.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¬\0#include <lib.h>
1523 #define stty    _stty
1524 #define ioctl   _ioctl
1525 #include <sgtty.h>
1526
1527 PUBLIC int stty(fd, argp)
1528 int fd;
1529 struct sgttyb *argp;
1530 {
1531   return ioctl(fd, TIOCSETP, argp);
1532 }
1533 _sync.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\90\0#include <lib.h>
1534 #define sync    _sync
1535 #include <unistd.h>
1536
1537 PUBLIC int sync()
1538 {
1539   return(_callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1540 }
1541 syslib.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0
1542 \18#include <lib.h>
1543 #include <minix/com.h>
1544
1545 /*----------------------------------------------------------------------------
1546                 Messages to systask (special calls)
1547 ----------------------------------------------------------------------------*/
1548 #if (CHIP == M68000)
1549 PUBLIC _PROTOTYPE( void sys_xit, (int parent, int proc,
1550                                     phys_clicks *basep, phys_clicks *sizep));
1551 #else
1552 PUBLIC _PROTOTYPE( void sys_xit, (int parent, int proc));
1553 #endif
1554 PUBLIC _PROTOTYPE( void sys_getsp, (int proc, vir_bytes *newsp));
1555 PUBLIC _PROTOTYPE( void sys_sig, (int proc, int sig, void (*sighandler)(int)));
1556 #if (CHIP == M68000)
1557 #ifdef ALCYON_C_BUG_FIXED
1558 PUBLIC _PROTOTYPE( void sys_fork, (int prnt, int chld, int pd, phys_clicks shdw));
1559 #else
1560 PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid, int shadow));
1561 #endif
1562 #else
1563 PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid));
1564 #endif
1565 PUBLIC _PROTOTYPE( void sys_exec, (int proc, char *ptr, int traced));
1566 PUBLIC _PROTOTYPE( void sys_newmap, (int proc, char *ptr));
1567 PUBLIC _PROTOTYPE( void sys_copy, (message *mptr));
1568 PUBLIC _PROTOTYPE( void sys_times, (int proc, time_t ptr[4]));
1569 PUBLIC _PROTOTYPE( void sys_abort, (void));
1570 #if (CHIP == M68000)
1571 PUBLIC _PROTOTYPE( void sys_fresh, (int proc, char *ptr, phys_clicks dc,
1572                                     phys_clicks *basep, phys_clicks *sizep));
1573 #endif
1574 PUBLIC _PROTOTYPE( void sys_kill, (int proc, int sig));
1575 PUBLIC _PROTOTYPE( int sys_trace, (int req, int procnr,
1576                                     long addr, long *data_p));
1577 PUBLIC _PROTOTYPE( void tell_fs, ( int what, int p1, int p2, int p3));
1578
1579
1580 #if (CHIP == M68000)
1581 PUBLIC void sys_xit(parent, proc, basep, sizep)
1582 phys_clicks *basep, *sizep;
1583 #else
1584 PUBLIC void sys_xit(parent, proc)
1585 #endif
1586 int parent;                     /* parent of exiting proc. */
1587 int proc;                       /* which proc has exited */
1588 {
1589 /* A proc has exited.  Tell the kernel. */
1590
1591   _callm1(SYSTASK, SYS_XIT, parent, proc, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1592 #if (CHIP == M68000)
1593   *basep = (phys_clicks) _M.m1_i1;
1594   *sizep = (phys_clicks) _M.m1_i2;
1595 #endif
1596 }
1597
1598
1599 PUBLIC void sys_getsp(proc, newsp)
1600 int proc;                       /* which proc has enabled signals */
1601 vir_bytes *newsp;               /* place to put sp read from kernel */
1602 {
1603 /* Ask the kernel what the sp is. */
1604
1605
1606   _callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1607   *newsp = (vir_bytes) _M.STACK_PTR;
1608 }
1609
1610
1611 PUBLIC void sys_sig(proc, sig, sighandler)
1612 int proc;                       /* which proc has exited */
1613 int sig;                        /* signal number: 1 - 16 */
1614 _PROTOTYPE(void (*sighandler), (int));/* pointer to signal handler in user space */
1615 {
1616 /* A proc has to be signaled.  Tell the kernel. */
1617
1618   _M.m6_i1 = proc;
1619   _M.m6_i2 = sig;
1620   _M.m6_f1 = sighandler;
1621   _callx(SYSTASK, SYS_SIG);
1622 }
1623
1624
1625 #if (CHIP == M68000)
1626 PUBLIC void sys_fork(parent, child, pid, shadow)
1627 #ifdef ALCYON_C_BUG_FIXED
1628 phys_clicks shadow;             /* memory allocated for shadow */
1629 #else
1630 int shadow;
1631 #endif
1632 #else
1633 PUBLIC void sys_fork(parent, child, pid)
1634 #endif
1635 int parent;                     /* proc doing the fork */
1636 int child;                      /* which proc has been created by the fork */
1637 int pid;                        /* process id assigned by MM */
1638 {
1639 /* A proc has forked.  Tell the kernel. */
1640
1641 #if (CHIP == M68000)
1642   _callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *) shadow, NIL_PTR, NIL_PTR);
1643 #else
1644   _callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR);
1645 #endif
1646 }
1647
1648
1649 PUBLIC void sys_exec(proc, ptr, traced)
1650 int proc;                       /* proc that did exec */
1651 char *ptr;                      /* new stack pointer */
1652 int traced;                     /* is tracing enabled? */
1653 {
1654 /* A proc has exec'd.  Tell the kernel. */
1655
1656   _callm1(SYSTASK, SYS_EXEC, proc, traced, 0, ptr, NIL_PTR, NIL_PTR);
1657 }
1658
1659 PUBLIC void sys_newmap(proc, ptr)
1660 int proc;                       /* proc whose map is to be changed */
1661 char *ptr;                      /* pointer to new map */
1662 {
1663 /* A proc has been assigned a new memory map.  Tell the kernel. */
1664
1665
1666   _callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
1667 }
1668
1669 PUBLIC void sys_copy(mptr)
1670 message *mptr;                  /* pointer to message */
1671 {
1672 /* A proc wants to use local copy. */
1673
1674   /* Make this routine better.  Also check other guys' error handling
1675    * -DEBUG */
1676   mptr->m_type = SYS_COPY;
1677   if (_sendrec(SYSTASK, mptr) != 0) panic("sys_copy can't send", NO_NUM);
1678 }
1679
1680 PUBLIC void sys_times(proc, ptr)
1681 int proc;                       /* proc whose times are needed */
1682 time_t ptr[4];          /* pointer to time buffer */
1683 {
1684 /* Fetch the accounting info for a proc. */
1685
1686   _callm1(SYSTASK, SYS_TIMES, proc, 0, 0, (char *)ptr, NIL_PTR, NIL_PTR);
1687   ptr[0] = _M.USER_TIME;
1688   ptr[1] = _M.SYSTEM_TIME;
1689   ptr[2] = _M.CHILD_UTIME;
1690   ptr[3] = _M.CHILD_STIME;
1691 }
1692
1693
1694 PUBLIC void sys_abort()
1695 {
1696 /* Something awful has happened.  Abandon ship. */
1697
1698   _callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1699 }
1700
1701 #if (CHIP == M68000)
1702 PUBLIC void sys_fresh(proc, ptr, dc, basep, sizep)
1703 int proc;                       /* proc whose map is to be changed */
1704 char *ptr;                      /* pointer to new map */
1705 phys_clicks dc;                 /* size of initialized data */
1706 phys_clicks *basep, *sizep;     /* base and size for free_mem() */
1707 {
1708 /* Create a fresh process image for exec().  Tell the kernel. */
1709
1710   _callm1(SYSTASK, SYS_FRESH, proc, (int) dc, 0, ptr, NIL_PTR, NIL_PTR);
1711   *basep = (phys_clicks) _M.m1_i1;
1712   *sizep = (phys_clicks) _M.m1_i2;
1713 }
1714
1715 #endif
1716
1717
1718 PUBLIC void sys_kill(proc, sig)
1719 int proc;                       /* which proc has exited */
1720 int sig;                        /* signal number: 1 - 16 */
1721 {
1722 /* A proc has to be signaled via MM.  Tell the kernel. */
1723
1724   _M.m6_i1 = proc;
1725   _M.m6_i2 = sig;
1726   _callx(SYSTASK, SYS_KILL);
1727 }
1728
1729 PUBLIC int sys_trace(req, procnr, addr, data_p)
1730 int req, procnr;
1731 long addr, *data_p;
1732 {
1733   int r;
1734
1735   _M.m2_i1 = procnr;
1736   _M.m2_i2 = req;
1737   _M.m2_l1 = addr;
1738   if (data_p) _M.m2_l2 = *data_p;
1739   r = _callx(SYSTASK, SYS_TRACE);
1740   if (data_p) *data_p = _M.m2_l2;
1741   return(r);
1742 }
1743
1744 PUBLIC void tell_fs(what, p1, p2, p3)
1745 int what, p1, p2, p3;
1746 {
1747 /* This routine is only used by MM to inform FS of certain events:
1748  *      tell_fs(CHDIR, slot, dir, 0)
1749  *      tell_fs(EXEC, proc, 0, 0)
1750  *      tell_fs(EXIT, proc, 0, 0)
1751  *      tell_fs(FORK, parent, child, pid)
1752  *      tell_fs(SETGID, proc, realgid, effgid)
1753  *      tell_fs(SETUID, proc, realuid, effuid)
1754  *      tell_fs(SYNC, 0, 0, 0)
1755  *      tell_fs(UNPAUSE, proc, signr, 0)
1756  *      tell_fs(SETPGRP, proc, 0, 0)
1757  */
1758   _callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR);
1759 }
1760 _time.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\00\ 1#include <lib.h>
1761 #define time    _time
1762 #include <time.h>
1763
1764 PUBLIC long time(tp)
1765 long *tp;
1766 {
1767   int k;
1768   long l;
1769   k = _callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1770   if (_M.m_type < 0 || k != 0) {
1771         errno = -_M.m_type;
1772         return(-1L);
1773   }
1774   l = _M.m2_l1;
1775   if (tp != (long *) 0) *tp = l;
1776   return(l);
1777 }
1778 _times.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0m\ 1#include <lib.h>
1779 #include <sys/types.h>
1780 #include <time.h>
1781 #define times   _times
1782 #include <sys/times.h>
1783
1784 PUBLIC clock_t times(buf)
1785 struct tms *buf;
1786 {
1787   clock_t k;
1788   k = (clock_t)_callm1(FS, TIMES, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1789   buf->tms_utime = _M.m4_l1;
1790   buf->tms_stime = _M.m4_l2;
1791   buf->tms_cutime = _M.m4_l3;
1792   buf->tms_cstime = _M.m4_l4;
1793   return(k);
1794 }
1795 e_umask.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ý\0#include <lib.h>
1796 #include <sys/types.h>
1797 #define umask   _umask
1798 #include <sys/stat.h>
1799
1800 PUBLIC mode_t umask(complmode)
1801 int complmode;
1802 {
1803   return((mode_t)_callm1(FS, UMASK, (int)complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1804 }
1805  _umount.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\94\0#include <lib.h>
1806 #define umount  _umount
1807 #include <unistd.h>
1808
1809 PUBLIC int umount(name)
1810 _CONST char *name;
1811 {
1812   return(_callm3(FS, UMOUNT, 0, name));
1813 }
1814 _unlink.c\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\94\0#include <lib.h>
1815 #define unlink  _unlink
1816 #include <unistd.h>
1817
1818 PUBLIC int unlink(name)
1819 _CONST char *name;
1820 {
1821   return(_callm3(FS, UNLINK, 0, name));
1822 }
1823 _utime.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\e\ 2/* _utime(2) for POSIX                Authors: Terrence W. Holm & Edwin L. Froese */
1824
1825 #include <lib.h>
1826 #define time    _time
1827 #include <time.h>
1828 #define utime   _utime
1829 #include <utime.h>
1830
1831 long time();
1832
1833 PUBLIC int utime(name, timp)
1834 char *name;
1835 struct utimbuf *timp;
1836 {
1837   long current_time;
1838
1839   if (timp == (struct utimbuf *)NULL) {
1840         current_time = time((long *)NULL);
1841         _M.m2_l1 = current_time;
1842         _M.m2_l2 = current_time;
1843   } else {
1844         _M.m2_l1 = timp->actime;
1845         _M.m2_l2 = timp->modtime;
1846   }
1847
1848   _M.m2_i1 = _len(name);
1849   _M.m2_p1 = name;
1850   return _callx(FS, UTIME);
1851 }
1852 p_wait.c\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0è\0#include <lib.h>
1853 #define wait    _wait
1854 #include <sys/wait.h>
1855
1856 PUBLIC int wait(status)
1857 int *status;
1858 {
1859   int k;
1860   k = _callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1861   if (k >= 0 && status != 0) *status = _M.m2_i1;
1862   return(k);
1863 }
1864 _write.c\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ò\0#include <lib.h>
1865 #define write   _write
1866 #include <unistd.h>
1867
1868 PUBLIC int write(fd, buffer, nbytes)
1869 int fd;
1870 char *buffer;
1871 unsigned nbytes;
1872 {
1873   return(_callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR));
1874 }
1875 stbrksz.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\80\0.define       __brksize
1876 .extern endbss, __brksize
1877 .sect   .text
1878 .sect   .rom
1879 .sect   .data
1880 .sect   .bss
1881
1882 .sect   .data
1883 __brksize:
1884 .data4  endbss
1885 stcatch.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ù\ 2#define FREEREGS d0-d1/a0-a1
1886
1887 .define __begsig
1888 .extern __vectab
1889 .extern __M
1890 .sect   .text
1891 .sect   .rom
1892 .sect   .data
1893 .sect   .bss
1894
1895
1896 mtype = 2                       ! M+mtype = &M.m_type
1897 .sect   .text
1898 __begsig:
1899         movem.l FREEREGS,-(sp)
1900         clr.l   d0
1901 #ifdef ALCYON
1902         move.w  24(sp),d0       ! d0 = signal number
1903 #else
1904         move.w  16(sp),d0       ! d0 = signal number
1905 #endif
1906         move.w  __M+mtype,-(sp) ! push status of last system call
1907         move.w  d0,-(sp)        ! func called with signal number as arg
1908         asl.l   #2,d0           ! pointers are four bytes on 68000
1909         move.l  #__vectab,a0
1910         move.l  -4(a0,d0),a0    ! a0 = address of routine to call
1911         jsr     (a0)
1912 back:
1913         add.l   #2,sp           ! get signal number off stack
1914         move.w  (sp)+,__M+mtype ! restore status of previous system call
1915         movem.l (sp)+,FREEREGS
1916         add.l   #2,sp           ! remove signal number from stack
1917         rtr
1918 tstsndrec.s\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Á\ 1.define      _send
1919 .define _receive
1920 .define _sendrec
1921 .sect   .text
1922 .sect   .rom
1923 .sect   .data
1924 .sect   .bss
1925 ! =====================================================================
1926 !                           send and receive                          =
1927 ! =====================================================================
1928 ! send(), receive(), sendrec() destroy d0, d1, and a0.
1929
1930 .sect   .text
1931
1932 _send:  jmp __send
1933
1934 _receive:
1935         jmp __receive
1936
1937 _sendrec:
1938         jmp __sendrec
1939  _stsndrec.s\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0û\ 2.define      __send
1940 .define __receive
1941 .define __sendrec
1942 .sect   .text
1943 .sect   .rom
1944 .sect   .data
1945 .sect   .bss
1946 ! =====================================================================
1947 !                           send and receive                          =
1948 ! =====================================================================
1949 ! send(), receive(), sendrec() destroy d0, d1, and a0.
1950
1951 ! See ../h/com.h for C definitions
1952 SEND    = 1
1953 RECEIVE = 2
1954 BOTH    = 3
1955
1956 .sect   .text
1957
1958 __send: move.w  #SEND,d0        ! send(dest, ptr)
1959         bra     L0
1960
1961 __receive:
1962         move.w  #RECEIVE,d0     ! receive(src, ptr)
1963         bra     L0
1964
1965 __sendrec:
1966         move.w  #BOTH,d0        ! sendrec(srcdest, ptr)
1967 L0:                             ! d0 = SEND/RECEIVE/BOTH
1968         move.w  4(sp),d1        ! d1 = dest-src
1969         move.l  6(sp),a0        ! a0 = message pointer
1970         trap    #0              ! trap to the kernel
1971         rts                     ! return
1972  vectab.c\0.s\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\\ 1/* When the signal call is made, a pointer to the function to be called
1973  * is stored in this table.  When the interrupt comes in from the kernel,
1974  * the function is called within the user address space using _vectab[].
1975  */
1976
1977 #include <lib.h>
1978 #include <signal.h>
1979
1980 /* array of functions to catch signals */
1981 _PROTOTYPE( void (*_vectab[_NSIG]), (int));
1982 errno.c\0\0.s\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0l\0#include <lib.h>
1983 /* errno.c - declare variable errno             Author: F. Meulenbroeks */
1984
1985 int errno = 0;