1: / chown -- change owner
2:
3:
4: .globl fopen, getc, mesg
5:
6: mov sp,r5
7: mov (r5),r4
8: cmp r4,$3
9: bge 1f
10: jsr r5,mesg; <chown uid f1 ...\n\0>; .even
11: 1:
12: add $4,r5
13: mov (r5),r3
14: cmpb (r3),$'0
15: blt 1f
16: cmpb (r3),$'9
17: bgt 1f
18: jsr r5,cvnum; geta
19: br do
20: 1:
21: mov $uids,r0
22: jsr r5,fopen; ubuf
23: bec 1f
24: jsr r5,mesg; <Can't open /etc/uids\n\0>; .even
25: sys exit
26: 1:
27: mov r3,r2
28: 2:
29: jsr r5,getc; ubuf
30: bcc 3f
31: who:
32: jsr r5,mesg; <Who?\n\0>; .even
33: sys exit
34: 3:
35: cmp r0,$':
36: beq 3f
37: cmpb (r2)+,r0
38: beq 2b
39: 2:
40: jsr r5,getc; ubuf
41: bcs who
42: cmp r0,$'\n
43: bne 2b
44: br 1b
45: 3:
46: tstb (r2)
47: bne 2b
48: 3:
49: jsr r5,getc; ubuf
50: cmpb r0,$':
51: bne 3b
52: jsr r5,cvnum; getc
53: do:
54: sub $2,r4
55: mov r1,0f+2
56: tst (r5)+
57: 1:
58: mov (r5),0f
59: mov (r5)+,9f
60: sys stat; 9:..; statb
61: movb statb+8,0f+3
62: sys chown; 0:..; 0
63: bec 2f
64: mov 0b,r0
65: mov r0,0f
66: clr 0f+2
67: 3:
68: tstb (r0)+
69: beq 3f
70: inc 0f+2
71: br 3b
72: 3:
73: mov $1,r0
74: sys write; 0:..; ..
75: jsr r5,mesg; <?\n\0>; .even
76: 2:
77: dec r4
78: bgt 1b
79: sys exit
80:
81: cvnum:
82: clr r1
83: 1:
84: jsr r5,*(r5); ubuf
85: bcs 1f
86: sub $'0,r0
87: cmp r0,$9.
88: bhi 1f
89: mpy $10.,r1
90: add r0,r1
91: br 1b
92: 1:
93: tst (r5)+
94: rts r5
95:
96: geta:
97: movb (r3)+,r0
98: tst (r5)+
99: rts r5
100:
101: uids: </etc/passwd\0>
102:
103: .bss
104: statb: .=.+36.
105: ubuf: .=.+518.
Defined functions
cvnum
defined in line
81; used 2 times
do
defined in line
53; used 1 times
geta
defined in line
96; used 1 times
uids
defined in line
101; used 1 times
who
defined in line
31; used 1 times
Defined variables
ubuf
defined in line
105; used 5 times