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