|
|
1.1 root 1: # 1 "acct.c"
2:
3:
4: # 1 "../sys/param.h"
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42: # 1 "/usr/include/signal.h"
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81: typedef int (*SIG_TYP)();
82: # 42 "/usr/include/signal.h"
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101: # 39 "../sys/param.h"
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194: # 1 "../sys/types.h"
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223: typedef unsigned char u_char;
224: typedef unsigned short u_short;
225: typedef unsigned int u_int;
226: typedef unsigned long u_long;
227:
228: typedef long daddr_t;
229: typedef char * caddr_t;
230: typedef u_short ino_t;
231: typedef long swblk_t;
232:
233:
234: typedef long size_t;
235:
236: typedef long time_t;
237: typedef long label_t[14];
238: typedef u_short dev_t;
239: typedef long off_t;
240: typedef struct { unsigned long lo; long hi; } Long;
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256: typedef struct fd_set { unsigned int fds_bits[(128+sizeof(int)*8-1)/(sizeof(int)*8)]; } fd_set;
257:
258:
259:
260:
261: # 132 "../sys/param.h"
262:
263:
264:
265:
266:
267: Long ltoL();
268: Long Lladd();
269: Long Luadd();
270: Long LLadd();
271:
272: unsigned Lshift();
273: # 4 "acct.c"
274: # 1 "../sys/systm.h"
275:
276:
277:
278:
279:
280: int lbolt;
281: time_t time;
282: char runin;
283: char runout;
284: int runrun;
285: int noproc;
286: char curpri;
287: int maxmem;
288: int physmem;
289: int wantin;
290:
291: daddr_t rablock;
292: dev_t rootdev;
293: extern dev_t swapdev;
294: dev_t argdev;
295:
296: daddr_t bmap();
297: unsigned max();
298: unsigned min();
299:
300:
301:
302:
303: extern struct sysent
304: {
305: int sy_narg;
306: int (*sy_call)();
307: } sysent[];
308:
309: # 5 "acct.c"
310: # 1 "../sys/acct.h"
311:
312:
313:
314:
315:
316: typedef u_short comp_t;
317:
318: struct acct
319: {
320: char ac_comm[10];
321: comp_t ac_utime;
322: comp_t ac_stime;
323: comp_t ac_etime;
324: time_t ac_btime;
325: short ac_uid;
326: short ac_gid;
327: short ac_mem;
328: comp_t ac_io;
329: dev_t ac_tty;
330: char ac_flag;
331: };
332:
333:
334:
335:
336: # 6 "acct.c"
337: # 1 "../sys/user.h"
338: # 1 "../sys/pcb.h"
339:
340:
341:
342:
343: struct pcb
344: {
345: int pcb_ksp;
346: int pcb_esp;
347: int pcb_ssp;
348: int pcb_usp;
349: int pcb_r0;
350: int pcb_r1;
351: int pcb_r2;
352: int pcb_r3;
353: int pcb_r4;
354: int pcb_r5;
355: int pcb_r6;
356: int pcb_r7;
357: int pcb_r8;
358: int pcb_r9;
359: int pcb_r10;
360: int pcb_r11;
361: int pcb_r12;
362:
363: int pcb_r13;
364:
365: int pcb_pc;
366: int pcb_psl;
367: struct pte *pcb_p0br;
368: int pcb_p0lr;
369: struct pte *pcb_p1br;
370: int pcb_p1lr;
371:
372:
373:
374: long *pcb_sswap;
375: int pcb_szpt;
376: int pcb_sigc[3];
377: };
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398: # 2 "../sys/user.h"
399: # 1 "../sys/dmap.h"
400:
401:
402:
403:
404:
405:
406:
407: struct dmap
408: {
409: swblk_t dm_size;
410: swblk_t dm_alloc;
411: swblk_t dm_map[64];
412: };
413:
414: extern struct dmap zdmap;
415: extern int dmmin;
416: extern int dmmax;
417:
418:
419:
420:
421:
422:
423: struct dblock
424: {
425: swblk_t db_base;
426: swblk_t db_size;
427: };
428: # 3 "../sys/user.h"
429: # 1 "../sys/vtimes.h"
430:
431:
432:
433:
434:
435:
436: struct vtimes {
437: int vm_utime;
438: int vm_stime;
439:
440: unsigned vm_idsrss;
441: unsigned vm_ixrss;
442: int vm_maxrss;
443: int vm_majflt;
444: int vm_minflt;
445: int vm_nswap;
446: int vm_inblk;
447: int vm_oublk;
448: };
449:
450:
451: struct vtimes zvms;
452:
453: # 4 "../sys/user.h"
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472: struct user
473: {
474: struct pcb u_pcb;
475: int junk1;
476: int u_arg[5];
477: label_t u_qsav;
478: char u_segflg;
479:
480:
481:
482: char u_error;
483: short u_uid;
484: short u_gid;
485: short u_ruid;
486: short u_rgid;
487: short u_groups[32];
488: struct proc *u_procp;
489: int *u_ap;
490: union {
491: struct {
492: int R_val1;
493: int R_val2;
494: } u_rv;
495:
496:
497: off_t r_off;
498: time_t r_time;
499: } u_r;
500: caddr_t u_base;
501: unsigned int u_count;
502: Long u_offset;
503: struct inode *u_cdir;
504: struct inode *u_rdir;
505: char junk2[14];
506: char junk4[14+2];
507: struct file *u_ofile[128];
508: char u_pofile[128];
509:
510: label_t u_ssav;
511: int (*u_signal[32])();
512: int u_code;
513:
514:
515: int *u_ar0;
516: struct uprof {
517: short *pr_base;
518: unsigned pr_size;
519: unsigned pr_off;
520: unsigned pr_scale;
521: } u_prof;
522: short junk5;
523: dev_t u_ttydev;
524: ino_t u_ttyino;
525: union {
526: struct {
527: int Ux_mag;
528: unsigned Ux_tsize;
529: unsigned Ux_dsize;
530: unsigned Ux_bsize;
531: unsigned Ux_ssize;
532: unsigned Ux_entloc;
533: unsigned Ux_unused;
534: unsigned Ux_relflg;
535: } Ux_A;
536: char ux_shell[32];
537: } u_exdata;
538:
539:
540:
541:
542:
543:
544:
545:
546:
547: char u_comm[14];
548: time_t u_start;
549: char u_acflag;
550: short junk6;
551: short u_cmask;
552: size_t u_tsize;
553: size_t u_dsize;
554: size_t u_ssize;
555: struct vtimes u_vm;
556: struct vtimes u_cvm;
557: struct dmap u_dmap;
558: struct dmap u_smap;
559: struct dmap u_cdmap, u_csmap;
560:
561: time_t u_outime;
562: size_t u_odsize, u_ossize;
563: int u_limit[8];
564: int u_nbadio;
565: char u_logname[8];
566: int u_stack[1];
567:
568:
569:
570:
571:
572:
573: };
574:
575:
576:
577:
578:
579:
580:
581: # 1 "/usr/include/errno.h"
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633: # 56 "/usr/include/errno.h"
634:
635: # 132 "../sys/user.h"
636:
637:
638: extern struct user u;
639: extern struct user *swaputl;
640: extern struct user *forkutl;
641: extern struct user *xswaputl;
642: extern struct user *xswap2utl;
643: extern struct user *pushutl;
644: extern struct user *prusrutl;
645:
646: # 7 "acct.c"
647: # 1 "../sys/inode.h"
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661: struct inode
662: {
663: short i_flag;
664: dev_t i_dev;
665: char i_fstyp;
666: unsigned short i_count;
667: long i_number;
668: unsigned short i_mode;
669: short i_nlink;
670: short i_uid;
671: short i_gid;
672: off_t i_size;
673: struct inode *i_mroot;
674: struct inode *i_mpoint;
675: struct stdata *i_sptr;
676: union {
677: struct {
678: daddr_t I_addr[13];
679: daddr_t I_lastr;
680: struct buf *I_bufp;
681: } i_f;
682:
683:
684:
685: struct {
686: daddr_t I_rdev;
687: } i_d;
688:
689: struct {
690: long I_tag;
691: struct inode *I_cip;
692: int I_fsflags;
693: time_t I_atime;
694: time_t I_mtime;
695: time_t I_ctime;
696: dev_t I_rdev;
697: } i_a;
698:
699:
700:
701:
702:
703:
704:
705: struct {
706: struct proc *I_proc;
707: int I_sigmask;
708: } i_p;
709:
710:
711: } i_un;
712: struct inode *i_hlink;
713: };
714:
715:
716: struct inode inode[];
717: extern struct inode *inodeNINODE;
718: extern int inodecnt;
719:
720: struct inode *rootdir;
721:
722: struct inode *ialloc();
723: struct inode *ifind();
724: struct inode *iget();
725: struct inode *iuniq();
726: struct inode *namei();
727: struct inode *openi();
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756: struct argnamei {
757: short flag;
758: short len;
759: union {
760: short mode;
761: struct inode *il;
762: caddr_t buf;
763: } un;
764: };
765:
766:
767:
768:
769:
770:
771:
772:
773:
774: extern struct argnamei nilargnamei;
775:
776: struct nx {
777: struct inode *dp;
778: char *cp;
779: char *nbuf;
780: short nlen;
781: short nlink;
782: };
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809: # 8 "acct.c"
810:
811: struct inode *acctp;
812:
813:
814:
815:
816: sysacct()
817: {
818: register struct inode *ip;
819: register struct a {
820: char *fname;
821: } *uap;
822:
823: uap = (struct a *)u.u_ap;
824: if (suser() == 0)
825: return;
826: if (uap->fname==0) {
827: if (ip = acctp) {
828: { while ((ip)->i_flag & 01) { (ip)->i_flag |= 020; sleep((caddr_t)(ip), 10); } (ip)->i_flag |= 01; };
829: iput(ip);
830: acctp = 0;
831: }
832: return;
833: }
834: if (acctp) {
835: u.u_error = 16;
836: return;
837: }
838: ip = namei(uap->fname, 0, &nilargnamei, 1);
839: if(ip == 0)
840: return;
841: if((ip->i_mode & 0170000) != 0100000) {
842: u.u_error = 13;
843: iput(ip);
844: return;
845: }
846: if (access(ip, 0200)) {
847: iput(ip);
848: return;
849: }
850: acctp = ip;
851: { (ip)->i_flag &= ~01; if ((ip)->i_flag&020) { (ip)->i_flag &= ~020; wakeup((caddr_t)(ip)); } };
852: }
853:
854: struct acct acctbuf;
855:
856:
857:
858: acct()
859: {
860: register i;
861: register struct inode *ip;
862: off_t siz;
863: register struct acct *ap = &acctbuf;
864:
865: if ((ip=acctp)==0)
866: return;
867: { while ((ip)->i_flag & 01) { (ip)->i_flag |= 020; sleep((caddr_t)(ip), 10); } (ip)->i_flag |= 01; };
868: for (i=0; i<sizeof(ap->ac_comm); i++)
869: ap->ac_comm[i] = u.u_comm[i];
870: ap->ac_utime = compress((long)u.u_vm.vm_utime);
871: ap->ac_stime = compress((long)u.u_vm.vm_stime);
872: ap->ac_etime = compress((long)(time - u.u_start));
873: ap->ac_btime = u.u_start;
874: ap->ac_uid = u.u_ruid;
875: ap->ac_gid = u.u_rgid;
876: ap->ac_mem = 0;
877: if (i = u.u_vm.vm_utime + u.u_vm.vm_stime)
878: ap->ac_mem = (u.u_vm.vm_ixrss + u.u_vm.vm_idsrss) / i;
879: ap->ac_io = compress((long)(u.u_vm.vm_inblk + u.u_vm.vm_oublk));
880: ap->ac_tty = u.u_ttyino;
881: ap->ac_flag = u.u_acflag;
882: siz = ip->i_size;
883: u.u_offset = ltoL(siz);
884: u.u_base = (caddr_t)ap;
885: u.u_count = sizeof(acctbuf);
886: u.u_segflg = 1;
887: u.u_error = 0;
888: writei(ip);
889: if(u.u_error)
890: ip->i_size = siz;
891: { (ip)->i_flag &= ~01; if ((ip)->i_flag&020) { (ip)->i_flag &= ~020; wakeup((caddr_t)(ip)); } };
892: }
893:
894:
895:
896:
897:
898: compress(t)
899: register long t;
900: {
901: register exp = 0, round = 0;
902:
903: while (t >= 8192) {
904: exp++;
905: round = t&04;
906: t >>= 3;
907: }
908: if (round) {
909: t++;
910: if (t >= 8192) {
911: t >>= 3;
912: exp++;
913: }
914: }
915: return((exp<<13) + t);
916: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.