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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
296 nexit.c
\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Y
\0#include <lib.h>
298 PUBLIC int exit(status)
304 _cleanup.c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\ f\0_cleanup()
307 >_exit.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\8e\0#include <lib.h>
310 PUBLIC void _exit(status)
313 _callm1(MM, EXIT, status, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
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
319 PUBLIC int access(name, mode)
323 return(_callm3(FS, ACCESS, mode, name));
325 _alarm.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0º
\0#include <lib.h>
329 PUBLIC unsigned int alarm(sec)
332 return(_callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
334 _brk.c
\0c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\02
\ 2#include <lib.h>
339 extern char *_brksize;
341 PUBLIC char *brk(addr)
344 if (_callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR) == 0) {
353 PUBLIC char *sbrk(incr)
356 char *newsize, *oldsize;
359 newsize = _brksize + incr;
360 if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize)
362 if (_brk(newsize) == 0)
367 call.c
\0c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\14\b#include <lib.h>
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 */
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.
388 return _callx(proc, syscallnr);
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 */
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.
407 _M.m3_p1 = (char *) name;
409 if (k <= M3_STRING) while (k--)
411 return _callx(proc, syscallnr);
415 PUBLIC int _callx(proc, syscallnr)
416 int proc; /* FS or MM */
417 int syscallnr; /* which system call */
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).
424 _M.m_type = syscallnr;
425 k = _sendrec(proc, &_M);
426 if (k != 0) return(k); /* _send() itself failed */
436 _CONST register char *s; /* character string whose length is needed */
438 /* Return the length of a character string, including the 0 at the end. */
442 while (*s++ != 0) k++;
443 return(k + 1); /* return length including the 0-byte at end */
445 _chdir.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\89\0#include <lib.h>
449 PUBLIC int chdir(name)
452 return(_callm3(FS, CHDIR, 0, name));
454 w_chmod.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0¨
\0#include <lib.h>
456 #include <sys/stat.h>
458 PUBLIC int chmod(name, mode)
462 return(_callm3(FS, CHMOD, mode, name));
464 _chown.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ì
\0#include <lib.h>
468 PUBLIC int chown(name, owner, grp)
472 return(_callm1(FS, CHOWN, _len(name), owner, grp, name, NIL_PTR, NIL_PTR));
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
478 PUBLIC int chroot(name)
481 return(_callm3(FS, CHROOT, 0, name));
483 _close.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\9f\0#include <lib.h>
490 return(_callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
492 m_creat.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0¥
\0#include <lib.h>
496 PUBLIC int creat(name, mode)
500 return(_callm3(FS, CREAT, mode, name));
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>
510 return(fcntl(fd, F_DUPFD, 0));
512 _dup2.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0.
\ 2#include <lib.h>
519 PUBLIC int dup2(fd, fd2)
522 /* The behavior of dup2 is defined by POSIX in 6.2.1.2 as almost, but not
523 * quite the same as fcntl.
526 if (fd2 < 0 || fd2 > OPEN_MAX) {
531 /* Check to see if fildes is valid. */
532 if (fcntl(fd, F_GETFL) < 0) {
533 /* fd is not valid. */
537 if (fd == fd2) return(fd2);
539 return(fcntl(fd, F_DUPFD, fd2));
542 _exec.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ã
\ f#include <lib.h>
545 #define execle _execle
547 #define execve _execve
549 extern char **environ; /* environment pointer */
551 #define PTRSIZE (sizeof(char *))
552 _PROTOTYPE( char *_sbrk, (int _incr) );
557 PUBLIC int execl(char *name, ...)
563 retval = execve(name, (char **)ap, environ);
568 PUBLIC int execl(name, arg0)
572 return(execve(name, &arg0, environ));
577 PUBLIC int execle(char *name, ...)
585 p = va_arg(ap, char *);
587 p = (char *)va_arg(ap, char **);
590 retval = execve(name, (char **)ap, (char **) p);
595 PUBLIC int execle(name, argv)
600 while (*p++) /* null statement */
602 return(execve(name, &argv, (char **) *p));
606 PUBLIC int execv(name, argv)
610 return(execve(name, argv, environ));
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 */
618 register char **argtop;
619 register char **envtop;
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)));
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 */
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.
639 int i, stackbytes, npointers, overflow, temp;
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 */
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)
650 for (i = PTRSIZE; i != 0; i--) {
651 temp = stackbytes + npointers;
652 if (temp < stackbytes) overflow = TRUE;
655 for (i = 0, ap = argv; i < nargs; i++) {
656 temp = stackbytes + _len(*ap++);
657 if (temp < stackbytes) overflow = TRUE;
660 for (i = 0, ap = envp; i < nenvps; i++) {
661 temp = stackbytes + _len(*ap++);
662 if (temp < stackbytes) overflow = TRUE;
665 temp = stackbytes + PTRSIZE - 1;
666 if (temp < stackbytes) overflow = TRUE;
667 stackbytes = (temp / PTRSIZE) * PTRSIZE;
669 /* Check for overflow before committing sbrk. */
670 if (overflow || stackbytes > ARG_MAX) {
675 /* Allocate the stack. */
676 stack = _sbrk(stackbytes);
677 if (stack == (char *) -1) {
682 /* Prepare the stack vector and argc. */
683 ap = (char **) stack;
684 hp = &stack[npointers * PTRSIZE];
685 *ap++ = (char *) nargs;
687 /* Prepare the argument pointers and strings. */
688 for (i = 0; i < nargs; i++) {
689 *ap++ = (char *) (hp - stack);
691 while ((*hp++ = *p++) != 0)
694 *ap++ = (char *) NULL;
696 /* Prepare the environment pointers and strings. */
697 for (i = 0; i < nenvps; i++) {
698 *ap++ = (char *) (hp - stack);
700 while ((*hp++ = *p++) != 0)
703 *ap++ = (char *) NULL;
705 /* Do the real work. */
706 temp = _callm1(MM, EXEC, _len(path), stackbytes, 0, path, stack, NIL_PTR);
710 \0_execn.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0´
\ 1#include <lib.h>
712 #define PTRSIZE sizeof(char *)
713 _PROTOTYPE( int _execn, (char * name));
715 PUBLIC int _execn(name)
716 char *name; /* pointer to file to be exec'd */
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.
722 PRIVATE char stack[3 * PTRSIZE];
724 return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR));
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.
732 #include <sys/types.h>
735 #define MAXSTK 256 /* maximum EXEC stack size */
736 #define PTRSIZE sizeof(char *)
738 _PROTOTYPE(int _execn,(char *name));
739 _PROTOTYPE(int _execnl,(char *name, char *arg0));
740 PRIVATE _PROTOTYPE(int _nexec,(char *name, char *argv[]));
742 PUBLIC int _execn(name)
743 char *name; /* pointer to file to be exec'd */
745 /* This funcion uses no arguments at all. */
746 PRIVATE char stack[3 * PTRSIZE];
748 return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR));
752 PUBLIC int _execnl(name, arg0)
756 /* This function resembles execl(2). */
758 return(_nexec(name, &arg0));
761 PRIVATE int _nexec(name, argv)
762 char *name; /* pointer to name of file to be executed */
763 char *argv[]; /* pointer to argument array */
766 char **argorg, *hp, **ap, *p;
767 int i, nargs, stackbytes, offset;
769 /* Count the argument pointers. */
772 while (*argorg++ != NIL_PTR) nargs++;
774 /* Prepare to set up the initial stack. */
775 hp = &stack[(nargs + 3) * PTRSIZE];
776 if (hp + nargs >= &stack[MAXSTK]) {
780 ap = (char **) stack;
781 *ap++ = (char *) nargs;
783 /* Prepare the argument pointers and strings. */
784 for (i = 0; i < nargs; i++) {
786 *ap++ = (char *) offset;
790 if (hp >= &stack[MAXSTK]) {
799 stackbytes = (((int) (hp - stack) + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
800 return(_callm1(MM, EXEC, _len(name), stackbytes, 0, name, stack, NIL_PTR));
802 m_fcntl.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\ 2\ 4#include <lib.h>
810 PUBLIC int fcntl(int fd, int cmd, ...)
814 PUBLIC int fcntl(va_alist)
821 int int3; /* third integer parameter for callm1 */
822 char *ptr1; /* first pointer parameter for callm1 */
828 fd = va_arg(ap, int);
829 cmd = va_arg(ap, int);
832 /* Set up for the sensible case where there is no variable parameter. This
833 * covers F_GETFD, F_GETFL and invalid commands.
838 /* Adjust for the stupid cases. */
843 int3 = va_arg(ap, int);
848 ptr1 = (char *) va_arg(ap, struct flock *);
852 /* Clean up and make the system call. */
854 return(_callm1(FS, FCNTL, fd, cmd, int3, ptr1, NIL_PTR, NIL_PTR));
856 _fork.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\90\0#include <lib.h>
862 return(_callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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 */
868 #include <sys/types.h>
870 #include <sys/stat.h>
874 PUBLIC long fpathconf(fd, name)
875 int fd; /* file descriptor being interrogated */
876 int name; /* property being inspected */
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>.
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 */
893 return( (long) LINK_MAX);
896 return( (long) MAX_CANON);
899 return( (long) MAX_INPUT);
902 return( (long) NAME_MAX);
905 return( (long) PATH_MAX);
908 return( (long) PIPE_BUF);
910 case _PC_CHOWN_RESTRICTED:
911 return( (long) 1); /* MINIX defines CHOWN_RESTRICTED */
913 case _PC_NO_TRUNC: /* MINIX does not define NO_TRUNC */
916 case _PC_VDISABLE: /* MINIX defines VDISABLE */
917 return( (long) _POSIX_VDISABLE);
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>
927 #include <sys/stat.h>
929 PUBLIC int fstat(fd, buffer)
933 return(_callm1(FS, FSTAT, fd, 0, 0, (char *)buffer, NIL_PTR, NIL_PTR));
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 */
937 /* Directly derived from Adri Koppes' pwd(1).
938 * Modified by Andy Tanenbaum for POSIX (29 Oct. 1989)
942 #include <sys/stat.h>
946 #define getcwd _getcwd
948 #define DIRECT_SIZE (sizeof (struct direct))
950 PRIVATE _PROTOTYPE(void go_back, (char *path) );
952 char *getcwd(buffer, size)
955 /* Get current working directory. */
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;
962 if (buffer == (char *)NULL || size <= 0) {
964 return((char *)NULL);
968 /* Get the inode for the current directory */
969 if (stat(".", ¤t) == -1) return((char *)NULL);
970 if ((current.st_mode & S_IFMT) != S_IFDIR) return((char *)NULL);
972 /* Run backwards up the directory tree, grabbing dir names on the way. */
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;
983 /* At the root, "." is the same as ".." */
984 if (same_device && current.st_ino == parent.st_ino) break;
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 */
991 if (current.st_ino == d.d_ino) found = 1;
994 strncat(temp_name, d.d_name, NAME_MAX);
995 if (stat(temp_name, &dir_entry) == -1) {
998 return((char *)NULL);
1000 if (current.st_dev == dir_entry.st_dev &&
1001 current.st_ino == dir_entry.st_ino)
1009 return((char *)NULL);
1011 if (strlen(path) + NAME_MAX + 1 > PATH_MAX) {
1014 return((char *)NULL);
1017 strncat(path, d.d_name, NAME_MAX);
1018 current.st_dev = parent.st_dev;
1019 current.st_ino = parent.st_ino;
1022 /* Copy the reversed path name into <buffer> */
1023 if (strlen(path) + 1 > size) {
1026 return((char *)NULL);
1028 if (strlen(path) == 0) {
1029 strcpy(buffer, "/");
1033 while ((r = strrchr(path, '/')) != (char *)NULL) {
1037 return(chdir(buffer) ? (char *)NULL : buffer);
1040 PRIVATE void go_back(path)
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
1050 while ((r = strrchr(path, '/')) != (char *)NULL) {
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
1060 PUBLIC gid_t getegid()
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);
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
1072 PUBLIC uid_t geteuid()
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);
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
1084 PUBLIC gid_t getgid()
1086 return((gid_t)_callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1094 return(_callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1096 _getppid.c
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Í
\0#include <lib.h>
1097 #define getppid _getppid
1100 PUBLIC int getppid()
1104 p = _callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1105 if (p < 0) return(p);
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
1113 PUBLIC uid_t getuid()
1115 return((uid_t)_callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1117 _gtty.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0
\0#include <lib.h>
1119 #define ioctl _ioctl
1122 PUBLIC int gtty(fd, argp)
1124 struct sgttyb *argp;
1126 return(ioctl(fd, TIOCGETP, argp));
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
1133 PUBLIC int ioctl(fd, request, argp)
1136 struct sgttyb *argp;
1139 long erase, kill, intr, quit, xon, xoff, eof, brk, speed;
1140 struct tchars *argt;
1142 _M.TTY_REQUEST = request;
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);
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);
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;
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;
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.
1194 _M.TTY_FLAGS = (int /* kludge */) argp;
1195 return _callx(FS, IOCTL);
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
1201 _M.ADDRESS = (char *)argp;
1202 return _callx(FS, IOCTL);
1205 (_kill.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ö
\0#include <lib.h>
1209 PUBLIC int kill(proc, sig)
1210 int proc; /* which process is to be sent the signal */
1211 int sig; /* signal number */
1213 return(_callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1215 _link.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ÿ
\0#include <lib.h>
1219 PUBLIC int link(name, name2)
1220 _CONST char *name, *name2;
1222 return(_callm1(FS, LINK, _len(name), _len(name2), 0,
1223 (char *) name, (char *) name2, /* perhaps callm1 preserves these */
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
1231 PUBLIC off_t lseek(fd, offset, whence)
1240 k = _callx(FS, LSEEK);
1241 if (k != 0) return((off_t) k); /* _send() itself failed */
1242 return((off_t)_M.m2_l1);
1244 message.c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0l
\0#include <lib.h>
1246 /* Some compilers require an initializer to force storage allocation */
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>
1252 PUBLIC int mkdir(name, mode)
1256 return(_callm1(FS, MKDIR, _len(name), mode, 0, (char *)name, NIL_PTR, NIL_PTR));
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>
1263 PUBLIC int mkfifo(name, mode)
1267 mode = (mode & 0777) | S_IFIFO;
1268 return(_callm1(FS, MKNOD, _len(name), (int)mode, 0,
1269 (char *)name, NIL_PTR, NIL_PTR));
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
1275 PUBLIC int mknod(name, mode, addr)
1279 return(_callm1(FS, MKNOD, _len(name), mode, addr,
1280 (char *) name, (char *) 0, NIL_PTR));
1282 _mknod4.c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0
1284 #define mknod4 _mknod4
1287 PUBLIC int mknod4(name, mode, addr, size)
1292 return(_callm1(FS, MKNOD, _len(name), mode, addr,
1293 (char *) name, (char *) size, NIL_PTR));
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
1299 PUBLIC int mount(special, name, rwflag)
1300 char *name, *special;
1303 return(_callm1(FS, MOUNT, _len(special), _len(name), rwflag, special, name, NIL_PTR));
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>
1313 PUBLIC int open(const char *name, int flags, ...)
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);
1326 return _callm3(FS, OPEN, flags, name);
1329 PUBLIC int open(name, flags, mode)
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));
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 */
1342 #include <sys/types.h>
1346 #define close _close
1348 PUBLIC long pathconf(path, name)
1349 char *path; /* name of file being interrogated */
1350 int name; /* property being inspected */
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>.
1361 if ( (fd = open(path, O_RDONLY)) < 0) return(-1L);
1362 val = fpathconf(fd, name);
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
1372 return(_callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1374 _pipe.c
\0\0c
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\ 1\ 1#include <lib.h>
1378 PUBLIC int pipe(fild)
1382 k = _callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
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
1394 PUBLIC long ptrace(req, pid, addr, data)
1402 if (_callx(MM, PTRACE) == -1) return(-1L);
1403 if (_M.m2_l2 == -1) {
1409 _read.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Î
\0#include <lib.h>
1413 PUBLIC int read(fd, buffer, nbytes)
1418 return(_callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR));
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
1424 PUBLIC int rename(name, name2)
1425 _CONST char *name, *name2;
1427 return(_callm1(FS, RENAME, _len(name), _len(name2), 0,
1428 (char *) name, (char *) name2, /* perhaps callm1 preserves these */
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
1435 PUBLIC int rmdir(name)
1438 return(_callm3(FS, RMDIR, 0, name));
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
1445 PUBLIC int setgid(grp)
1448 return(_callm1(MM, SETGID, (int)grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1455 PUBLIC int setuid(usr)
1458 return(_callm1(MM, SETUID, (int)usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1464 extern _PROTOTYPE(void (*_vectab[_NSIG]), (int)); /* array of funcs to catch signals */
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
1471 * PUBLIC void *signal(signr, func)
1472 * and change ../h/signal.h accordingly.
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 */
1480 _PROTOTYPE( void (*old), (int));
1482 old = _vectab[signr - 1];
1484 if (func == SIG_IGN || func == SIG_DFL)
1485 /* Keep old signal catcher until it is completely de-installed */
1488 /* Use new signal catcher immediately (old one may not exist) */
1489 _vectab[signr - 1] = func;
1492 r = _callx(MM, SIGNAL);
1494 _vectab[signr - 1] = old;/* undo any pre-installation */
1495 return((void (*) ()) r);
1497 _vectab[signr - 1] = func; /* redo any pre-installation */
1498 if (r == 1) return(SIG_IGN);
1501 _stat.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ß
\0#include <lib.h>
1503 #include <sys/stat.h>
1505 PUBLIC int stat(name, buffer)
1507 struct stat *buffer;
1509 return(_callm1(FS, STAT, _len(name), 0, 0,
1510 (char *)name, (char *)buffer, NIL_PTR));
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
1516 PUBLIC int stime(top)
1520 return(_callx(FS, STIME));
1522 _stty.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0¬
\0#include <lib.h>
1524 #define ioctl _ioctl
1527 PUBLIC int stty(fd, argp)
1529 struct sgttyb *argp;
1531 return ioctl(fd, TIOCSETP, argp);
1533 _sync.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\90\0#include <lib.h>
1539 return(_callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1541 syslib.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0
1543 #include <minix/com.h>
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));
1552 PUBLIC _PROTOTYPE( void sys_xit, (int parent, int proc));
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));
1560 PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid, int shadow));
1563 PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid));
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));
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));
1580 #if (CHIP == M68000)
1581 PUBLIC void sys_xit(parent, proc, basep, sizep)
1582 phys_clicks *basep, *sizep;
1584 PUBLIC void sys_xit(parent, proc)
1586 int parent; /* parent of exiting proc. */
1587 int proc; /* which proc has exited */
1589 /* A proc has exited. Tell the kernel. */
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;
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 */
1603 /* Ask the kernel what the sp is. */
1606 _callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1607 *newsp = (vir_bytes) _M.STACK_PTR;
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 */
1616 /* A proc has to be signaled. Tell the kernel. */
1620 _M.m6_f1 = sighandler;
1621 _callx(SYSTASK, SYS_SIG);
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 */
1633 PUBLIC void sys_fork(parent, child, pid)
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 */
1639 /* A proc has forked. Tell the kernel. */
1641 #if (CHIP == M68000)
1642 _callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *) shadow, NIL_PTR, NIL_PTR);
1644 _callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR);
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? */
1654 /* A proc has exec'd. Tell the kernel. */
1656 _callm1(SYSTASK, SYS_EXEC, proc, traced, 0, ptr, NIL_PTR, NIL_PTR);
1659 PUBLIC void sys_newmap(proc, ptr)
1660 int proc; /* proc whose map is to be changed */
1661 char *ptr; /* pointer to new map */
1663 /* A proc has been assigned a new memory map. Tell the kernel. */
1666 _callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
1669 PUBLIC void sys_copy(mptr)
1670 message *mptr; /* pointer to message */
1672 /* A proc wants to use local copy. */
1674 /* Make this routine better. Also check other guys' error handling
1676 mptr->m_type = SYS_COPY;
1677 if (_sendrec(SYSTASK, mptr) != 0) panic("sys_copy can't send", NO_NUM);
1680 PUBLIC void sys_times(proc, ptr)
1681 int proc; /* proc whose times are needed */
1682 time_t ptr[4]; /* pointer to time buffer */
1684 /* Fetch the accounting info for a proc. */
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;
1694 PUBLIC void sys_abort()
1696 /* Something awful has happened. Abandon ship. */
1698 _callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
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() */
1708 /* Create a fresh process image for exec(). Tell the kernel. */
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;
1718 PUBLIC void sys_kill(proc, sig)
1719 int proc; /* which proc has exited */
1720 int sig; /* signal number: 1 - 16 */
1722 /* A proc has to be signaled via MM. Tell the kernel. */
1726 _callx(SYSTASK, SYS_KILL);
1729 PUBLIC int sys_trace(req, procnr, addr, data_p)
1738 if (data_p) _M.m2_l2 = *data_p;
1739 r = _callx(SYSTASK, SYS_TRACE);
1740 if (data_p) *data_p = _M.m2_l2;
1744 PUBLIC void tell_fs(what, p1, p2, p3)
1745 int what, p1, p2, p3;
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)
1758 _callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR);
1760 _time.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\00
\ 1#include <lib.h>
1764 PUBLIC long time(tp)
1769 k = _callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1770 if (_M.m_type < 0 || k != 0) {
1775 if (tp != (long *) 0) *tp = l;
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>
1781 #define times _times
1782 #include <sys/times.h>
1784 PUBLIC clock_t times(buf)
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;
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>
1800 PUBLIC mode_t umask(complmode)
1803 return((mode_t)_callm1(FS, UMASK, (int)complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1809 PUBLIC int umount(name)
1812 return(_callm3(FS, UMOUNT, 0, name));
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
1818 PUBLIC int unlink(name)
1821 return(_callm3(FS, UNLINK, 0, name));
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 */
1828 #define utime _utime
1833 PUBLIC int utime(name, timp)
1835 struct utimbuf *timp;
1839 if (timp == (struct utimbuf *)NULL) {
1840 current_time = time((long *)NULL);
1841 _M.m2_l1 = current_time;
1842 _M.m2_l2 = current_time;
1844 _M.m2_l1 = timp->actime;
1845 _M.m2_l2 = timp->modtime;
1848 _M.m2_i1 = _len(name);
1850 return _callx(FS, UTIME);
1852 p_wait.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0è
\0#include <lib.h>
1854 #include <sys/wait.h>
1856 PUBLIC int wait(status)
1860 k = _callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1861 if (k >= 0 && status != 0) *status = _M.m2_i1;
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
1868 PUBLIC int write(fd, buffer, nbytes)
1873 return(_callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR));
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
1885 stcatch.s
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ù
\ 2#define FREEREGS d0-d1/a0-a1
1896 mtype = 2 ! M+mtype = &M.m_type
1899 movem.l FREEREGS,-(sp)
1902 move.w 24(sp),d0 ! d0 = signal number
1904 move.w 16(sp),d0 ! d0 = signal number
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
1910 move.l -4(a0,d0),a0 ! a0 = address of routine to call
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
1918 tstsndrec.s
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Á
\ 1.define _send
1925 ! =====================================================================
1926 ! send and receive =
1927 ! =====================================================================
1928 ! send(), receive(), sendrec() destroy d0, d1, and a0.
1939 _stsndrec.s
\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0û
\ 2.define __send
1946 ! =====================================================================
1947 ! send and receive =
1948 ! =====================================================================
1949 ! send(), receive(), sendrec() destroy d0, d1, and a0.
1951 ! See ../h/com.h for C definitions
1958 __send: move.w #SEND,d0 ! send(dest, ptr)
1962 move.w #RECEIVE,d0 ! receive(src, ptr)
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
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[].
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 */