home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1002 < prev    next >
SHell self-extracting ARchive  |  1990-12-28  |  10.8 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: 1002

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news or mail text default
99% file C source text default
98% file makefile script text default
97% file C source, ASCII text default
100% TrID E-Mail message (Var. 2) default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 3a 20 6a 66 | 68 40 72 70 70 33 38 36 |From: jf|h@rpp386|
|00000010| 2e 63 61 63 74 75 73 2e | 6f 72 67 20 28 4a 6f 68 |.cactus.|org (Joh|
|00000020| 6e 20 46 2e 20 48 61 75 | 67 68 20 49 49 29 0a 4e |n F. Hau|gh II).N|
|00000030| 65 77 73 67 72 6f 75 70 | 73 3a 20 61 6c 74 2e 73 |ewsgroup|s: alt.s|
|00000040| 6f 75 72 63 65 73 0a 53 | 75 62 6a 65 63 74 3a 20 |ources.S|ubject: |
|00000050| 6f 66 69 6c 65 73 20 63 | 6f 6d 6d 61 6e 64 20 66 |ofiles c|ommand f|
|00000060| 6f 72 20 53 43 4f 20 58 | 65 6e 69 78 0a 4d 65 73 |or SCO X|enix.Mes|
|00000070| 73 61 67 65 2d 49 44 3a | 20 3c 31 38 31 31 36 40 |sage-ID:| <18116@|
|00000080| 72 70 70 33 38 36 2e 63 | 61 63 74 75 73 2e 6f 72 |rpp386.c|actus.or|
|00000090| 67 3e 0a 44 61 74 65 3a | 20 31 30 20 4d 61 72 20 |g>.Date:| 10 Mar |
|000000a0| 39 30 20 30 34 3a 31 32 | 3a 30 37 20 47 4d 54 0a |90 04:12|:07 GMT.|
|000000b0| 0a 51 75 6f 74 65 64 20 | 66 72 6f 6d 20 74 68 65 |.Quoted |from the|
|000000c0| 20 52 45 41 44 4d 45 20 | 2e 2e 2e 0a 0a 49 20 68 | README |.....I h|
|000000d0| 61 63 6b 65 64 20 6f 6e | 20 74 68 69 73 20 74 6f |acked on| this to|
|000000e0| 20 70 72 6f 64 75 63 65 | 20 61 20 76 65 72 73 69 | produce| a versi|
|000000f0| 6f 6e 20 77 68 69 63 68 | 20 72 75 6e 73 20 6f 6e |on which| runs on|
|00000100| 20 53 43 4f 20 58 65 6e | 69 78 2f 33 38 36 20 32 | SCO Xen|ix/386 2|
|00000110| 2e 32 2e 33 2e 0a 54 68 | 65 20 62 69 67 67 65 73 |.2.3..Th|e bigges|
|00000120| 74 20 63 68 61 6e 67 65 | 73 20 69 6e 76 6f 6c 76 |t change|s involv|
|00000130| 65 64 20 64 65 61 6c 69 | 6e 67 20 77 69 74 68 20 |ed deali|ng with |
|00000140| 74 68 65 20 66 6c 6f 61 | 74 69 6e 67 20 73 74 72 |the floa|ting str|
|00000150| 75 63 74 75 72 65 73 20 | 69 6e 20 55 4e 49 58 0a |uctures |in UNIX.|
|00000160| 66 6f 72 20 74 68 65 20 | 33 42 31 2e 20 20 53 74 |for the |3B1. St|
|00000170| 72 61 6e 67 65 20 6d 61 | 63 68 69 6e 65 20 2e 2e |range ma|chine ..|
|00000180| 2e 0a 0a 49 20 61 64 64 | 65 64 20 63 6f 64 65 20 |...I add|ed code |
|00000190| 74 6f 20 6c 6f 63 61 74 | 65 20 74 68 65 20 69 6e |to locat|e the in|
|000001a0| 6f 64 65 20 66 6f 72 20 | 74 68 65 20 74 65 78 74 |ode for |the text|
|000001b0| 20 74 61 62 6c 65 20 65 | 6e 74 72 79 2c 20 69 66 | table e|ntry, if|
|000001c0| 20 74 68 65 20 70 72 6f | 63 65 73 73 0a 73 74 72 | the pro|cess.str|
|000001d0| 75 63 74 75 72 65 20 69 | 6e 64 69 63 61 74 65 64 |ucture i|ndicated|
|000001e0| 20 6f 6e 65 20 65 78 69 | 73 74 65 64 2e 20 20 54 | one exi|sted. T|
|000001f0| 68 69 73 20 70 72 69 6e | 74 73 20 61 73 20 61 6e |his prin|ts as an|
|00000200| 20 27 78 27 20 63 68 61 | 72 61 63 74 65 72 2e 20 | 'x' cha|racter. |
|00000210| 20 49 20 61 6c 73 6f 0a | 61 64 64 65 64 20 73 65 | I also.|added se|
|00000220| 74 75 69 64 28 29 20 63 | 61 6c 6c 73 20 61 72 6f |tuid() c|alls aro|
|00000230| 75 6e 64 20 74 68 65 20 | 6f 70 65 6e 73 20 6f 66 |und the |opens of|
|00000240| 20 74 68 65 20 64 65 76 | 69 63 65 20 66 69 6c 65 | the dev|ice file|
|00000250| 73 20 77 68 69 63 68 20 | 72 65 71 75 69 72 65 64 |s which |required|
|00000260| 0a 72 6f 6f 74 20 70 72 | 69 76 69 6c 65 67 65 2e |.root pr|ivilege.|
|00000270| 20 20 59 65 73 2c 20 69 | 74 20 77 61 73 20 70 6f | Yes, i|t was po|
|00000280| 73 73 69 62 6c 65 20 74 | 6f 20 69 6e 73 74 61 6c |ssible t|o instal|
|00000290| 6c 20 74 68 69 73 20 70 | 72 6f 67 72 61 6d 20 61 |l this p|rogram a|
|000002a0| 73 20 53 55 49 44 20 72 | 6f 6f 74 0a 61 6e 64 20 |s SUID r|oot.and |
|000002b0| 68 61 76 65 20 61 6e 79 | 6f 6e 65 20 62 65 20 61 |have any|one be a|
|000002c0| 62 6c 65 20 74 6f 20 64 | 65 74 65 72 6d 69 6e 65 |ble to d|etermine|
|000002d0| 20 74 68 65 20 73 74 61 | 74 75 73 20 6f 66 20 61 | the sta|tus of a|
|000002e0| 6e 79 20 66 69 6c 65 20 | 6f 6e 20 74 68 65 20 73 |ny file |on the s|
|000002f0| 79 73 74 65 6d 2c 0a 65 | 76 65 6e 20 69 66 20 74 |ystem,.e|ven if t|
|00000300| 68 65 20 75 73 65 72 20 | 77 6f 75 6c 64 20 6e 6f |he user |would no|
|00000310| 74 20 6e 6f 72 6d 61 6c | 6c 79 20 68 61 76 65 20 |t normal|ly have |
|00000320| 61 63 63 65 73 73 20 74 | 6f 20 74 68 61 74 20 66 |access t|o that f|
|00000330| 69 6c 65 2e 20 20 4e 6f | 74 20 65 78 61 63 74 6c |ile. No|t exactl|
|00000340| 79 0a 61 20 67 6f 6f 64 | 20 69 64 65 61 20 2e 2e |y.a good| idea ..|
|00000350| 2e 0a 0a 54 68 65 20 63 | 6f 64 65 20 68 61 73 20 |...The c|ode has |
|00000360| 68 61 64 20 61 6c 6c 20 | 6f 66 20 74 68 65 20 33 |had all |of the 3|
|00000370| 42 31 20 64 65 70 65 6e | 64 65 6e 74 20 74 68 69 |B1 depen|dent thi|
|00000380| 6e 67 73 20 72 65 6d 6f | 76 65 64 20 61 6e 64 20 |ngs remo|ved and |
|00000390| 61 20 6c 69 74 74 6c 65 | 0a 73 70 72 69 6e 67 20 |a little|.spring |
|000003a0| 63 6c 65 61 6e 69 6e 67 | 20 61 70 70 6c 69 65 64 |cleaning| applied|
|000003b0| 2e 0a 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 20 63 75 74 |..------|---- cut|
|000003c0| 20 68 65 72 65 20 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d | here --|--------|
|000003d0| 0a 23 21 20 2f 62 69 6e | 2f 73 68 0a 23 20 54 68 |.#! /bin|/sh.# Th|
|000003e0| 69 73 20 69 73 20 61 20 | 73 68 65 6c 6c 20 61 72 |is is a |shell ar|
|000003f0| 63 68 69 76 65 2c 20 6d | 65 61 6e 69 6e 67 3a 0a |chive, m|eaning:.|
|00000400| 23 20 31 2e 20 52 65 6d | 6f 76 65 20 65 76 65 72 |# 1. Rem|ove ever|
|00000410| 79 74 68 69 6e 67 20 61 | 62 6f 76 65 20 74 68 65 |ything a|bove the|
|00000420| 20 23 21 20 2f 62 69 6e | 2f 73 68 20 6c 69 6e 65 | #! /bin|/sh line|
|00000430| 2e 0a 23 20 32 2e 20 53 | 61 76 65 20 74 68 65 20 |..# 2. S|ave the |
|00000440| 72 65 73 75 6c 74 69 6e | 67 20 74 65 78 74 20 69 |resultin|g text i|
|00000450| 6e 20 61 20 66 69 6c 65 | 2e 0a 23 20 33 2e 20 45 |n a file|..# 3. E|
|00000460| 78 65 63 75 74 65 20 74 | 68 65 20 66 69 6c 65 20 |xecute t|he file |
|00000470| 77 69 74 68 20 2f 62 69 | 6e 2f 73 68 20 28 6e 6f |with /bi|n/sh (no|
|00000480| 74 20 63 73 68 29 20 74 | 6f 20 63 72 65 61 74 65 |t csh) t|o create|
|00000490| 3a 0a 23 09 52 45 41 44 | 4d 45 0a 23 09 4d 61 6b |:.#.READ|ME.#.Mak|
|000004a0| 65 66 69 6c 65 0a 23 09 | 6f 66 69 6c 65 73 2e 63 |efile.#.|ofiles.c|
|000004b0| 0a 23 20 54 68 69 73 20 | 61 72 63 68 69 76 65 20 |.# This |archive |
|000004c0| 63 72 65 61 74 65 64 3a | 20 46 72 69 20 4d 61 72 |created:| Fri Mar|
|000004d0| 20 20 39 20 32 32 3a 30 | 39 3a 30 33 20 31 39 39 | 9 22:0|9:03 199|
|000004e0| 30 0a 23 20 42 79 3a 09 | 4a 6f 68 6e 20 46 2e 20 |0.# By:.|John F. |
|000004f0| 48 61 75 67 68 20 49 49 | 20 28 52 69 76 65 72 20 |Haugh II| (River |
|00000500| 50 61 72 69 73 68 65 73 | 20 50 72 6f 67 72 61 6d |Parishes| Program|
|00000510| 6d 69 6e 67 2c 20 41 75 | 73 74 69 6e 20 54 58 29 |ming, Au|stin TX)|
|00000520| 0a 65 78 70 6f 72 74 20 | 50 41 54 48 3b 20 50 41 |.export |PATH; PA|
|00000530| 54 48 3d 2f 62 69 6e 3a | 2f 75 73 72 2f 62 69 6e |TH=/bin:|/usr/bin|
|00000540| 3a 24 50 41 54 48 0a 69 | 66 20 74 65 73 74 20 2d |:$PATH.i|f test -|
|00000550| 66 20 27 52 45 41 44 4d | 45 27 0a 74 68 65 6e 0a |f 'READM|E'.then.|
|00000560| 09 65 63 68 6f 20 73 68 | 61 72 3a 20 22 77 69 6c |.echo sh|ar: "wil|
|00000570| 6c 20 6e 6f 74 20 6f 76 | 65 72 2d 77 72 69 74 65 |l not ov|er-write|
|00000580| 20 65 78 69 73 74 69 6e | 67 20 66 69 6c 65 20 27 | existin|g file '|
|00000590| 52 45 41 44 4d 45 27 22 | 0a 65 6c 73 65 0a 63 61 |README'"|.else.ca|
|000005a0| 74 20 3c 3c 20 5c 53 48 | 41 52 5f 45 4f 46 20 3e |t << \SH|AR_EOF >|
|000005b0| 20 27 52 45 41 44 4d 45 | 27 0a 3e 20 5b 2e 2e 20 | 'README|'.> [.. |
|000005c0| 69 6e 20 72 65 70 6c 79 | 20 74 6f 20 61 20 6c 65 |in reply| to a le|
|000005d0| 74 74 65 72 20 74 6f 20 | 4d 69 6b 65 20 61 62 6f |tter to |Mike abo|
|000005e0| 75 74 20 22 6f 66 69 6c | 65 73 22 20 2e 2e 5d 0a |ut "ofil|es" ..].|
|000005f0| 3e 20 0a 3e 20 57 65 6c | 6c 2c 20 49 20 72 65 63 |> .> Wel|l, I rec|
|00000600| 65 6e 74 6c 79 20 72 61 | 6e 20 61 63 72 6f 73 73 |ently ra|n across|
|00000610| 20 61 20 70 6f 73 74 69 | 6e 67 20 6f 66 20 73 6f | a posti|ng of so|
|00000620| 6d 65 74 68 69 6e 67 20 | 63 61 6c 6c 65 64 20 22 |mething |called "|
|00000630| 6f 66 69 6c 65 73 22 20 | 66 6f 72 0a 3e 20 42 53 |ofiles" |for.> BS|
|00000640| 44 2c 20 61 6e 64 20 72 | 65 6d 65 6d 62 65 72 69 |D, and r|ememberi|
|00000650| 6e 67 20 79 6f 75 72 20 | 6d 65 73 73 61 67 65 2c |ng your |message,|
|00000660| 20 49 20 64 65 63 69 64 | 65 64 20 74 6f 20 73 65 | I decid|ed to se|
|00000670| 65 20 69 66 20 69 74 20 | 70 6f 72 74 65 64 0a 3e |e if it |ported.>|
|00000680| 20 65 61 73 69 6c 79 20 | 74 6f 20 74 68 65 20 55 | easily |to the U|
|00000690| 6e 69 78 20 50 43 2e 20 | 20 49 74 20 64 69 64 2c |nix PC. | It did,|
|000006a0| 20 61 6e 64 20 68 65 72 | 65 20 69 74 20 69 73 2c | and her|e it is,|
|000006b0| 20 61 6c 74 68 6f 75 67 | 68 20 69 74 20 64 6f 65 | althoug|h it doe|
|000006c0| 73 6e 27 74 0a 3e 20 73 | 65 65 6d 20 74 6f 20 65 |sn't.> s|eem to e|
|000006d0| 78 61 63 74 6c 79 20 66 | 69 74 20 79 6f 75 72 20 |xactly f|it your |
|000006e0| 64 65 73 63 72 69 70 74 | 69 6f 6e 2e 20 20 49 74 |descript|ion. It|
|000006f0| 20 73 65 65 6d 73 20 74 | 6f 20 62 65 20 6a 75 73 | seems t|o be jus|
|00000700| 74 20 61 20 22 66 75 73 | 65 72 22 0a 3e 20 70 72 |t a "fus|er".> pr|
|00000710| 6f 67 72 61 6d 20 77 69 | 74 68 20 73 6c 69 67 68 |ogram wi|th sligh|
|00000720| 74 6c 79 20 66 61 6e 63 | 69 65 72 20 6f 75 74 70 |tly fanc|ier outp|
|00000730| 75 74 2e 0a 3e 20 0a 3e | 20 48 65 72 65 27 73 20 |ut..> .>| Here's |
|00000740| 74 68 65 20 42 53 44 20 | 76 65 72 73 69 6f 6e 20 |the BSD |version |
|00000750| 61 6e 64 20 74 68 65 20 | 55 6e 69 78 20 50 43 20 |and the |Unix PC |
|00000760| 76 65 72 73 69 6f 6e 2e | 20 20 49 66 20 79 6f 75 |version.| If you|
|00000770| 20 63 61 6e 20 74 72 61 | 63 6b 20 64 6f 77 6e 0a | can tra|ck down.|
|00000780| 3e 20 74 68 65 20 70 72 | 6f 67 72 61 6d 20 79 6f |> the pr|ogram yo|
|00000790| 75 20 77 65 72 65 20 74 | 61 6c 6b 69 6e 67 20 61 |u were t|alking a|
|000007a0| 62 6f 75 74 2c 20 49 27 | 64 20 6c 69 6b 65 20 74 |bout, I'|d like t|
|000007b0| 6f 20 73 65 65 20 69 74 | 2e 0a 3e 20 0a 3e 20 09 |o see it|..> .> .|
|000007c0| 09 09 09 09 2d 3d 5d 20 | 46 6f 72 64 20 5b 3d 2d |....-=] |Ford [=-|
|000007d0| 0a 3e 20 0a 3e 20 22 54 | 68 65 20 6e 75 6d 62 65 |.> .> "T|he numbe|
|000007e0| 72 20 6f 66 20 55 6e 69 | 78 20 69 6e 73 74 61 6c |r of Uni|x instal|
|000007f0| 6c 61 74 69 6f 6e 73 09 | 28 49 6e 20 52 65 61 6c |lations.|(In Real|
|00000800| 20 4c 69 66 65 3a 20 20 | 4d 69 6b 65 20 44 69 74 | Life: |Mike Dit|
|00000810| 74 6f 29 0a 3e 20 68 61 | 73 20 67 72 6f 77 6e 20 |to).> ha|s grown |
|00000820| 74 6f 20 31 30 2c 20 77 | 69 74 68 20 6d 6f 72 65 |to 10, w|ith more|
|00000830| 20 65 78 70 65 63 74 65 | 64 2e 22 09 66 6f 72 64 | expecte|d.".ford|
|00000840| 40 6b 65 6e 6f 62 69 2e | 63 74 73 2e 63 6f 6d 0a |@kenobi.|cts.com.|
|00000850| 3e 20 2d 20 54 68 65 20 | 55 6e 69 78 20 50 72 6f |> - The |Unix Pro|
|00000860| 67 72 61 6d 6d 65 72 27 | 73 20 4d 61 6e 75 61 6c |grammer'|s Manual|
|00000870| 2c 09 09 2e 2e 2e 21 73 | 64 63 73 76 61 78 21 63 |,.....!s|dcsvax!c|
|00000880| 72 61 73 68 21 65 6c 67 | 61 72 21 66 6f 72 64 0a |rash!elg|ar!ford.|
|00000890| 3e 20 20 20 32 6e 64 20 | 45 64 69 74 69 6f 6e 2c |> 2nd |Edition,|
|000008a0| 20 4a 75 6e 65 2c 20 31 | 39 37 32 2e 09 09 64 69 | June, 1|972...di|
|000008b0| 74 74 6f 40 63 62 6d 76 | 61 78 2e 63 6f 6d 6d 6f |tto@cbmv|ax.commo|
|000008c0| 64 6f 72 65 2e 63 6f 6d | 0a 0a 49 20 68 61 63 6b |dore.com|..I hack|
|000008d0| 65 64 20 6f 6e 20 74 68 | 69 73 20 74 6f 20 70 72 |ed on th|is to pr|
|000008e0| 6f 64 75 63 65 20 61 20 | 76 65 72 73 69 6f 6e 20 |oduce a |version |
|000008f0| 77 68 69 63 68 20 72 75 | 6e 73 20 6f 6e 20 53 43 |which ru|ns on SC|
|00000900| 4f 20 58 65 6e 69 78 2f | 33 38 36 20 32 2e 32 2e |O Xenix/|386 2.2.|
|00000910| 33 2e 0a 54 68 65 20 62 | 69 67 67 65 73 74 20 63 |3..The b|iggest c|
|00000920| 68 61 6e 67 65 73 20 69 | 6e 76 6f 6c 76 65 64 20 |hanges i|nvolved |
|00000930| 64 65 61 6c 69 6e 67 20 | 77 69 74 68 20 74 68 65 |dealing |with the|
|00000940| 20 66 6c 6f 61 74 69 6e | 67 20 73 74 72 75 63 74 | floatin|g struct|
|00000950| 75 72 65 73 20 69 6e 20 | 55 4e 49 58 0a 66 6f 72 |ures in |UNIX.for|
|00000960| 20 74 68 65 20 33 42 31 | 2e 20 20 53 74 72 61 6e | the 3B1|. Stran|
|00000970| 67 65 20 6d 61 63 68 69 | 6e 65 20 2e 2e 2e 0a 0a |ge machi|ne .....|
|00000980| 49 20 61 64 64 65 64 20 | 63 6f 64 65 20 74 6f 20 |I added |code to |
|00000990| 6c 6f 63 61 74 65 20 74 | 68 65 20 69 6e 6f 64 65 |locate t|he inode|
|000009a0| 20 66 6f 72 20 74 68 65 | 20 74 65 78 74 20 74 61 | for the| text ta|
|000009b0| 62 6c 65 20 65 6e 74 72 | 79 2c 20 69 66 20 74 68 |ble entr|y, if th|
|000009c0| 65 20 70 72 6f 63 65 73 | 73 0a 73 74 72 75 63 74 |e proces|s.struct|
|000009d0| 75 72 65 20 69 6e 64 69 | 63 61 74 65 64 20 6f 6e |ure indi|cated on|
|000009e0| 65 20 65 78 69 73 74 65 | 64 2e 20 20 54 68 69 73 |e existe|d. This|
|000009f0| 20 70 72 69 6e 74 73 20 | 61 73 20 61 6e 20 27 78 | prints |as an 'x|
|00000a00| 27 20 63 68 61 72 61 63 | 74 65 72 2e 20 20 49 20 |' charac|ter. I |
|00000a10| 61 6c 73 6f 0a 61 64 64 | 65 64 20 73 65 74 75 69 |also.add|ed setui|
|00000a20| 64 28 29 20 63 61 6c 6c | 73 20 61 72 6f 75 6e 64 |d() call|s around|
|00000a30| 20 74 68 65 20 6f 70 65 | 6e 73 20 6f 66 20 74 68 | the ope|ns of th|
|00000a40| 65 20 64 65 76 69 63 65 | 20 66 69 6c 65 73 20 77 |e device| files w|
|00000a50| 68 69 63 68 20 72 65 71 | 75 69 72 65 64 0a 72 6f |hich req|uired.ro|
|00000a60| 6f 74 20 70 72 69 76 69 | 6c 65 67 65 2e 20 20 59 |ot privi|lege. Y|
|00000a70| 65 73 2c 20 69 74 20 77 | 61 73 20 70 6f 73 73 69 |es, it w|as possi|
|00000a80| 62 6c 65 20 74 6f 20 69 | 6e 73 74 61 6c 6c 20 74 |ble to i|nstall t|
|00000a90| 68 69 73 20 70 72 6f 67 | 72 61 6d 20 61 73 20 53 |his prog|ram as S|
|00000aa0| 55 49 44 20 72 6f 6f 74 | 0a 61 6e 64 20 68 61 76 |UID root|.and hav|
|00000ab0| 65 20 61 6e 79 6f 6e 65 | 20 62 65 20 61 62 6c 65 |e anyone| be able|
|00000ac0| 20 74 6f 20 64 65 74 65 | 72 6d 69 6e 65 20 74 68 | to dete|rmine th|
|00000ad0| 65 20 73 74 61 74 75 73 | 20 6f 66 20 61 6e 79 20 |e status| of any |
|00000ae0| 66 69 6c 65 20 6f 6e 20 | 74 68 65 20 73 79 73 74 |file on |the syst|
|00000af0| 65 6d 2c 0a 65 76 65 6e | 20 69 66 20 74 68 65 20 |em,.even| if the |
|00000b00| 75 73 65 72 20 77 6f 75 | 6c 64 20 6e 6f 74 20 6e |user wou|ld not n|
|00000b10| 6f 72 6d 61 6c 6c 79 20 | 68 61 76 65 20 61 63 63 |ormally |have acc|
|00000b20| 65 73 73 20 74 6f 20 74 | 68 61 74 20 66 69 6c 65 |ess to t|hat file|
|00000b30| 2e 20 20 4e 6f 74 20 65 | 78 61 63 74 6c 79 0a 61 |. Not e|xactly.a|
|00000b40| 20 67 6f 6f 64 20 69 64 | 65 61 20 2e 2e 2e 0a 0a | good id|ea .....|
|00000b50| 54 68 65 20 63 6f 64 65 | 20 68 61 73 20 68 61 64 |The code| has had|
|00000b60| 20 61 6c 6c 20 6f 66 20 | 74 68 65 20 33 42 31 20 | all of |the 3B1 |
|00000b70| 64 65 70 65 6e 64 65 6e | 74 20 74 68 69 6e 67 73 |dependen|t things|
|00000b80| 20 72 65 6d 6f 76 65 64 | 20 61 6e 64 20 61 20 6c | removed| and a l|
|00000b90| 69 74 74 6c 65 0a 73 70 | 72 69 6e 67 20 63 6c 65 |ittle.sp|ring cle|
|00000ba0| 61 6e 69 6e 67 20 61 70 | 70 6c 69 65 64 2e 0a 0a |aning ap|plied...|
|00000bb0| 2d 20 4a 6f 68 6e 2e 0a | 2d 2d 0a 4a 6f 68 6e 20 |- John..|--.John |
|00000bc0| 46 2e 20 48 61 75 67 68 | 20 49 49 20 20 20 20 20 |F. Haugh| II |
|00000bd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000be0| 20 20 20 20 20 20 20 20 | 55 55 43 50 3a 20 2e 2e | |UUCP: ..|
|00000bf0| 2e 21 63 73 2e 75 74 65 | 78 61 73 2e 65 64 75 21 |.!cs.ute|xas.edu!|
|00000c00| 72 70 70 33 38 36 21 6a | 66 68 0a 22 41 20 66 72 |rpp386!j|fh."A fr|
|00000c10| 69 65 6e 64 20 6f 66 20 | 42 49 46 46 27 53 20 66 |iend of |BIFF'S f|
|00000c20| 6f 72 20 61 20 66 69 66 | 74 68 20 6f 66 20 61 20 |or a fif|th of a |
|00000c30| 79 65 61 72 22 20 20 20 | 20 20 20 20 20 44 6f 6d |year" | Dom|
|00000c40| 61 69 6e 3a 20 6a 66 68 | 40 72 70 70 33 38 36 2e |ain: jfh|@rpp386.|
|00000c50| 63 61 63 74 75 73 2e 6f | 72 67 0a 53 48 41 52 5f |cactus.o|rg.SHAR_|
|00000c60| 45 4f 46 0a 66 69 0a 69 | 66 20 74 65 73 74 20 2d |EOF.fi.i|f test -|
|00000c70| 66 20 27 4d 61 6b 65 66 | 69 6c 65 27 0a 74 68 65 |f 'Makef|ile'.the|
|00000c80| 6e 0a 09 65 63 68 6f 20 | 73 68 61 72 3a 20 22 77 |n..echo |shar: "w|
|00000c90| 69 6c 6c 20 6e 6f 74 20 | 6f 76 65 72 2d 77 72 69 |ill not |over-wri|
|00000ca0| 74 65 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |te exist|ing file|
|00000cb0| 20 27 4d 61 6b 65 66 69 | 6c 65 27 22 0a 65 6c 73 | 'Makefi|le'".els|
|00000cc0| 65 0a 63 61 74 20 3c 3c | 20 5c 53 48 41 52 5f 45 |e.cat <<| \SHAR_E|
|00000cd0| 4f 46 20 3e 20 27 4d 61 | 6b 65 66 69 6c 65 27 0a |OF > 'Ma|kefile'.|
|00000ce0| 23 0a 23 20 4d 61 6b 65 | 66 69 6c 65 20 74 6f 20 |#.# Make|file to |
|00000cf0| 63 6f 6d 70 69 6c 65 20 | 6f 66 69 6c 65 73 2e 63 |compile |ofiles.c|
|00000d00| 20 20 28 4f 70 65 6e 20 | 46 69 6c 65 73 29 0a 23 | (Open |Files).#|
|00000d10| 20 50 6f 72 74 20 66 72 | 6f 6d 20 42 53 44 20 6f | Port fr|om BSD o|
|00000d20| 66 69 6c 65 73 20 64 6f | 6e 65 20 62 79 20 4d 69 |files do|ne by Mi|
|00000d30| 6b 65 20 2d 3d 5d 46 6f | 72 64 5b 3d 2d 20 44 69 |ke -=]Fo|rd[=- Di|
|00000d40| 74 74 6f 20 0a 23 20 50 | 6f 72 74 20 66 72 6f 6d |tto .# P|ort from|
|00000d50| 20 55 4e 49 58 20 50 43 | 20 6f 66 69 6c 65 73 20 | UNIX PC| ofiles |
|00000d60| 64 6f 6e 65 20 62 79 20 | 4a 6f 68 6e 20 46 2e 20 |done by |John F. |
|00000d70| 48 61 75 67 68 20 49 49 | 20 28 6a 66 68 40 72 70 |Haugh II| (jfh@rp|
|00000d80| 70 33 38 36 2e 63 61 63 | 74 75 73 2e 6f 72 67 29 |p386.cac|tus.org)|
|00000d90| 0a 23 20 4d 61 6b 65 66 | 69 6c 65 20 63 6f 6e 74 |.# Makef|ile cont|
|00000da0| 72 69 62 75 74 65 64 20 | 62 79 20 4c 65 6e 6e 79 |ributed |by Lenny|
|00000db0| 20 54 72 6f 70 69 61 6e | 6f 0a 23 0a 23 20 4e 4f | Tropian|o.#.# NO|
|00000dc0| 54 45 3a 20 49 66 20 79 | 6f 75 20 64 6f 6e 27 74 |TE: If y|ou don't|
|00000dd0| 20 77 61 6e 74 20 74 68 | 69 73 20 70 72 6f 67 72 | want th|is progr|
|00000de0| 61 6d 20 69 6e 73 74 61 | 6c 6c 65 64 20 73 65 74 |am insta|lled set|
|00000df0| 75 69 64 2c 20 73 6f 20 | 61 6e 79 6f 6e 65 20 63 |uid, so |anyone c|
|00000e00| 61 6e 20 75 73 65 20 69 | 74 2c 0a 23 20 20 20 20 |an use i|t,.# |
|00000e10| 20 20 20 6d 6f 64 69 66 | 79 20 74 68 65 20 22 6d | modif|y the "m|
|00000e20| 61 6b 65 20 69 6e 73 74 | 61 6c 6c 22 20 64 65 70 |ake inst|all" dep|
|00000e30| 65 6e 64 65 6e 63 79 20 | 77 69 74 68 20 74 68 65 |endency |with the|
|00000e40| 20 70 65 72 6d 69 73 73 | 69 6f 6e 20 79 6f 75 20 | permiss|ion you |
|00000e50| 77 61 6e 74 20 74 6f 0a | 23 09 67 72 61 6e 74 2e |want to.|#.grant.|
|00000e60| 20 20 53 65 65 20 74 68 | 65 20 52 45 41 44 4d 45 | See th|e README|
|00000e70| 20 66 6f 72 20 6d 6f 72 | 65 20 69 6e 66 6f 72 6d | for mor|e inform|
|00000e80| 61 74 69 6f 6e 2e 0a 23 | 0a 23 20 53 43 4f 20 58 |ation..#|.# SCO X|
|00000e90| 45 4e 49 58 2f 33 38 36 | 0a 44 45 42 55 47 20 3d |ENIX/386|.DEBUG =|
|00000ea0| 20 0a 43 46 4c 41 47 53 | 20 3d 20 2d 4f 78 20 24 | .CFLAGS| = -Ox $|
|00000eb0| 28 44 45 42 55 47 29 0a | 4c 44 46 4c 41 47 53 20 |(DEBUG).|LDFLAGS |
|00000ec0| 3d 20 24 28 44 45 42 55 | 47 29 0a 23 0a 44 45 53 |= $(DEBU|G).#.DES|
|00000ed0| 54 20 3d 20 2f 75 73 72 | 2f 6c 6f 63 61 6c 2f 62 |T = /usr|/local/b|
|00000ee0| 69 6e 0a 23 0a 6f 66 69 | 6c 65 73 3a 20 20 6f 66 |in.#.ofi|les: of|
|00000ef0| 69 6c 65 73 2e 6f 0a 09 | 24 28 43 43 29 20 24 28 |iles.o..|$(CC) $(|
|00000f00| 4c 44 46 4c 41 47 53 29 | 20 2d 6f 20 6f 66 69 6c |LDFLAGS)| -o ofil|
|00000f10| 65 73 20 6f 66 69 6c 65 | 73 2e 6f 20 24 28 4c 49 |es ofile|s.o $(LI|
|00000f20| 42 53 29 20 0a 23 0a 23 | 20 59 6f 75 20 6e 65 65 |BS) .#.#| You nee|
|00000f30| 64 20 74 6f 20 62 65 20 | 73 75 70 65 72 2d 75 73 |d to be |super-us|
|00000f40| 65 72 20 74 6f 20 64 6f | 20 74 68 69 73 2e 0a 23 |er to do| this..#|
|00000f50| 0a 69 6e 73 74 61 6c 6c | 3a 20 6f 66 69 6c 65 73 |.install|: ofiles|
|00000f60| 20 24 28 44 45 53 54 29 | 0a 09 63 70 20 6f 66 69 | $(DEST)|..cp ofi|
|00000f70| 6c 65 73 20 24 28 44 45 | 53 54 29 2f 6f 66 69 6c |les $(DE|ST)/ofil|
|00000f80| 65 73 0a 09 63 68 6f 77 | 6e 20 72 6f 6f 74 20 24 |es..chow|n root $|
|00000f90| 28 44 45 53 54 29 2f 6f | 66 69 6c 65 73 0a 09 63 |(DEST)/o|files..c|
|00000fa0| 68 67 72 70 20 62 69 6e | 20 20 24 28 44 45 53 54 |hgrp bin| $(DEST|
|00000fb0| 29 2f 6f 66 69 6c 65 73 | 0a 09 63 68 6d 6f 64 20 |)/ofiles|..chmod |
|00000fc0| 34 31 31 31 20 24 28 44 | 45 53 54 29 2f 6f 66 69 |4111 $(D|EST)/ofi|
|00000fd0| 6c 65 73 0a 0a 63 6c 65 | 61 6e 3a 0a 09 72 6d 20 |les..cle|an:..rm |
|00000fe0| 2d 66 20 63 6f 72 65 20 | 61 2e 6f 75 74 20 6f 66 |-f core |a.out of|
|00000ff0| 69 6c 65 73 2e 6f 0a 0a | 63 6c 6f 62 62 65 72 3a |iles.o..|clobber:|
|00001000| 20 63 6c 65 61 6e 0a 09 | 72 6d 20 2d 66 20 6f 66 | clean..|rm -f of|
|00001010| 69 6c 65 73 0a 0a 6f 66 | 69 6c 65 73 2e 73 68 61 |iles..of|iles.sha|
|00001020| 72 3a 09 52 45 41 44 4d | 45 20 4d 61 6b 65 66 69 |r:.READM|E Makefi|
|00001030| 6c 65 20 6f 66 69 6c 65 | 73 2e 63 0a 09 73 68 61 |le ofile|s.c..sha|
|00001040| 72 20 52 45 41 44 4d 45 | 20 4d 61 6b 65 66 69 6c |r README| Makefil|
|00001050| 65 20 6f 66 69 6c 65 73 | 2e 63 20 3e 20 6f 66 69 |e ofiles|.c > ofi|
|00001060| 6c 65 73 2e 73 68 61 72 | 0a 0a 73 68 61 72 3a 09 |les.shar|..shar:.|
|00001070| 6f 66 69 6c 65 73 2e 73 | 68 61 72 0a 0a 53 48 41 |ofiles.s|har..SHA|
|00001080| 52 5f 45 4f 46 0a 66 69 | 0a 69 66 20 74 65 73 74 |R_EOF.fi|.if test|
|00001090| 20 2d 66 20 27 6f 66 69 | 6c 65 73 2e 63 27 0a 74 | -f 'ofi|les.c'.t|
|000010a0| 68 65 6e 0a 09 65 63 68 | 6f 20 73 68 61 72 3a 20 |hen..ech|o shar: |
|000010b0| 22 77 69 6c 6c 20 6e 6f | 74 20 6f 76 65 72 2d 77 |"will no|t over-w|
|000010c0| 72 69 74 65 20 65 78 69 | 73 74 69 6e 67 20 66 69 |rite exi|sting fi|
|000010d0| 6c 65 20 27 6f 66 69 6c | 65 73 2e 63 27 22 0a 65 |le 'ofil|es.c'".e|
|000010e0| 6c 73 65 0a 63 61 74 20 | 3c 3c 20 5c 53 48 41 52 |lse.cat |<< \SHAR|
|000010f0| 5f 45 4f 46 20 3e 20 27 | 6f 66 69 6c 65 73 2e 63 |_EOF > '|ofiles.c|
|00001100| 27 0a 2f 2a 20 0a 20 2a | 20 55 4e 49 58 20 50 43 |'./* . *| UNIX PC|
|00001110| 20 50 6f 72 74 20 70 72 | 6f 67 72 61 6d 6d 65 64 | Port pr|ogrammed|
|00001120| 20 62 79 20 4d 69 6b 65 | 20 2d 3d 5d 46 6f 72 64 | by Mike| -=]Ford|
|00001130| 5b 3d 2d 20 44 69 74 74 | 6f 20 28 64 69 74 74 6f |[=- Ditt|o (ditto|
|00001140| 40 63 62 6d 76 61 78 2e | 63 6f 6d 6d 6f 64 6f 72 |@cbmvax.|commodor|
|00001150| 65 2e 63 6f 6d 29 0a 20 | 2a 0a 20 2a 20 53 43 4f |e.com). |*. * SCO|
|00001160| 20 58 45 4e 49 58 2f 33 | 38 36 20 50 6f 72 74 20 | XENIX/3|86 Port |
|00001170| 70 72 6f 67 72 61 6d 6d | 65 64 20 62 79 20 4a 6f |programm|ed by Jo|
|00001180| 68 6e 20 46 2e 20 48 61 | 75 67 68 20 49 49 20 28 |hn F. Ha|ugh II (|
|00001190| 6a 66 68 40 72 70 70 33 | 38 36 2e 63 61 63 74 75 |jfh@rpp3|86.cactu|
|000011a0| 73 2e 6f 72 67 29 0a 20 | 2a 2f 0a 0a 23 69 66 6e |s.org). |*/..#ifn|
|000011b0| 64 65 66 20 6c 69 6e 74 | 0a 73 74 61 74 69 63 20 |def lint|.static |
|000011c0| 63 68 61 72 20 72 63 73 | 69 64 5b 5d 3d 22 24 48 |char rcs|id[]="$H|
|000011d0| 65 61 64 65 72 3a 20 6f | 66 69 6c 65 73 2e 63 2c |eader: o|files.c,|
|000011e0| 76 20 31 2e 31 20 38 35 | 2f 30 35 2f 30 33 20 30 |v 1.1 85|/05/03 0|
|000011f0| 36 3a 34 39 3a 31 39 20 | 63 73 70 65 6e 63 65 72 |6:49:19 |cspencer|
|00001200| 20 45 78 70 20 24 22 3b | 0a 23 65 6e 64 69 66 20 | Exp $";|.#endif |
|00001210| 6c 69 6e 74 0a 23 69 6e | 63 6c 75 64 65 20 3c 73 |lint.#in|clude <s|
|00001220| 79 73 2f 70 61 72 61 6d | 2e 68 3e 0a 23 69 6e 63 |ys/param|.h>.#inc|
|00001230| 6c 75 64 65 20 3c 73 79 | 73 2f 64 69 72 2e 68 3e |lude <sy|s/dir.h>|
|00001240| 0a 23 64 65 66 69 6e 65 | 20 4b 45 52 4e 45 4c 0a |.#define| KERNEL.|
|00001250| 23 69 6e 63 6c 75 64 65 | 20 3c 73 79 73 2f 66 69 |#include| <sys/fi|
|00001260| 6c 65 2e 68 3e 0a 23 75 | 6e 64 65 66 20 4b 45 52 |le.h>.#u|ndef KER|
|00001270| 4e 45 4c 0a 23 69 6e 63 | 6c 75 64 65 20 3c 73 79 |NEL.#inc|lude <sy|
|00001280| 73 2f 74 65 78 74 2e 68 | 3e 0a 23 69 6e 63 6c 75 |s/text.h|>.#inclu|
|00001290| 64 65 20 3c 73 79 73 2f | 69 6e 6f 64 65 2e 68 3e |de <sys/|inode.h>|
|000012a0| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 73 79 73 2f 75 |.#includ|e <sys/u|
|000012b0| 73 65 72 2e 68 3e 0a 23 | 69 6e 63 6c 75 64 65 20 |ser.h>.#|include |
|000012c0| 3c 73 79 73 2f 70 72 6f | 63 2e 68 3e 0a 23 69 6e |<sys/pro|c.h>.#in|
|000012d0| 63 6c 75 64 65 20 3c 73 | 79 73 2f 73 74 61 74 2e |clude <s|ys/stat.|
|000012e0| 68 3e 0a 23 69 6e 63 6c | 75 64 65 20 3c 73 79 73 |h>.#incl|ude <sys|
|000012f0| 2f 73 79 73 6d 61 63 72 | 6f 73 2e 68 3e 0a 23 69 |/sysmacr|os.h>.#i|
|00001300| 6e 63 6c 75 64 65 20 3c | 70 77 64 2e 68 3e 0a 23 |nclude <|pwd.h>.#|
|00001310| 69 6e 63 6c 75 64 65 20 | 3c 73 79 73 2f 76 61 72 |include |<sys/var|
|00001320| 2e 68 3e 0a 23 69 6e 63 | 6c 75 64 65 20 3c 73 74 |.h>.#inc|lude <st|
|00001330| 64 69 6f 2e 68 3e 0a 23 | 69 6e 63 6c 75 64 65 20 |dio.h>.#|include |
|00001340| 3c 66 63 6e 74 6c 2e 68 | 3e 0a 0a 0a 23 64 65 66 |<fcntl.h|>...#def|
|00001350| 69 6e 65 20 43 44 49 52 | 09 30 31 0a 23 64 65 66 |ine CDIR|.01.#def|
|00001360| 69 6e 65 20 4f 46 49 4c | 45 09 30 32 0a 23 64 65 |ine OFIL|E.02.#de|
|00001370| 66 69 6e 65 20 52 44 49 | 52 09 30 34 0a 23 64 65 |fine RDI|R.04.#de|
|00001380| 66 69 6e 65 09 58 46 49 | 4c 45 09 30 31 30 0a 0a |fine.XFI|LE.010..|
|00001390| 0a 6c 6f 6e 67 20 65 73 | 65 65 6b 28 29 3b 0a 6c |.long es|eek();.l|
|000013a0| 6f 6e 67 20 6c 73 65 65 | 6b 28 29 3b 0a 0a 69 6e |ong lsee|k();..in|
|000013b0| 74 20 6e 70 72 6f 63 3b | 09 09 2f 2a 20 6e 75 6d |t nproc;|../* num|
|000013c0| 62 65 72 20 6f 66 20 65 | 6e 74 72 69 65 73 20 69 |ber of e|ntries i|
|000013d0| 6e 20 70 72 6f 63 20 74 | 61 62 6c 65 20 09 09 2a |n proc t|able ..*|
|000013e0| 2f 0a 69 6e 74 20 6d 65 | 6d 3b 09 09 2f 2a 20 66 |/.int me|m;../* f|
|000013f0| 64 20 66 6f 72 20 2f 64 | 65 76 2f 6d 65 6d 09 09 |d for /d|ev/mem..|
|00001400| 09 09 2a 2f 0a 69 6e 74 | 20 6b 6d 65 6d 3b 09 09 |..*/.int| kmem;..|
|00001410| 2f 2a 20 66 64 20 66 6f | 72 20 2f 64 65 76 2f 6b |/* fd fo|r /dev/k|
|00001420| 6d 65 6d 09 09 09 09 2a | 2f 0a 69 6e 74 20 73 77 |mem....*|/.int sw|
|00001430| 61 70 3b 09 09 2f 2a 20 | 66 64 20 66 6f 72 20 2f |ap;../* |fd for /|
|00001440| 64 65 76 2f 73 77 61 70 | 09 09 09 09 2a 2f 0a 0a |dev/swap|....*/..|
|00001450| 69 6e 74 20 70 69 64 73 | 5f 6f 6e 6c 79 20 3d 20 |int pids|_only = |
|00001460| 30 3b 09 2f 2a 20 69 66 | 20 6e 6f 6e 2d 7a 65 72 |0;./* if| non-zer|
|00001470| 6f 2c 20 6f 6e 6c 79 20 | 6f 75 74 70 75 74 20 70 |o, only |output p|
|00001480| 72 6f 63 65 73 73 20 69 | 64 73 09 2a 2f 0a 0a 63 |rocess i|ds.*/..c|
|00001490| 68 61 72 20 2a 70 72 6f | 67 6e 61 6d 65 3b 0a 73 |har *pro|gname;.s|
|000014a0| 74 72 75 63 74 20 6e 6c | 69 73 74 20 75 6e 69 78 |truct nl|ist unix|
|000014b0| 5f 6e 6c 5b 5d 20 3d 20 | 7b 0a 23 64 65 66 69 6e |_nl[] = |{.#defin|
|000014c0| 65 20 58 5f 50 52 4f 43 | 09 09 30 0a 09 7b 22 5f |e X_PROC|..0..{"_|
|000014d0| 70 72 6f 63 22 7d 2c 0a | 23 64 65 66 69 6e 65 20 |proc"},.|#define |
|000014e0| 58 5f 56 41 52 20 09 09 | 31 0a 09 7b 22 5f 76 22 |X_VAR ..|1..{"_v"|
|000014f0| 7d 2c 0a 09 7b 30 7d 0a | 7d 3b 0a 0a 6d 61 69 6e |},..{0}.|};..main|
|00001500| 28 61 72 67 63 2c 20 61 | 72 67 76 29 0a 69 6e 74 |(argc, a|rgv).int|
|00001510| 20 09 61 72 67 63 3b 0a | 63 68 61 72 09 2a 61 72 | .argc;.|char.*ar|
|00001520| 67 76 5b 5d 3b 0a 7b 0a | 09 69 6e 74 09 72 75 69 |gv[];.{.|.int.rui|
|00001530| 64 20 3d 20 67 65 74 75 | 69 64 20 28 29 3b 0a 09 |d = getu|id ();..|
|00001540| 69 6e 74 09 65 75 69 64 | 20 3d 20 67 65 74 65 75 |int.euid| = geteu|
|00001550| 69 64 20 28 29 3b 0a 09 | 73 74 72 75 63 74 20 69 |id ();..|struct i|
|00001560| 6e 6f 64 65 20 2a 69 2c | 2a 67 65 74 69 6e 6f 64 |node *i,|*getinod|
|00001570| 65 28 29 2c 20 2a 67 65 | 74 74 65 78 74 28 29 3b |e(), *ge|ttext();|
|00001580| 0a 09 73 74 72 75 63 74 | 20 73 74 61 74 20 73 3b |..struct| stat s;|
|00001590| 0a 09 73 74 72 75 63 74 | 20 75 73 65 72 20 2a 75 |..struct| user *u|
|000015a0| 2c 20 2a 67 65 74 75 73 | 65 72 28 29 3b 0a 09 73 |, *getus|er();..s|
|000015b0| 74 72 75 63 74 20 70 72 | 6f 63 20 70 3b 0a 09 72 |truct pr|oc p;..r|
|000015c0| 65 67 69 73 74 65 72 20 | 69 6e 74 20 66 69 6c 65 |egister |int file|
|000015d0| 6e 2c 20 66 6c 61 67 73 | 2c 20 70 72 6f 63 6e 3b |n, flags|, procn;|
|000015e0| 0a 09 72 65 67 69 73 74 | 65 72 20 63 68 61 72 20 |..regist|er char |
|000015f0| 2a 66 69 6c 65 6e 61 6d | 65 2c 20 2a 66 73 6e 61 |*filenam|e, *fsna|
|00001600| 6d 65 3b 0a 0a 09 70 72 | 6f 67 6e 61 6d 65 20 3d |me;...pr|ogname =|
|00001610| 20 61 72 67 76 5b 30 5d | 3b 0a 0a 09 69 66 28 61 | argv[0]|;...if(a|
|00001620| 72 67 63 20 3d 3d 20 31 | 29 20 7b 0a 09 09 66 70 |rgc == 1|) {...fp|
|00001630| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 22 75 73 |rintf(st|derr,"us|
|00001640| 61 67 65 3a 20 25 73 20 | 5b 2d 70 5d 20 66 69 6c |age: %s |[-p] fil|
|00001650| 65 73 5c 6e 22 2c 20 70 | 72 6f 67 6e 61 6d 65 29 |es\n", p|rogname)|
|00001660| 3b 0a 09 09 65 78 69 74 | 28 31 29 3b 0a 09 7d 0a |;...exit|(1);..}.|
|00001670| 0a 09 2f 2a 20 63 68 65 | 63 6b 20 66 6f 72 20 2d |../* che|ck for -|
|00001680| 70 20 66 6c 61 67 20 2a | 2f 0a 09 69 66 28 73 74 |p flag *|/..if(st|
|00001690| 72 63 6d 70 28 61 72 67 | 76 5b 31 5d 2c 22 2d 70 |rcmp(arg|v[1],"-p|
|000016a0| 22 29 20 3d 3d 20 30 29 | 20 7b 0a 09 09 09 70 69 |") == 0)| {....pi|
|000016b0| 64 73 5f 6f 6e 6c 79 2b | 2b 3b 0a 09 09 09 2d 2d |ds_only+|+;....--|
|000016c0| 61 72 67 63 3b 0a 09 09 | 09 2b 2b 61 72 67 76 3b |argc;...|.++argv;|
|000016d0| 0a 09 7d 0a 0a 09 73 65 | 74 75 69 64 20 28 65 75 |..}...se|tuid (eu|
|000016e0| 69 64 29 3b 09 2f 2a 20 | 67 65 74 20 61 6e 79 20 |id);./* |get any |
|000016f0| 53 55 49 44 20 70 72 69 | 76 69 6c 65 67 65 73 20 |SUID pri|vileges |
|00001700| 2a 2f 0a 0a 09 69 66 28 | 28 6d 65 6d 20 3d 20 6f |*/...if(|(mem = o|
|00001710| 70 65 6e 28 22 2f 64 65 | 76 2f 6d 65 6d 22 2c 20 |pen("/de|v/mem", |
|00001720| 4f 5f 52 44 4f 4e 4c 59 | 29 29 20 3c 20 30 29 0a |O_RDONLY|)) < 0).|
|00001730| 09 09 65 72 72 6f 72 28 | 22 63 61 6e 27 74 20 6f |..error(|"can't o|
|00001740| 70 65 6e 20 2f 64 65 76 | 2f 6d 65 6d 2e 20 22 29 |pen /dev|/mem. ")|
|00001750| 3b 0a 09 69 66 28 28 6b | 6d 65 6d 20 3d 20 6f 70 |;..if((k|mem = op|
|00001760| 65 6e 28 22 2f 64 65 76 | 2f 6b 6d 65 6d 22 2c 20 |en("/dev|/kmem", |
|00001770| 4f 5f 52 44 4f 4e 4c 59 | 29 29 20 3c 20 30 29 0a |O_RDONLY|)) < 0).|
|00001780| 09 09 65 72 72 6f 72 28 | 22 63 61 6e 27 74 20 6f |..error(|"can't o|
|00001790| 70 65 6e 20 2f 64 65 76 | 2f 6b 6d 65 6d 2e 20 22 |pen /dev|/kmem. "|
|000017a0| 29 3b 0a 09 69 66 28 28 | 73 77 61 70 20 3d 20 6f |);..if((|swap = o|
|000017b0| 70 65 6e 28 22 2f 64 65 | 76 2f 73 77 61 70 22 2c |pen("/de|v/swap",|
|000017c0| 20 4f 5f 52 44 4f 4e 4c | 59 29 29 20 3c 20 30 29 | O_RDONL|Y)) < 0)|
|000017d0| 20 0a 09 09 65 72 72 6f | 72 28 22 63 61 6e 27 74 | ...erro|r("can't|
|000017e0| 20 6f 70 65 6e 20 2f 64 | 65 76 2f 73 77 61 70 2e | open /d|ev/swap.|
|000017f0| 20 22 29 3b 0a 0a 09 73 | 65 74 75 69 64 20 28 72 | ");...s|etuid (r|
|00001800| 75 69 64 29 3b 09 2f 2a | 20 67 69 76 65 20 75 70 |uid);./*| give up|
|00001810| 20 61 6e 79 20 53 55 49 | 44 20 70 72 69 76 69 6c | any SUI|D privil|
|00001820| 65 67 65 73 20 2a 2f 0a | 0a 09 67 65 74 73 79 6d |eges */.|..getsym|
|00001830| 73 28 29 3b 0a 0a 09 77 | 68 69 6c 65 28 2d 2d 61 |s();...w|hile(--a|
|00001840| 72 67 63 29 20 7b 0a 09 | 09 66 69 6c 65 6e 61 6d |rgc) {..|.filenam|
|00001850| 65 20 3d 20 2a 2b 2b 61 | 72 67 76 3b 0a 09 09 66 |e = *++a|rgv;...f|
|00001860| 73 6e 61 6d 65 20 3d 20 | 22 22 3b 0a 0a 09 09 69 |sname = |"";....i|
|00001870| 66 28 73 74 61 74 28 66 | 69 6c 65 6e 61 6d 65 2c |f(stat(f|ilename,|
|00001880| 20 26 73 29 29 20 7b 0a | 09 09 09 66 70 72 69 6e | &s)) {.|...fprin|
|00001890| 74 66 28 73 74 64 65 72 | 72 2c 22 63 61 6e 27 74 |tf(stder|r,"can't|
|000018a0| 20 73 74 61 74 20 25 73 | 2e 20 22 2c 66 69 6c 65 | stat %s|. ",file|
|000018b0| 6e 61 6d 65 29 3b 0a 09 | 09 09 70 65 72 72 6f 72 |name);..|..perror|
|000018c0| 28 22 22 29 3b 0a 09 09 | 09 63 6f 6e 74 69 6e 75 |("");...|.continu|
|000018d0| 65 3b 0a 09 09 7d 0a 09 | 09 69 66 28 21 20 70 69 |e;...}..|.if(! pi|
|000018e0| 64 73 5f 6f 6e 6c 79 29 | 20 7b 0a 09 09 09 70 72 |ds_only)| {....pr|
|000018f0| 69 6e 74 66 28 22 25 73 | 5c 74 25 73 5c 6e 22 2c |intf("%s|\t%s\n",|
|00001900| 20 66 69 6c 65 6e 61 6d | 65 2c 66 73 6e 61 6d 65 | filenam|e,fsname|
|00001910| 29 3b 0a 09 09 09 70 72 | 69 6e 74 66 28 22 25 2d |);....pr|intf("%-|
|00001920| 38 2e 38 73 5c 74 50 49 | 44 5c 74 54 79 70 65 5c |8.8s\tPI|D\tType\|
|00001930| 74 43 6f 6d 6d 61 6e 64 | 5c 6e 22 2c 20 22 55 73 |tCommand|\n", "Us|
|00001940| 65 72 22 29 3b 0a 09 09 | 7d 0a 09 09 66 6f 72 28 |er");...|}...for(|
|00001950| 70 72 6f 63 6e 20 3d 20 | 30 3b 20 70 72 6f 63 6e |procn = |0; procn|
|00001960| 20 3c 20 6e 70 72 6f 63 | 3b 20 70 72 6f 63 6e 2b | < nproc|; procn+|
|00001970| 2b 29 7b 0a 09 09 09 70 | 72 6f 63 73 6c 6f 74 28 |+){....p|rocslot(|
|00001980| 70 72 6f 63 6e 2c 20 26 | 70 29 3b 0a 09 09 09 66 |procn, &|p);....f|
|00001990| 6c 61 67 73 20 3d 20 30 | 3b 0a 09 09 09 69 66 28 |lags = 0|;....if(|
|000019a0| 70 2e 70 5f 73 74 61 74 | 20 3d 3d 20 30 20 7c 7c |p.p_stat| == 0 |||
|000019b0| 20 70 2e 70 5f 73 74 61 | 74 20 3d 3d 20 53 5a 4f | p.p_sta|t == SZO|
|000019c0| 4d 42 29 0a 09 09 09 09 | 63 6f 6e 74 69 6e 75 65 |MB).....|continue|
|000019d0| 3b 0a 09 09 09 75 20 3d | 20 67 65 74 75 73 65 72 |;....u =| getuser|
|000019e0| 28 26 70 29 3b 0a 09 09 | 09 69 66 20 28 20 75 20 |(&p);...|.if ( u |
|000019f0| 3d 3d 20 28 73 74 72 75 | 63 74 20 75 73 65 72 20 |== (stru|ct user |
|00001a00| 2a 29 4e 55 4c 4c 29 0a | 09 09 09 09 63 6f 6e 74 |*)NULL).|....cont|
|00001a10| 69 6e 75 65 3b 0a 0a 09 | 09 09 69 66 20 28 28 69 |inue;...|..if ((i|
|00001a20| 20 3d 20 67 65 74 74 65 | 78 74 20 28 26 70 29 29 | = gette|xt (&p))|
|00001a30| 20 26 26 20 63 68 65 63 | 6b 28 26 73 2c 69 29 29 | && chec|k(&s,i))|
|00001a40| 0a 09 09 09 09 66 6c 61 | 67 73 20 7c 3d 20 58 46 |.....fla|gs |= XF|
|00001a50| 49 4c 45 3b 0a 0a 09 09 | 09 69 20 3d 20 67 65 74 |ILE;....|.i = get|
|00001a60| 69 6e 6f 64 65 28 75 2d | 3e 75 5f 72 64 69 72 2c |inode(u-|>u_rdir,|
|00001a70| 20 22 72 64 69 72 22 29 | 3b 0a 09 09 09 69 66 28 | "rdir")|;....if(|
|00001a80| 63 68 65 63 6b 28 26 73 | 2c 69 29 29 0a 09 09 09 |check(&s|,i))....|
|00001a90| 09 66 6c 61 67 73 20 7c | 3d 20 52 44 49 52 3b 0a |.flags ||= RDIR;.|
|00001aa0| 0a 09 09 09 69 20 3d 20 | 67 65 74 69 6e 6f 64 65 |....i = |getinode|
|00001ab0| 28 75 2d 3e 75 5f 63 64 | 69 72 2c 20 22 63 64 69 |(u->u_cd|ir, "cdi|
|00001ac0| 72 22 29 3b 0a 09 09 09 | 69 66 28 63 68 65 63 6b |r");....|if(check|
|00001ad0| 28 26 73 2c 69 29 29 0a | 09 09 09 09 66 6c 61 67 |(&s,i)).|....flag|
|00001ae0| 73 20 7c 3d 20 43 44 49 | 52 3b 0a 0a 09 09 09 66 |s |= CDI|R;.....f|
|00001af0| 6f 72 28 66 69 6c 65 6e | 20 3d 20 30 3b 20 66 69 |or(filen| = 0; fi|
|00001b00| 6c 65 6e 20 3c 20 4e 4f | 46 49 4c 45 3b 20 66 69 |len < NO|FILE; fi|
|00001b10| 6c 65 6e 2b 2b 29 20 7b | 0a 09 09 09 09 73 74 72 |len++) {|.....str|
|00001b20| 75 63 74 20 66 69 6c 65 | 20 66 3b 0a 0a 09 09 09 |uct file| f;.....|
|00001b30| 09 69 66 28 75 2d 3e 75 | 5f 6f 66 69 6c 65 5b 66 |.if(u->u|_ofile[f|
|00001b40| 69 6c 65 6e 5d 20 3d 3d | 20 4e 55 4c 4c 29 0a 09 |ilen] ==| NULL)..|
|00001b50| 09 09 09 09 63 6f 6e 74 | 69 6e 75 65 3b 0a 0a 09 |....cont|inue;...|
|00001b60| 09 09 09 65 73 65 65 6b | 28 6b 6d 65 6d 2c 28 6c |...eseek|(kmem,(l|
|00001b70| 6f 6e 67 29 75 2d 3e 75 | 5f 6f 66 69 6c 65 5b 66 |ong)u->u|_ofile[f|
|00001b80| 69 6c 65 6e 5d 2c 30 2c | 22 66 69 6c 65 22 29 3b |ilen],0,|"file");|
|00001b90| 0a 09 09 09 09 65 72 65 | 61 64 28 6b 6d 65 6d 2c |.....ere|ad(kmem,|
|00001ba0| 28 63 68 61 72 20 2a 29 | 26 66 2c 20 73 69 7a 65 |(char *)|&f, size|
|00001bb0| 6f 66 28 66 29 2c 20 22 | 66 69 6c 65 22 29 3b 0a |of(f), "|file");.|
|00001bc0| 0a 09 09 09 09 69 66 28 | 66 2e 66 5f 63 6f 75 6e |.....if(|f.f_coun|
|00001bd0| 74 20 3e 20 30 29 20 7b | 0a 09 09 09 09 09 69 20 |t > 0) {|......i |
|00001be0| 3d 20 67 65 74 69 6e 6f | 64 65 28 28 63 68 61 72 |= getino|de((char|
|00001bf0| 20 2a 29 66 2e 66 5f 69 | 6e 6f 64 65 2c 20 22 66 | *)f.f_i|node, "f|
|00001c00| 69 6c 65 22 29 3b 0a 09 | 09 09 09 09 69 66 28 63 |ile");..|....if(c|
|00001c10| 68 65 63 6b 28 26 73 2c | 69 29 29 0a 09 09 09 09 |heck(&s,|i)).....|
|00001c20| 09 09 66 6c 61 67 73 20 | 7c 3d 20 4f 46 49 4c 45 |..flags ||= OFILE|
|00001c30| 3b 0a 09 09 09 09 7d 0a | 09 09 09 7d 0a 09 09 09 |;.....}.|...}....|
|00001c40| 69 66 28 66 6c 61 67 73 | 29 20 67 6f 74 6f 6e 65 |if(flags|) gotone|
|00001c50| 28 75 2c 26 70 2c 66 6c | 61 67 73 29 3b 0a 09 09 |(u,&p,fl|ags);...|
|00001c60| 7d 0a 09 09 69 66 28 21 | 20 70 69 64 73 5f 6f 6e |}...if(!| pids_on|
|00001c70| 6c 79 29 0a 09 09 09 70 | 72 69 6e 74 66 28 22 5c |ly)....p|rintf("\|
|00001c80| 6e 22 29 3b 0a 09 7d 0a | 7d 09 09 0a 0a 2f 2a 0a |n");..}.|}..../*.|
|00001c90| 20 2a 20 70 72 69 6e 74 | 20 74 68 65 20 6e 61 6d | * print| the nam|
|00001ca0| 65 20 6f 66 20 74 68 65 | 20 75 73 65 72 20 6f 77 |e of the| user ow|
|00001cb0| 6e 69 6e 67 20 70 72 6f | 63 65 73 73 20 22 70 22 |ning pro|cess "p"|
|00001cc0| 20 61 6e 64 20 74 68 65 | 20 70 69 64 20 6f 66 20 | and the| pid of |
|00001cd0| 74 68 61 74 20 70 72 6f | 63 65 73 73 0a 20 2a 2f |that pro|cess. */|
|00001ce0| 0a 67 6f 74 6f 6e 65 28 | 75 2c 70 2c 66 29 0a 73 |.gotone(|u,p,f).s|
|00001cf0| 74 72 75 63 74 20 75 73 | 65 72 20 2a 75 3b 0a 73 |truct us|er *u;.s|
|00001d00| 74 72 75 63 74 20 70 72 | 6f 63 20 2a 70 3b 0a 69 |truct pr|oc *p;.i|
|00001d10| 6e 74 20 66 3b 0a 7b 0a | 09 72 65 67 69 73 74 65 |nt f;.{.|.registe|
|00001d20| 72 20 73 74 72 75 63 74 | 20 70 61 73 73 77 64 20 |r struct| passwd |
|00001d30| 2a 70 77 3b 0a 09 73 74 | 72 75 63 74 20 70 61 73 |*pw;..st|ruct pas|
|00001d40| 73 77 64 20 2a 67 65 74 | 70 77 75 69 64 28 29 3b |swd *get|pwuid();|
|00001d50| 0a 0a 09 2f 2a 20 6f 6e | 6c 79 20 70 72 69 6e 74 |.../* on|ly print|
|00001d60| 20 70 69 64 73 20 61 6e | 64 20 72 65 74 75 72 6e | pids an|d return|
|00001d70| 20 2a 2f 0a 09 69 66 28 | 70 69 64 73 5f 6f 6e 6c | */..if(|pids_onl|
|00001d80| 79 29 20 7b 0a 09 09 09 | 70 72 69 6e 74 66 28 22 |y) {....|printf("|
|00001d90| 25 64 20 22 2c 70 2d 3e | 70 5f 70 69 64 29 3b 0a |%d ",p->|p_pid);.|
|00001da0| 09 09 09 66 66 6c 75 73 | 68 28 73 74 64 6f 75 74 |...fflus|h(stdout|
|00001db0| 29 3b 0a 09 09 09 72 65 | 74 75 72 6e 3b 0a 09 7d |);....re|turn;..}|
|00001dc0| 0a 09 70 77 20 3d 20 67 | 65 74 70 77 75 69 64 28 |..pw = g|etpwuid(|
|00001dd0| 75 2d 3e 75 5f 75 69 64 | 29 3b 0a 09 69 66 28 70 |u->u_uid|);..if(p|
|00001de0| 77 29 0a 09 09 70 72 69 | 6e 74 66 28 22 25 2d 38 |w)...pri|ntf("%-8|
|00001df0| 2e 38 73 5c 74 22 2c 20 | 70 77 2d 3e 70 77 5f 6e |.8s\t", |pw->pw_n|
|00001e00| 61 6d 65 20 29 3b 0a 09 | 65 6c 73 65 0a 09 09 70 |ame );..|else...p|
|00001e10| 72 69 6e 74 66 28 22 28 | 25 64 29 5c 74 22 2c 20 |rintf("(|%d)\t", |
|00001e20| 75 2d 3e 75 5f 75 69 64 | 29 3b 0a 09 70 72 69 6e |u->u_uid|);..prin|
|00001e30| 74 66 28 22 25 64 5c 74 | 22 2c 20 70 2d 3e 70 5f |tf("%d\t|", p->p_|
|00001e40| 70 69 64 29 3b 0a 09 69 | 66 28 66 20 26 20 4f 46 |pid);..i|f(f & OF|
|00001e50| 49 4c 45 29 20 70 75 74 | 63 68 61 72 28 27 66 27 |ILE) put|char('f'|
|00001e60| 29 3b 09 2f 2a 20 70 72 | 6f 63 20 68 61 73 20 61 |);./* pr|oc has a|
|00001e70| 20 66 69 6c 65 20 09 09 | 20 20 20 2a 2f 09 0a 09 | file ..| */...|
|00001e80| 69 66 28 66 20 26 20 43 | 44 49 52 29 20 20 70 75 |if(f & C|DIR) pu|
|00001e90| 74 63 68 61 72 28 27 70 | 27 29 3b 09 2f 2a 20 70 |tchar('p|');./* p|
|00001ea0| 72 6f 63 27 73 20 63 75 | 72 72 65 6e 74 20 64 69 |roc's cu|rrent di|
|00001eb0| 72 20 69 73 20 6f 6e 20 | 64 65 76 69 63 65 20 2a |r is on |device *|
|00001ec0| 2f 0a 09 69 66 28 66 20 | 26 20 52 44 49 52 29 20 |/..if(f |& RDIR) |
|00001ed0| 20 70 75 74 63 68 61 72 | 28 27 72 27 29 3b 09 2f | putchar|('r');./|
|00001ee0| 2a 20 70 72 6f 63 27 73 | 20 72 6f 6f 74 20 64 69 |* proc's| root di|
|00001ef0| 72 20 69 73 20 6f 6e 20 | 64 65 76 69 63 65 09 20 |r is on |device. |
|00001f00| 20 20 2a 2f 0a 09 69 66 | 28 66 20 26 20 58 46 49 | */..if|(f & XFI|
|00001f10| 4c 45 29 20 70 75 74 63 | 68 61 72 28 27 78 27 29 |LE) putc|har('x')|
|00001f20| 3b 09 2f 2a 20 70 72 6f | 63 27 73 20 74 65 78 74 |;./* pro|c's text|
|00001f30| 20 70 72 6f 74 6f 20 69 | 73 20 66 69 6c 65 20 20 | proto i|s file |
|00001f40| 20 20 20 20 20 2a 2f 0a | 09 70 72 69 6e 74 66 28 | */.|.printf(|
|00001f50| 22 5c 74 22 29 3b 0a 09 | 70 72 69 6e 74 66 28 22 |"\t");..|printf("|
|00001f60| 25 2d 31 34 2e 31 34 73 | 22 2c 20 75 2d 3e 75 5f |%-14.14s|", u->u_|
|00001f70| 63 6f 6d 6d 29 3b 0a 09 | 70 72 69 6e 74 66 28 22 |comm);..|printf("|
|00001f80| 5c 6e 22 29 3b 0a 7d 0a | 0a 2f 2a 0a 20 2a 20 69 |\n");.}.|./*. * i|
|00001f90| 73 20 69 6e 6f 64 65 20 | 22 69 22 20 6f 6e 20 64 |s inode |"i" on d|
|00001fa0| 65 76 69 63 65 20 22 73 | 22 3f 20 72 65 74 75 72 |evice "s|"? retur|
|00001fb0| 6e 73 20 54 52 55 45 20 | 6f 72 20 46 41 4c 53 45 |ns TRUE |or FALSE|
|00001fc0| 20 0a 20 2a 2f 0a 0a 63 | 68 65 63 6b 28 73 2c 20 | . */..c|heck(s, |
|00001fd0| 69 29 0a 73 74 72 75 63 | 74 20 73 74 61 74 20 2a |i).struc|t stat *|
|00001fe0| 73 3b 0a 73 74 72 75 63 | 74 20 69 6e 6f 64 65 20 |s;.struc|t inode |
|00001ff0| 2a 69 3b 0a 7b 0a 09 69 | 66 20 28 28 73 2d 3e 73 |*i;.{..i|f ((s->s|
|00002000| 74 5f 6d 6f 64 65 20 26 | 20 53 5f 49 46 4d 54 29 |t_mode &| S_IFMT)|
|00002010| 20 3d 3d 20 53 5f 49 46 | 42 4c 4b 20 26 26 20 73 | == S_IF|BLK && s|
|00002020| 2d 3e 73 74 5f 72 64 65 | 76 20 3d 3d 20 62 72 64 |->st_rde|v == brd|
|00002030| 65 76 28 69 2d 3e 69 5f | 64 65 76 29 29 0a 09 09 |ev(i->i_|dev))...|
|00002040| 09 72 65 74 75 72 6e 20 | 31 3b 0a 09 65 6c 73 65 |.return |1;..else|
|00002050| 20 69 66 28 28 73 2d 3e | 73 74 5f 64 65 76 20 3d | if((s->|st_dev =|
|00002060| 3d 20 62 72 64 65 76 28 | 69 2d 3e 69 5f 64 65 76 |= brdev(|i->i_dev|
|00002070| 29 29 20 26 26 20 28 73 | 2d 3e 73 74 5f 69 6e 6f |)) && (s|->st_ino|
|00002080| 20 3d 3d 20 69 2d 3e 69 | 5f 6e 75 6d 62 65 72 29 | == i->i|_number)|
|00002090| 29 0a 09 09 09 72 65 74 | 75 72 6e 20 31 3b 0a 09 |)....ret|urn 1;..|
|000020a0| 65 6c 73 65 20 72 65 74 | 75 72 6e 20 30 3b 0a 7d |else ret|urn 0;.}|
|000020b0| 0a 0a 0a 2f 2a 20 0a 20 | 2a 09 67 65 74 69 6e 6f |.../* . |*.getino|
|000020c0| 64 65 20 2d 20 72 65 61 | 64 20 61 6e 20 69 6e 6f |de - rea|d an ino|
|000020d0| 64 65 20 66 72 6f 6d 20 | 66 72 6f 6d 20 6d 65 6d |de from |from mem|
|000020e0| 20 61 74 20 61 64 64 72 | 65 73 73 20 22 61 64 64 | at addr|ess "add|
|000020f0| 72 22 0a 20 2a 20 09 20 | 20 20 20 20 20 72 65 74 |r". * . | ret|
|00002100| 75 72 6e 20 70 6f 69 6e | 74 65 72 20 74 6f 20 69 |urn poin|ter to i|
|00002110| 6e 6f 64 65 20 73 74 72 | 75 63 74 2e 20 0a 20 2a |node str|uct. . *|
|00002120| 2f 0a 73 74 72 75 63 74 | 20 69 6e 6f 64 65 20 2a |/.struct| inode *|
|00002130| 67 65 74 69 6e 6f 64 65 | 28 69 70 2c 73 29 0a 73 |getinode|(ip,s).s|
|00002140| 74 72 75 63 74 20 69 6e | 6f 64 65 20 2a 69 70 3b |truct in|ode *ip;|
|00002150| 0a 63 68 61 72 20 2a 73 | 3b 0a 7b 0a 09 73 74 61 |.char *s|;.{..sta|
|00002160| 74 69 63 20 73 74 72 75 | 63 74 20 69 6e 6f 64 65 |tic stru|ct inode|
|00002170| 20 69 3b 0a 0a 09 65 73 | 65 65 6b 28 6b 6d 65 6d | i;...es|eek(kmem|
|00002180| 2c 20 28 6c 6f 6e 67 29 | 69 70 2c 20 30 2c 20 22 |, (long)|ip, 0, "|
|00002190| 69 6e 6f 64 65 22 29 3b | 0a 09 65 72 65 61 64 28 |inode");|..eread(|
|000021a0| 6b 6d 65 6d 2c 20 28 63 | 68 61 72 20 2a 29 26 69 |kmem, (c|har *)&i|
|000021b0| 2c 20 73 69 7a 65 6f 66 | 28 69 29 2c 20 22 69 6e |, sizeof|(i), "in|
|000021c0| 6f 64 65 22 29 3b 0a 09 | 72 65 74 75 72 6e 20 26 |ode");..|return &|
|000021d0| 69 3b 0a 7d 0a 0a 0a 2f | 2a 0a 20 2a 09 67 65 74 |i;.}.../|*. *.get|
|000021e0| 74 65 78 74 20 2d 20 72 | 65 61 64 20 74 68 65 20 |text - r|ead the |
|000021f0| 74 65 78 74 20 74 61 62 | 6c 65 20 65 6e 74 72 79 |text tab|le entry|
|00002200| 20 66 6f 72 20 70 72 6f | 63 65 73 73 20 22 70 22 | for pro|cess "p"|
|00002210| 0a 20 2a 09 09 72 65 74 | 75 72 6e 20 70 6f 69 6e |. *..ret|urn poin|
|00002220| 74 65 72 20 74 6f 20 69 | 6e 6f 64 65 0a 20 2a 2f |ter to i|node. */|
|00002230| 0a 0a 73 74 72 75 63 74 | 09 69 6e 6f 64 65 09 2a |..struct|.inode.*|
|00002240| 67 65 74 74 65 78 74 20 | 28 70 29 0a 73 74 72 75 |gettext |(p).stru|
|00002250| 63 74 09 70 72 6f 63 09 | 2a 70 3b 0a 7b 0a 09 73 |ct.proc.|*p;.{..s|
|00002260| 74 72 75 63 74 09 74 65 | 78 74 09 74 65 78 74 3b |truct.te|xt.text;|
|00002270| 0a 0a 09 69 66 20 28 70 | 2d 3e 70 5f 74 65 78 74 |...if (p|->p_text|
|00002280| 70 20 3d 3d 20 30 29 0a | 09 09 72 65 74 75 72 6e |p == 0).|..return|
|00002290| 20 30 3b 0a 0a 09 65 73 | 65 65 6b 20 28 6b 6d 65 | 0;...es|eek (kme|
|000022a0| 6d 2c 20 28 6c 6f 6e 67 | 29 20 70 2d 3e 70 5f 74 |m, (long|) p->p_t|
|000022b0| 65 78 74 70 2c 20 30 2c | 20 22 74 65 78 74 22 29 |extp, 0,| "text")|
|000022c0| 3b 0a 09 65 72 65 61 64 | 20 28 6b 6d 65 6d 2c 20 |;..eread| (kmem, |
|000022d0| 28 63 68 61 72 20 2a 29 | 20 26 74 65 78 74 2c 20 |(char *)| &text, |
|000022e0| 73 69 7a 65 6f 66 20 74 | 65 78 74 2c 20 22 74 65 |sizeof t|ext, "te|
|000022f0| 78 74 22 29 3b 0a 0a 09 | 72 65 74 75 72 6e 20 67 |xt");...|return g|
|00002300| 65 74 69 6e 6f 64 65 20 | 28 74 65 78 74 2e 78 5f |etinode |(text.x_|
|00002310| 69 70 74 72 29 3b 0a 7d | 0a 0a 0a 2f 2a 20 0a 20 |iptr);.}|.../* . |
|00002320| 2a 20 67 65 74 20 75 73 | 65 72 20 70 61 67 65 20 |* get us|er page |
|00002330| 66 6f 72 20 70 72 6f 63 | 20 22 70 22 20 66 72 6f |for proc| "p" fro|
|00002340| 6d 20 63 6f 72 65 20 6f | 72 20 73 77 61 70 0a 20 |m core o|r swap. |
|00002350| 2a 20 72 65 74 75 72 6e | 20 70 6f 69 6e 74 65 72 |* return| pointer|
|00002360| 20 74 6f 20 75 73 65 72 | 20 73 74 72 75 63 74 0a | to user| struct.|
|00002370| 20 2a 2f 0a 73 74 72 75 | 63 74 20 75 73 65 72 20 | */.stru|ct user |
|00002380| 2a 67 65 74 75 73 65 72 | 28 70 29 0a 73 74 72 75 |*getuser|(p).stru|
|00002390| 63 74 20 70 72 6f 63 20 | 2a 70 3b 0a 7b 0a 09 73 |ct proc |*p;.{..s|
|000023a0| 74 61 74 69 63 20 63 68 | 61 72 20 62 75 66 5b 4e |tatic ch|ar buf[N|
|000023b0| 42 50 43 5d 3b 0a 09 6c | 6f 6e 67 20 75 70 61 67 |BPC];..l|ong upag|
|000023c0| 65 3b 0a 0a 09 6c 6f 6e | 67 09 73 77 61 70 61 64 |e;...lon|g.swapad|
|000023d0| 64 72 3b 0a 09 69 6e 74 | 09 69 3b 0a 0a 09 69 66 |dr;..int|.i;...if|
|000023e0| 20 28 28 70 2d 3e 70 5f | 66 6c 61 67 20 26 20 28 | ((p->p_|flag & (|
|000023f0| 53 53 57 41 50 7c 53 53 | 50 41 52 54 29 29 20 7c |SSWAP|SS|PART)) ||
|00002400| 7c 20 21 20 28 70 2d 3e | 70 5f 66 6c 61 67 20 26 || ! (p->|p_flag &|
|00002410| 20 53 4c 4f 41 44 29 29 | 20 7b 0a 09 09 73 77 61 | SLOAD))| {...swa|
|00002420| 70 61 64 64 72 20 3d 20 | 70 2d 3e 70 5f 61 64 64 |paddr = |p->p_add|
|00002430| 72 5b 30 5d 2e 74 65 5f | 66 72 61 6d 65 6e 6f 20 |r[0].te_|frameno |
|00002440| 2a 20 4e 42 50 43 3b 0a | 09 09 6c 73 65 65 6b 20 |* NBPC;.|..lseek |
|00002450| 28 73 77 61 70 2c 20 73 | 77 61 70 61 64 64 72 2c |(swap, s|wapaddr,|
|00002460| 20 30 29 3b 0a 09 09 69 | 66 20 28 72 65 61 64 20 | 0);...i|f (read |
|00002470| 28 73 77 61 70 2c 20 62 | 75 66 2c 20 73 69 7a 65 |(swap, b|uf, size|
|00002480| 6f 66 20 62 75 66 29 20 | 3c 20 30 29 0a 09 09 09 |of buf) |< 0)....|
|00002490| 72 65 74 75 72 6e 20 28 | 30 29 3b 0a 09 7d 20 65 |return (|0);..} e|
|000024a0| 6c 73 65 20 7b 0a 09 09 | 6c 73 65 65 6b 20 28 6d |lse {...|lseek (m|
|000024b0| 65 6d 2c 20 70 2d 3e 70 | 5f 61 64 64 72 5b 30 5d |em, p->p|_addr[0]|
|000024c0| 2e 74 65 5f 66 72 61 6d | 65 6e 6f 20 2a 20 4e 42 |.te_fram|eno * NB|
|000024d0| 50 43 2c 20 30 29 3b 0a | 09 09 69 66 20 28 72 65 |PC, 0);.|..if (re|
|000024e0| 61 64 20 28 6d 65 6d 2c | 20 62 75 66 2c 20 73 69 |ad (mem,| buf, si|
|000024f0| 7a 65 6f 66 20 62 75 66 | 29 20 3c 20 30 29 0a 09 |zeof buf|) < 0)..|
|00002500| 09 09 72 65 74 75 72 6e | 20 28 30 29 3b 0a 09 7d |..return| (0);..}|
|00002510| 0a 09 72 65 74 75 72 6e | 20 28 73 74 72 75 63 74 |..return| (struct|
|00002520| 20 75 73 65 72 20 2a 29 | 20 62 75 66 3b 0a 7d 0a | user *)| buf;.}.|
|00002530| 0a 2f 2a 0a 20 2a 20 72 | 65 61 64 20 77 69 74 68 |./*. * r|ead with|
|00002540| 20 65 72 72 6f 72 20 63 | 68 65 63 6b 69 6e 67 0a | error c|hecking.|
|00002550| 20 2a 2f 0a 65 72 65 61 | 64 28 20 66 64 2c 20 70 | */.erea|d( fd, p|
|00002560| 2c 20 73 69 7a 65 2c 20 | 73 29 0a 69 6e 74 20 66 |, size, |s).int f|
|00002570| 64 3b 0a 63 68 61 72 20 | 2a 70 3b 0a 69 6e 74 20 |d;.char |*p;.int |
|00002580| 73 69 7a 65 3b 0a 63 68 | 61 72 20 2a 73 3b 0a 7b |size;.ch|ar *s;.{|
|00002590| 0a 09 69 6e 74 20 6e 3b | 0a 09 63 68 61 72 20 62 |..int n;|..char b|
|000025a0| 75 66 5b 31 30 30 5d 3b | 0a 09 69 66 28 28 20 6e |uf[100];|..if(( n|
|000025b0| 20 3d 20 20 72 65 61 64 | 28 66 64 2c 20 70 2c 20 | = read|(fd, p, |
|000025c0| 73 69 7a 65 29 29 20 21 | 3d 20 73 69 7a 65 29 7b |size)) !|= size){|
|000025d0| 0a 09 09 73 70 72 69 6e | 74 66 28 62 75 66 2c 20 |...sprin|tf(buf, |
|000025e0| 22 72 65 61 64 20 65 72 | 72 6f 72 20 66 6f 72 20 |"read er|ror for |
|000025f0| 25 73 2e 20 22 2c 20 73 | 29 3b 0a 09 09 65 72 72 |%s. ", s|);...err|
|00002600| 6f 72 28 62 75 66 29 3b | 0a 09 7d 0a 09 72 65 74 |or(buf);|..}..ret|
|00002610| 75 72 6e 20 6e 3b 0a 7d | 0a 0a 2f 2a 0a 20 2a 20 |urn n;.}|../*. * |
|00002620| 73 65 65 6b 20 77 69 74 | 68 20 65 72 72 6f 72 20 |seek wit|h error |
|00002630| 63 68 65 63 6b 69 6e 67 | 0a 20 2a 2f 0a 6c 6f 6e |checking|. */.lon|
|00002640| 67 20 65 73 65 65 6b 28 | 66 64 2c 20 6f 66 66 2c |g eseek(|fd, off,|
|00002650| 20 77 68 65 6e 63 65 2c | 20 73 29 0a 69 6e 74 20 | whence,| s).int |
|00002660| 66 64 3b 0a 6c 6f 6e 67 | 20 6f 66 66 3b 0a 69 6e |fd;.long| off;.in|
|00002670| 74 20 77 68 65 6e 63 65 | 3b 0a 63 68 61 72 20 2a |t whence|;.char *|
|00002680| 73 3b 0a 7b 0a 09 6c 6f | 6e 67 20 72 65 74 3b 0a |s;.{..lo|ng ret;.|
|00002690| 09 63 68 61 72 20 62 75 | 66 5b 31 30 30 5d 3b 0a |.char bu|f[100];.|
|000026a0| 0a 09 69 66 28 28 20 72 | 65 74 20 3d 20 6c 73 65 |..if(( r|et = lse|
|000026b0| 65 6b 28 66 64 2c 20 6f | 66 66 2c 20 77 68 65 6e |ek(fd, o|ff, when|
|000026c0| 63 65 29 29 20 21 3d 20 | 6f 66 66 29 20 7b 0a 09 |ce)) != |off) {..|
|000026d0| 09 73 70 72 69 6e 74 66 | 28 62 75 66 2c 20 22 73 |.sprintf|(buf, "s|
|000026e0| 65 65 6b 20 66 6f 72 20 | 25 73 20 66 61 69 6c 65 |eek for |%s faile|
|000026f0| 64 2c 20 77 61 6e 74 65 | 64 20 25 6f 2c 20 67 6f |d, wante|d %o, go|
|00002700| 74 20 25 6f 2e 20 22 2c | 0a 09 09 09 73 2c 20 6f |t %o. ",|....s, o|
|00002710| 66 66 2c 20 72 65 74 29 | 3b 0a 09 09 65 72 72 6f |ff, ret)|;...erro|
|00002720| 72 28 62 75 66 29 3b 0a | 09 7d 0a 09 72 65 74 75 |r(buf);.|.}..retu|
|00002730| 72 6e 20 72 65 74 3b 0a | 7d 0a 0a 2f 2a 0a 20 2a |rn ret;.|}../*. *|
|00002740| 20 70 72 69 6e 74 20 6d | 65 73 67 20 22 73 22 20 | print m|esg "s" |
|00002750| 66 6f 6c 6c 6f 77 65 64 | 20 62 79 20 73 79 73 74 |followed| by syst|
|00002760| 65 6d 20 65 72 72 6f 20 | 6d 73 67 2e 20 65 78 69 |em erro |msg. exi|
|00002770| 74 2e 0a 20 2a 2f 0a 65 | 72 72 6f 72 28 73 29 0a |t.. */.e|rror(s).|
|00002780| 63 68 61 72 20 2a 73 3b | 0a 7b 0a 09 69 66 20 28 |char *s;|.{..if (|
|00002790| 73 29 0a 09 09 66 70 72 | 69 6e 74 66 28 73 74 64 |s)...fpr|intf(std|
|000027a0| 65 72 72 2c 73 29 3b 0a | 09 70 65 72 72 6f 72 28 |err,s);.|.perror(|
|000027b0| 22 22 29 3b 0a 09 65 78 | 69 74 28 31 29 3b 0a 7d |"");..ex|it(1);.}|
|000027c0| 0a 0a 2f 2a 0a 20 2a 20 | 67 65 74 20 73 6f 6d 65 |../*. * |get some|
|000027d0| 20 73 79 6d 62 6f 6c 73 | 20 66 6f 72 6d 20 74 68 | symbols| form th|
|000027e0| 65 20 6b 65 72 6e 65 6c | 0a 20 2a 2f 0a 67 65 74 |e kernel|. */.get|
|000027f0| 73 79 6d 73 28 29 0a 7b | 0a 09 72 65 67 69 73 74 |syms().{|..regist|
|00002800| 65 72 20 69 3b 0a 09 73 | 74 72 75 63 74 20 76 61 |er i;..s|truct va|
|00002810| 72 20 76 3b 0a 0a 09 6e | 6c 69 73 74 28 22 2f 78 |r v;...n|list("/x|
|00002820| 65 6e 69 78 22 2c 20 75 | 6e 69 78 5f 6e 6c 29 3b |enix", u|nix_nl);|
|00002830| 0a 0a 09 66 6f 72 28 69 | 20 3d 20 30 3b 20 69 20 |...for(i| = 0; i |
|00002840| 3c 20 28 73 69 7a 65 6f | 66 28 75 6e 69 78 5f 6e |< (sizeo|f(unix_n|
|00002850| 6c 29 2f 73 69 7a 65 6f | 66 28 75 6e 69 78 5f 6e |l)/sizeo|f(unix_n|
|00002860| 6c 5b 30 5d 29 29 2d 31 | 3b 20 69 2b 2b 29 0a 09 |l[0]))-1|; i++)..|
|00002870| 09 69 66 28 75 6e 69 78 | 5f 6e 6c 5b 69 5d 2e 6e |.if(unix|_nl[i].n|
|00002880| 5f 76 61 6c 75 65 20 3d | 3d 20 30 29 20 7b 0a 09 |_value =|= 0) {..|
|00002890| 09 09 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 |..fprint|f(stderr|
|000028a0| 2c 22 25 73 3a 20 63 61 | 6e 27 74 20 6e 6c 69 73 |,"%s: ca|n't nlis|
|000028b0| 74 20 66 6f 72 20 25 73 | 2e 5c 6e 22 2c 0a 09 09 |t for %s|.\n",...|
|000028c0| 09 09 70 72 6f 67 6e 61 | 6d 65 2c 20 75 6e 69 78 |..progna|me, unix|
|000028d0| 5f 6e 6c 5b 69 5d 2e 6e | 5f 6e 61 6d 65 29 3b 0a |_nl[i].n|_name);.|
|000028e0| 09 09 09 65 78 69 74 28 | 31 29 3b 0a 09 09 7d 0a |...exit(|1);...}.|
|000028f0| 09 65 73 65 65 6b 28 6b | 6d 65 6d 2c 20 28 6c 6f |.eseek(k|mem, (lo|
|00002900| 6e 67 29 75 6e 69 78 5f | 6e 6c 5b 58 5f 56 41 52 |ng)unix_|nl[X_VAR|
|00002910| 5d 2e 6e 5f 76 61 6c 75 | 65 2c 20 30 29 3b 0a 09 |].n_valu|e, 0);..|
|00002920| 65 72 65 61 64 28 6b 6d | 65 6d 2c 20 26 76 2c 20 |eread(km|em, &v, |
|00002930| 73 69 7a 65 6f 66 28 76 | 29 2c 20 22 76 61 72 22 |sizeof(v|), "var"|
|00002940| 29 3b 0a 09 6e 70 72 6f | 63 20 3d 20 76 2e 76 5f |);..npro|c = v.v_|
|00002950| 70 72 6f 63 3b 0a 09 72 | 65 74 75 72 6e 3b 0a 7d |proc;..r|eturn;.}|
|00002960| 0a 0a 0a 2f 2a 0a 20 2a | 20 72 65 61 64 20 70 72 |.../*. *| read pr|
|00002970| 6f 63 20 74 61 62 6c 65 | 20 65 6e 74 72 79 20 22 |oc table| entry "|
|00002980| 6e 22 20 69 6e 74 6f 20 | 62 75 66 66 65 72 20 22 |n" into |buffer "|
|00002990| 70 22 0a 20 2a 2f 0a 70 | 72 6f 63 73 6c 6f 74 28 |p". */.p|rocslot(|
|000029a0| 6e 2c 20 70 29 0a 69 6e | 74 20 6e 3b 0a 73 74 72 |n, p).in|t n;.str|
|000029b0| 75 63 74 20 70 72 6f 63 | 20 2a 70 3b 0a 7b 0a 09 |uct proc| *p;.{..|
|000029c0| 65 73 65 65 6b 28 6b 6d | 65 6d 2c 20 26 28 28 73 |eseek(km|em, &((s|
|000029d0| 74 72 75 63 74 20 70 72 | 6f 63 20 2a 29 20 75 6e |truct pr|oc *) un|
|000029e0| 69 78 5f 6e 6c 5b 58 5f | 50 52 4f 43 5d 2e 6e 5f |ix_nl[X_|PROC].n_|
|000029f0| 76 61 6c 75 65 29 5b 6e | 5d 2c 20 30 29 3b 0a 09 |value)[n|], 0);..|
|00002a00| 65 72 65 61 64 28 6b 6d | 65 6d 2c 20 28 63 68 61 |eread(km|em, (cha|
|00002a10| 72 20 2a 29 70 2c 20 73 | 69 7a 65 6f 66 28 73 74 |r *)p, s|izeof(st|
|00002a20| 72 75 63 74 20 70 72 6f | 63 29 2c 20 22 70 72 6f |ruct pro|c), "pro|
|00002a30| 63 22 29 3b 0a 09 72 65 | 74 75 72 6e 3b 0a 7d 0a |c");..re|turn;.}.|
|00002a40| 53 48 41 52 5f 45 4f 46 | 0a 66 69 0a 65 78 69 74 |SHAR_EOF|.fi.exit|
|00002a50| 20 30 0a 23 09 45 6e 64 | 20 6f 66 20 73 68 65 6c | 0.#.End| of shel|
|00002a60| 6c 20 61 72 63 68 69 76 | 65 0a 2d 2d 20 0a 4a 6f |l archiv|e.-- .Jo|
|00002a70| 68 6e 20 46 2e 20 48 61 | 75 67 68 20 49 49 20 20 |hn F. Ha|ugh II |
|00002a80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002a90| 20 20 20 20 20 20 20 20 | 20 20 20 55 55 43 50 3a | | UUCP:|
|00002aa0| 20 2e 2e 2e 21 63 73 2e | 75 74 65 78 61 73 2e 65 | ...!cs.|utexas.e|
|00002ab0| 64 75 21 72 70 70 33 38 | 36 21 6a 66 68 0a 4d 61 |du!rpp38|6!jfh.Ma|
|00002ac0| 20 42 65 6c 6c 3a 20 28 | 35 31 32 29 20 38 33 32 | Bell: (|512) 832|
|00002ad0| 2d 38 38 33 32 20 20 20 | 20 20 20 20 20 20 20 20 |-8832 | |
|00002ae0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002af0| 44 6f 6d 61 69 6e 3a 20 | 6a 66 68 40 72 70 70 33 |Domain: |jfh@rpp3|
|00002b00| 38 36 2e 63 61 63 74 75 | 73 2e 6f 72 67 0a |86.cactu|s.org. |
+--------+-------------------------+-------------------------+--------+--------+