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 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
301 pexit.c
\0.s
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Y
\0#include <lib.h>
303 PUBLIC int exit(status)
309 jcleanup.c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\ f\0_cleanup()
312 >_exit.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\8e\0#include <lib.h>
315 PUBLIC void _exit(status)
318 _callm1(MM, EXIT, status, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
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
324 PUBLIC int access(name, mode)
328 return(_callm3(FS, ACCESS, mode, name));
330 _alarm.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0º
\0#include <lib.h>
334 PUBLIC unsigned int alarm(sec)
337 return(_callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
339 _brk.c
\0c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\02
\ 2#include <lib.h>
344 extern char *_brksize;
346 PUBLIC char *brk(addr)
349 if (_callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR) == 0) {
358 PUBLIC char *sbrk(incr)
361 char *newsize, *oldsize;
364 newsize = _brksize + incr;
365 if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize)
367 if (_brk(newsize) == 0)
372 call.c
\0c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\14\b#include <lib.h>
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 */
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.
393 return _callx(proc, syscallnr);
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 */
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.
412 _M.m3_p1 = (char *) name;
414 if (k <= M3_STRING) while (k--)
416 return _callx(proc, syscallnr);
420 PUBLIC int _callx(proc, syscallnr)
421 int proc; /* FS or MM */
422 int syscallnr; /* which system call */
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).
429 _M.m_type = syscallnr;
430 k = _sendrec(proc, &_M);
431 if (k != 0) return(k); /* _send() itself failed */
441 _CONST register char *s; /* character string whose length is needed */
443 /* Return the length of a character string, including the 0 at the end. */
447 while (*s++ != 0) k++;
448 return(k + 1); /* return length including the 0-byte at end */
450 _chdir.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\89\0#include <lib.h>
454 PUBLIC int chdir(name)
457 return(_callm3(FS, CHDIR, 0, name));
459 w_chmod.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0¨
\0#include <lib.h>
461 #include <sys/stat.h>
463 PUBLIC int chmod(name, mode)
467 return(_callm3(FS, CHMOD, mode, name));
469 _chown.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ì
\0#include <lib.h>
473 PUBLIC int chown(name, owner, grp)
477 return(_callm1(FS, CHOWN, _len(name), owner, grp, name, NIL_PTR, NIL_PTR));
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
483 PUBLIC int chroot(name)
486 return(_callm3(FS, CHROOT, 0, name));
488 _close.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\9f\0#include <lib.h>
495 return(_callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
497 m_creat.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0¥
\0#include <lib.h>
501 PUBLIC int creat(name, mode)
505 return(_callm3(FS, CREAT, mode, name));
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>
515 return(fcntl(fd, F_DUPFD, 0));
517 _dup2.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0.
\ 2#include <lib.h>
524 PUBLIC int dup2(fd, fd2)
527 /* The behavior of dup2 is defined by POSIX in 6.2.1.2 as almost, but not
528 * quite the same as fcntl.
531 if (fd2 < 0 || fd2 > OPEN_MAX) {
536 /* Check to see if fildes is valid. */
537 if (fcntl(fd, F_GETFL) < 0) {
538 /* fd is not valid. */
542 if (fd == fd2) return(fd2);
544 return(fcntl(fd, F_DUPFD, fd2));
547 _exec.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ã
\ f#include <lib.h>
550 #define execle _execle
552 #define execve _execve
554 extern char **environ; /* environment pointer */
556 #define PTRSIZE (sizeof(char *))
557 _PROTOTYPE( char *_sbrk, (int _incr) );
562 PUBLIC int execl(char *name, ...)
568 retval = execve(name, (char **)ap, environ);
573 PUBLIC int execl(name, arg0)
577 return(execve(name, &arg0, environ));
582 PUBLIC int execle(char *name, ...)
590 p = va_arg(ap, char *);
592 p = (char *)va_arg(ap, char **);
595 retval = execve(name, (char **)ap, (char **) p);
600 PUBLIC int execle(name, argv)
605 while (*p++) /* null statement */
607 return(execve(name, &argv, (char **) *p));
611 PUBLIC int execv(name, argv)
615 return(execve(name, argv, environ));
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 */
623 register char **argtop;
624 register char **envtop;
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)));
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 */
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.
644 int i, stackbytes, npointers, overflow, temp;
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 */
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)
655 for (i = PTRSIZE; i != 0; i--) {
656 temp = stackbytes + npointers;
657 if (temp < stackbytes) overflow = TRUE;
660 for (i = 0, ap = argv; i < nargs; i++) {
661 temp = stackbytes + _len(*ap++);
662 if (temp < stackbytes) overflow = TRUE;
665 for (i = 0, ap = envp; i < nenvps; i++) {
666 temp = stackbytes + _len(*ap++);
667 if (temp < stackbytes) overflow = TRUE;
670 temp = stackbytes + PTRSIZE - 1;
671 if (temp < stackbytes) overflow = TRUE;
672 stackbytes = (temp / PTRSIZE) * PTRSIZE;
674 /* Check for overflow before committing sbrk. */
675 if (overflow || stackbytes > ARG_MAX) {
680 /* Allocate the stack. */
681 stack = _sbrk(stackbytes);
682 if (stack == (char *) -1) {
687 /* Prepare the stack vector and argc. */
688 ap = (char **) stack;
689 hp = &stack[npointers * PTRSIZE];
690 *ap++ = (char *) nargs;
692 /* Prepare the argument pointers and strings. */
693 for (i = 0; i < nargs; i++) {
694 *ap++ = (char *) (hp - stack);
696 while ((*hp++ = *p++) != 0)
699 *ap++ = (char *) NULL;
701 /* Prepare the environment pointers and strings. */
702 for (i = 0; i < nenvps; i++) {
703 *ap++ = (char *) (hp - stack);
705 while ((*hp++ = *p++) != 0)
708 *ap++ = (char *) NULL;
710 /* Do the real work. */
711 temp = _callm1(MM, EXEC, _len(path), stackbytes, 0, path, stack, NIL_PTR);
715 \0_execn.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0´
\ 1#include <lib.h>
717 #define PTRSIZE sizeof(char *)
718 _PROTOTYPE( int _execn, (char * name));
720 PUBLIC int _execn(name)
721 char *name; /* pointer to file to be exec'd */
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.
727 PRIVATE char stack[3 * PTRSIZE];
729 return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR));
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.
737 #include <sys/types.h>
740 #define MAXSTK 256 /* maximum EXEC stack size */
741 #define PTRSIZE sizeof(char *)
743 _PROTOTYPE(int _execn,(char *name));
744 _PROTOTYPE(int _execnl,(char *name, char *arg0));
745 PRIVATE _PROTOTYPE(int _nexec,(char *name, char *argv[]));
747 PUBLIC int _execn(name)
748 char *name; /* pointer to file to be exec'd */
750 /* This funcion uses no arguments at all. */
751 PRIVATE char stack[3 * PTRSIZE];
753 return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR));
757 PUBLIC int _execnl(name, arg0)
761 /* This function resembles execl(2). */
763 return(_nexec(name, &arg0));
766 PRIVATE int _nexec(name, argv)
767 char *name; /* pointer to name of file to be executed */
768 char *argv[]; /* pointer to argument array */
771 char **argorg, *hp, **ap, *p;
772 int i, nargs, stackbytes, offset;
774 /* Count the argument pointers. */
777 while (*argorg++ != NIL_PTR) nargs++;
779 /* Prepare to set up the initial stack. */
780 hp = &stack[(nargs + 3) * PTRSIZE];
781 if (hp + nargs >= &stack[MAXSTK]) {
785 ap = (char **) stack;
786 *ap++ = (char *) nargs;
788 /* Prepare the argument pointers and strings. */
789 for (i = 0; i < nargs; i++) {
791 *ap++ = (char *) offset;
795 if (hp >= &stack[MAXSTK]) {
804 stackbytes = (((int) (hp - stack) + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
805 return(_callm1(MM, EXEC, _len(name), stackbytes, 0, name, stack, NIL_PTR));
807 m_fcntl.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\ 2\ 4#include <lib.h>
815 PUBLIC int fcntl(int fd, int cmd, ...)
819 PUBLIC int fcntl(va_alist)
826 int int3; /* third integer parameter for callm1 */
827 char *ptr1; /* first pointer parameter for callm1 */
833 fd = va_arg(ap, int);
834 cmd = va_arg(ap, int);
837 /* Set up for the sensible case where there is no variable parameter. This
838 * covers F_GETFD, F_GETFL and invalid commands.
843 /* Adjust for the stupid cases. */
848 int3 = va_arg(ap, int);
853 ptr1 = (char *) va_arg(ap, struct flock *);
857 /* Clean up and make the system call. */
859 return(_callm1(FS, FCNTL, fd, cmd, int3, ptr1, NIL_PTR, NIL_PTR));
861 _fork.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\90\0#include <lib.h>
867 return(_callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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 */
873 #include <sys/types.h>
875 #include <sys/stat.h>
879 PUBLIC long fpathconf(fd, name)
880 int fd; /* file descriptor being interrogated */
881 int name; /* property being inspected */
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>.
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 */
898 return( (long) LINK_MAX);
901 return( (long) MAX_CANON);
904 return( (long) MAX_INPUT);
907 return( (long) NAME_MAX);
910 return( (long) PATH_MAX);
913 return( (long) PIPE_BUF);
915 case _PC_CHOWN_RESTRICTED:
916 return( (long) 1); /* MINIX defines CHOWN_RESTRICTED */
918 case _PC_NO_TRUNC: /* MINIX does not define NO_TRUNC */
921 case _PC_VDISABLE: /* MINIX defines VDISABLE */
922 return( (long) _POSIX_VDISABLE);
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>
932 #include <sys/stat.h>
934 PUBLIC int fstat(fd, buffer)
938 return(_callm1(FS, FSTAT, fd, 0, 0, (char *)buffer, NIL_PTR, NIL_PTR));
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 */
942 /* Directly derived from Adri Koppes' pwd(1).
943 * Modified by Andy Tanenbaum for POSIX (29 Oct. 1989)
947 #include <sys/stat.h>
951 #define getcwd _getcwd
953 #define DIRECT_SIZE (sizeof (struct direct))
955 PRIVATE _PROTOTYPE(void go_back, (char *path) );
957 char *getcwd(buffer, size)
960 /* Get current working directory. */
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;
967 if (buffer == (char *)NULL || size <= 0) {
969 return((char *)NULL);
973 /* Get the inode for the current directory */
974 if (stat(".", ¤t) == -1) return((char *)NULL);
975 if ((current.st_mode & S_IFMT) != S_IFDIR) return((char *)NULL);
977 /* Run backwards up the directory tree, grabbing dir names on the way. */
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;
988 /* At the root, "." is the same as ".." */
989 if (same_device && current.st_ino == parent.st_ino) break;
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 */
996 if (current.st_ino == d.d_ino) found = 1;
999 strncat(temp_name, d.d_name, NAME_MAX);
1000 if (stat(temp_name, &dir_entry) == -1) {
1003 return((char *)NULL);
1005 if (current.st_dev == dir_entry.st_dev &&
1006 current.st_ino == dir_entry.st_ino)
1014 return((char *)NULL);
1016 if (strlen(path) + NAME_MAX + 1 > PATH_MAX) {
1019 return((char *)NULL);
1022 strncat(path, d.d_name, NAME_MAX);
1023 current.st_dev = parent.st_dev;
1024 current.st_ino = parent.st_ino;
1027 /* Copy the reversed path name into <buffer> */
1028 if (strlen(path) + 1 > size) {
1031 return((char *)NULL);
1033 if (strlen(path) == 0) {
1034 strcpy(buffer, "/");
1038 while ((r = strrchr(path, '/')) != (char *)NULL) {
1042 return(chdir(buffer) ? (char *)NULL : buffer);
1045 PRIVATE void go_back(path)
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
1055 while ((r = strrchr(path, '/')) != (char *)NULL) {
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
1065 PUBLIC gid_t getegid()
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);
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
1077 PUBLIC uid_t geteuid()
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);
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
1089 PUBLIC gid_t getgid()
1091 return((gid_t)_callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1099 return(_callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1101 _getppid.c
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Í
\0#include <lib.h>
1102 #define getppid _getppid
1105 PUBLIC int getppid()
1109 p = _callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1110 if (p < 0) return(p);
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
1118 PUBLIC uid_t getuid()
1120 return((uid_t)_callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1122 _gtty.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0
\0#include <lib.h>
1124 #define ioctl _ioctl
1127 PUBLIC int gtty(fd, argp)
1129 struct sgttyb *argp;
1131 return(ioctl(fd, TIOCGETP, argp));
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
1138 PUBLIC int ioctl(fd, request, argp)
1141 struct sgttyb *argp;
1144 long erase, kill, intr, quit, xon, xoff, eof, brk, speed;
1145 struct tchars *argt;
1147 _M.TTY_REQUEST = request;
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);
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);
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;
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;
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.
1199 _M.TTY_FLAGS = (int /* kludge */) argp;
1200 return _callx(FS, IOCTL);
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
1206 _M.ADDRESS = (char *)argp;
1207 return _callx(FS, IOCTL);
1210 (_kill.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ö
\0#include <lib.h>
1214 PUBLIC int kill(proc, sig)
1215 int proc; /* which process is to be sent the signal */
1216 int sig; /* signal number */
1218 return(_callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1220 _link.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ÿ
\0#include <lib.h>
1224 PUBLIC int link(name, name2)
1225 _CONST char *name, *name2;
1227 return(_callm1(FS, LINK, _len(name), _len(name2), 0,
1228 (char *) name, (char *) name2, /* perhaps callm1 preserves these */
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
1236 PUBLIC off_t lseek(fd, offset, whence)
1245 k = _callx(FS, LSEEK);
1246 if (k != 0) return((off_t) k); /* _send() itself failed */
1247 return((off_t)_M.m2_l1);
1249 message.c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0l
\0#include <lib.h>
1251 /* Some compilers require an initializer to force storage allocation */
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>
1257 PUBLIC int mkdir(name, mode)
1261 return(_callm1(FS, MKDIR, _len(name), mode, 0, (char *)name, NIL_PTR, NIL_PTR));
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>
1268 PUBLIC int mkfifo(name, mode)
1272 mode = (mode & 0777) | S_IFIFO;
1273 return(_callm1(FS, MKNOD, _len(name), (int)mode, 0,
1274 (char *)name, NIL_PTR, NIL_PTR));
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
1280 PUBLIC int mknod(name, mode, addr)
1284 return(_callm1(FS, MKNOD, _len(name), mode, addr,
1285 (char *) name, (char *) 0, NIL_PTR));
1287 _mknod4.c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0
1289 #define mknod4 _mknod4
1292 PUBLIC int mknod4(name, mode, addr, size)
1297 return(_callm1(FS, MKNOD, _len(name), mode, addr,
1298 (char *) name, (char *) size, NIL_PTR));
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
1304 PUBLIC int mount(special, name, rwflag)
1305 char *name, *special;
1308 return(_callm1(FS, MOUNT, _len(special), _len(name), rwflag, special, name, NIL_PTR));
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>
1318 PUBLIC int open(const char *name, int flags, ...)
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);
1331 return _callm3(FS, OPEN, flags, name);
1334 PUBLIC int open(name, flags, mode)
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));
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 */
1347 #include <sys/types.h>
1351 #define close _close
1353 PUBLIC long pathconf(path, name)
1354 char *path; /* name of file being interrogated */
1355 int name; /* property being inspected */
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>.
1366 if ( (fd = open(path, O_RDONLY)) < 0) return(-1L);
1367 val = fpathconf(fd, name);
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
1377 return(_callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1379 _pipe.c
\0\0c
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\ 1\ 1#include <lib.h>
1383 PUBLIC int pipe(fild)
1387 k = _callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
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
1399 PUBLIC long ptrace(req, pid, addr, data)
1407 if (_callx(MM, PTRACE) == -1) return(-1L);
1408 if (_M.m2_l2 == -1) {
1414 _read.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Î
\0#include <lib.h>
1418 PUBLIC int read(fd, buffer, nbytes)
1423 return(_callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR));
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
1429 PUBLIC int rename(name, name2)
1430 _CONST char *name, *name2;
1432 return(_callm1(FS, RENAME, _len(name), _len(name2), 0,
1433 (char *) name, (char *) name2, /* perhaps callm1 preserves these */
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
1440 PUBLIC int rmdir(name)
1443 return(_callm3(FS, RMDIR, 0, name));
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
1450 PUBLIC int setgid(grp)
1453 return(_callm1(MM, SETGID, (int)grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1460 PUBLIC int setuid(usr)
1463 return(_callm1(MM, SETUID, (int)usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1469 extern _PROTOTYPE(void (*_vectab[_NSIG]), (int)); /* array of funcs to catch signals */
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
1476 * PUBLIC void *signal(signr, func)
1477 * and change ../h/signal.h accordingly.
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 */
1485 _PROTOTYPE( void (*old), (int));
1487 old = _vectab[signr - 1];
1489 if (func == SIG_IGN || func == SIG_DFL)
1490 /* Keep old signal catcher until it is completely de-installed */
1493 /* Use new signal catcher immediately (old one may not exist) */
1494 _vectab[signr - 1] = func;
1497 r = _callx(MM, SIGNAL);
1499 _vectab[signr - 1] = old;/* undo any pre-installation */
1500 return((void (*) ()) r);
1502 _vectab[signr - 1] = func; /* redo any pre-installation */
1503 if (r == 1) return(SIG_IGN);
1506 _stat.c
\0c
\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ß
\0#include <lib.h>
1508 #include <sys/stat.h>
1510 PUBLIC int stat(name, buffer)
1512 struct stat *buffer;
1514 return(_callm1(FS, STAT, _len(name), 0, 0,
1515 (char *)name, (char *)buffer, NIL_PTR));
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
1521 PUBLIC int stime(top)
1525 return(_callx(FS, STIME));
1527 _stty.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0¬
\0#include <lib.h>
1529 #define ioctl _ioctl
1532 PUBLIC int stty(fd, argp)
1534 struct sgttyb *argp;
1536 return ioctl(fd, TIOCSETP, argp);
1538 _sync.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\90\0#include <lib.h>
1544 return(_callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
1546 syslib.c
\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0
1548 #include <minix/com.h>
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));
1557 PUBLIC _PROTOTYPE( void sys_xit, (int parent, int proc));
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));
1565 PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid, int shadow));
1568 PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid));
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));
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));
1585 #if (CHIP == M68000)
1586 PUBLIC void sys_xit(parent, proc, basep, sizep)
1587 phys_clicks *basep, *sizep;
1589 PUBLIC void sys_xit(parent, proc)
1591 int parent; /* parent of exiting proc. */
1592 int proc; /* which proc has exited */
1594 /* A proc has exited. Tell the kernel. */
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;
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 */
1608 /* Ask the kernel what the sp is. */
1611 _callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1612 *newsp = (vir_bytes) _M.STACK_PTR;
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 */
1621 /* A proc has to be signaled. Tell the kernel. */
1625 _M.m6_f1 = sighandler;
1626 _callx(SYSTASK, SYS_SIG);
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 */
1638 PUBLIC void sys_fork(parent, child, pid)
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 */
1644 /* A proc has forked. Tell the kernel. */
1646 #if (CHIP == M68000)
1647 _callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *) shadow, NIL_PTR, NIL_PTR);
1649 _callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR);
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? */
1659 /* A proc has exec'd. Tell the kernel. */
1661 _callm1(SYSTASK, SYS_EXEC, proc, traced, 0, ptr, NIL_PTR, NIL_PTR);
1664 PUBLIC void sys_newmap(proc, ptr)
1665 int proc; /* proc whose map is to be changed */
1666 char *ptr; /* pointer to new map */
1668 /* A proc has been assigned a new memory map. Tell the kernel. */
1671 _callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
1674 PUBLIC void sys_copy(mptr)
1675 message *mptr; /* pointer to message */
1677 /* A proc wants to use local copy. */
1679 /* Make this routine better. Also check other guys' error handling
1681 mptr->m_type = SYS_COPY;
1682 if (_sendrec(SYSTASK, mptr) != 0) panic("sys_copy can't send", NO_NUM);
1685 PUBLIC void sys_times(proc, ptr)
1686 int proc; /* proc whose times are needed */
1687 time_t ptr[4]; /* pointer to time buffer */
1689 /* Fetch the accounting info for a proc. */
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;
1699 PUBLIC void sys_abort()
1701 /* Something awful has happened. Abandon ship. */
1703 _callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
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() */
1713 /* Create a fresh process image for exec(). Tell the kernel. */
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;
1723 PUBLIC void sys_kill(proc, sig)
1724 int proc; /* which proc has exited */
1725 int sig; /* signal number: 1 - 16 */
1727 /* A proc has to be signaled via MM. Tell the kernel. */
1731 _callx(SYSTASK, SYS_KILL);
1734 PUBLIC int sys_trace(req, procnr, addr, data_p)
1743 if (data_p) _M.m2_l2 = *data_p;
1744 r = _callx(SYSTASK, SYS_TRACE);
1745 if (data_p) *data_p = _M.m2_l2;
1749 PUBLIC void tell_fs(what, p1, p2, p3)
1750 int what, p1, p2, p3;
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)
1763 _callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR);
1765 _time.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\00
\ 1#include <lib.h>
1769 PUBLIC long time(tp)
1774 k = _callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1775 if (_M.m_type < 0 || k != 0) {
1780 if (tp != (long *) 0) *tp = l;
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>
1786 #define times _times
1787 #include <sys/times.h>
1789 PUBLIC clock_t times(buf)
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;
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>
1805 PUBLIC mode_t umask(complmode)
1808 return((mode_t)_callm1(FS, UMASK, (int)complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR));
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
1814 PUBLIC int umount(name)
1817 return(_callm3(FS, UMOUNT, 0, name));
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
1823 PUBLIC int unlink(name)
1826 return(_callm3(FS, UNLINK, 0, name));
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 */
1833 #define utime _utime
1838 PUBLIC int utime(name, timp)
1840 struct utimbuf *timp;
1844 if (timp == (struct utimbuf *)NULL) {
1845 current_time = time((long *)NULL);
1846 _M.m2_l1 = current_time;
1847 _M.m2_l2 = current_time;
1849 _M.m2_l1 = timp->actime;
1850 _M.m2_l2 = timp->modtime;
1853 _M.m2_i1 = _len(name);
1855 return _callx(FS, UTIME);
1857 p_wait.c
\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0è
\0#include <lib.h>
1859 #include <sys/wait.h>
1861 PUBLIC int wait(status)
1865 k = _callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
1866 if (k >= 0 && status != 0) *status = _M.m2_i1;
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
1873 PUBLIC int write(fd, buffer, nbytes)
1878 return(_callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR));
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
1882 .define __send, __receive, __sendrec
1884 ! See ../h/com.h for C definitions
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)
1899 mov cx,RECEIVE ! _receive(src, ptr)
1903 mov cx,BOTH ! _sendrec(srcdest, ptr)
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
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
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
1922 .extern __vectab, __M
1923 mtype = 2 ! M+mtype = &M.m_type
1926 push ax ! after interrupt, save all regs
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
1945 pop ax ! get signal number off stack
1946 pop (__M+mtype) ! restore status of previous system call
1947 pop es ! signal handling finished
1956 pop (dummy) ! remove signal number from stack
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[].
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 */