867
|
1 ifp1
|
|
2 use ..../defs/os9defs.a
|
|
3 endc
|
|
4 Carry equ %00000001
|
|
5 Write. equ 2 write access
|
|
6 FD.Att equ 0 FD offset to attr
|
|
7 FD.Own equ 1 FD offset to owner
|
|
8
|
|
9 Bufsize equ 16 FD info bytes
|
|
10
|
|
11 psect change,0,0,2,0,0
|
|
12
|
|
13 * chown(fname,owner)
|
|
14 chown:
|
|
15 pshs y,u save registers
|
|
16 leas -Bufsize,s reserve buffer space
|
|
17 os9 F$ID get user ID
|
|
18 bcs chexit bra if error
|
|
19 ldb #E$FNA prime for error
|
|
20 cmpy #0 superuser?
|
|
21 orcc #Carry prime the carry
|
|
22 bne chexit bra if not
|
|
23
|
|
24 bsr openfile open file and read FD
|
|
25 bcs chexit bra if error
|
|
26
|
|
27 pshs a save path number
|
|
28 ldd Bufsize+9,s get the new owner id
|
|
29 std FD.Own,x modify the FD
|
|
30 puls a restore path number
|
|
31 ldb #SS.FD write FD code
|
|
32 os9 I$SETSTT write the FD
|
|
33 bcs chexit bra if error
|
|
34 os9 I$CLOSE close the file
|
|
35
|
|
36 * carry set is error exit, clear for normal
|
|
37 chexit
|
|
38 leas Bufsize,s return scratch
|
|
39 puls y,u restore regs
|
|
40 lbra _sysret return to caller
|
|
41
|
|
42 *
|
|
43 * open file and fetch file FD
|
|
44 * Bufsize buffer is at 2,s
|
|
45 *
|
|
46 openfile
|
|
47 lda #Write. access mode
|
|
48 ldx Bufsize+8,s address of name
|
|
49 os9 I$OPEN open the file
|
|
50 bcc openf10 exit if error
|
|
51 rts
|
|
52
|
|
53 openf10
|
|
54 leax 2,s get buffer address
|
|
55 ldy #Bufsize and size
|
|
56 ldb #SS.FD read FD code
|
|
57 os9 I$GETSTT read the FD
|
|
58 rts
|
|
59
|
|
60 * chmod(fname,perm)
|
|
61 chmod:
|
|
62 pshs y,u save registers
|
|
63 leas -Bufsize,s reserve buffer space
|
|
64
|
|
65 bsr openfile open file and read FD
|
|
66 bcs chexit bra if error
|
|
67
|
|
68 pshs a,y save regs
|
|
69 os9 F$ID get user id
|
|
70 cmpy #0 super-user?
|
|
71 beq chmod10 yes, he can do it
|
|
72 ldb #E$FNA prime for error
|
|
73 cmpy FD.Own,x user's own file?
|
|
74 orcc #Carry prime the carry
|
|
75 bne chexit no, return error
|
|
76
|
|
77 chmod10
|
|
78 ldb Bufsize+12,s get the new attributes
|
|
79 stb FD.Att,x update FD
|
|
80 puls a,y restore path number
|
|
81 ldb #SS.FD write FD code
|
|
82 os9 I$SETSTT write the FD
|
|
83 bcs chexit bra if error
|
|
84 os9 I$CLOSE close the file
|
|
85 bra chexit and exit
|
|
86
|
|
87 endsect
|