|
|
1.1 root 1: /* $Header: /kernel/kersrc/coh.386/RCS/misc.c,v 1.2 92/08/04 12:33:36 bin Exp Locker: bin $ */
2: /* (lgl-
3: * The information contained herein is a trade secret of Mark Williams
4: * Company, and is confidential information. It is provided under a
5: * license agreement, and may be copied or disclosed only under the
6: * terms of that agreement. Any reproduction or disclosure of this
7: * material without the express written authorization of Mark Williams
8: * Company or persuant to the license agreement is unlawful.
9: *
10: * COHERENT Version 2.3.37
11: * Copyright (c) 1982, 1983, 1984.
12: * An unpublished work by Mark Williams Company, Chicago.
13: * All rights reserved.
14: -lgl) */
15: /*
16: * Coherent.
17: * Miscellaneous routines.
18: *
19: * $Log: misc.c,v $
20: * Revision 1.2 92/08/04 12:33:36 bin
21: * changed for ker 59
22: *
23: * Revision 1.2 92/01/06 11:59:45 hal
24: * Compile with cc.mwc.
25: *
26: * Revision 1.1 88/03/24 16:14:01 src
27: * Initial revision
28: *
29: * 87/05/08 Allan Cornish /usr/src/sys/coh/misc.c
30: * System code and data segments no longer reported in panic messages.
31: *
32: * 87/02/17 Allan Cornish /usr/src/sys/coh/misc.c
33: * Panic message now includes system code and data segments.
34: */
35: #include <sys/coherent.h>
36: #include <acct.h>
37: #include <errno.h>
38: #include <sys/ino.h>
39: #include <sys/stat.h>
40:
41: #ifdef TRACER
42: extern unsigned t_piggy;
43: #endif
44:
45: /*
46: * Copy `n' bytes from `bp1' to `bp2'.
47: */
48: kkcopy(bp1, bp2, n)
49: register char *bp1;
50: register char *bp2;
51: unsigned n;
52: {
53: register unsigned n1;
54:
55: n1 = n;
56: if (n1) {
57: do {
58: *bp2++ = *bp1++;
59: } while (--n1);
60: }
61: return (n);
62: }
63:
64: /*
65: * Clear the next `n' bytes starting at `bp'.
66: */
67: kclear(bp, n)
68: register char *bp;
69: register unsigned n;
70: {
71: if (n) {
72: do {
73: *bp++ = 0;
74: } while (--n);
75: }
76: }
77:
78: /*
79: * Make sure we are the super user.
80: */
81: super()
82: {
83: if (u.u_uid) {
84: u.u_error = EPERM;
85: return (0);
86: }
87: u.u_flag |= ASU;
88: return (1);
89: }
90:
91: /*
92: * Make sure we are the gived `uid' or the super user.
93: */
94: owner(uid)
95: {
96: if (u.u_uid == uid)
97: return (1);
98: if (u.u_uid == 0) {
99: u.u_flag |= ASU;
100: return (1);
101: }
102: u.u_error = EPERM;
103: return (0);
104: }
105:
106: /*
107: * Panic.
108: */
109: panic(a1)
110: char *a1;
111: {
112: static panflag;
113: sphi();
114:
115: #ifdef TRACER
116: if ( t_piggy & 0x80 ) {
117: if (panflag++ == 0) {
118: printf("Panic: %r", &a1);
119: putchar('\n');
120: usync();
121: }
122: printf("relax! It really isn't so bad.\n");
123: } else {
124: if (panflag++ == 0) {
125: printf("Panic: %r", &a1);
126: putchar('\n');
127: for (;;);
128: usync();
129: }
130: halt();
131: }
132: #else
133: if (panflag++ == 0) {
134: printf("Panic: %r", &a1);
135: putchar('\n');
136: for (;;);
137: usync();
138: }
139: halt();
140: #endif /* TRACER */
141:
142: --panflag;
143: }
144:
145: /*
146: * Print a message from a device driver.
147: */
148: devmsg(dev, a1)
149: dev_t dev;
150: char *a1;
151: {
152: printf("(%d,%d): %r", major(dev), minor(dev), &a1);
153: printf("\n");
154: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.