Mercurial > hg > Members > kono > nitros9-code
view 3rdparty/packages/cc/sources/change.a @ 867:0198655f2552
Added sources
author | boisy |
---|---|
date | Thu, 16 Jan 2003 19:54:21 +0000 |
parents | |
children |
line wrap: on
line source
ifp1 use ..../defs/os9defs.a endc Carry equ %00000001 Write. equ 2 write access FD.Att equ 0 FD offset to attr FD.Own equ 1 FD offset to owner Bufsize equ 16 FD info bytes psect change,0,0,2,0,0 * chown(fname,owner) chown: pshs y,u save registers leas -Bufsize,s reserve buffer space os9 F$ID get user ID bcs chexit bra if error ldb #E$FNA prime for error cmpy #0 superuser? orcc #Carry prime the carry bne chexit bra if not bsr openfile open file and read FD bcs chexit bra if error pshs a save path number ldd Bufsize+9,s get the new owner id std FD.Own,x modify the FD puls a restore path number ldb #SS.FD write FD code os9 I$SETSTT write the FD bcs chexit bra if error os9 I$CLOSE close the file * carry set is error exit, clear for normal chexit leas Bufsize,s return scratch puls y,u restore regs lbra _sysret return to caller * * open file and fetch file FD * Bufsize buffer is at 2,s * openfile lda #Write. access mode ldx Bufsize+8,s address of name os9 I$OPEN open the file bcc openf10 exit if error rts openf10 leax 2,s get buffer address ldy #Bufsize and size ldb #SS.FD read FD code os9 I$GETSTT read the FD rts * chmod(fname,perm) chmod: pshs y,u save registers leas -Bufsize,s reserve buffer space bsr openfile open file and read FD bcs chexit bra if error pshs a,y save regs os9 F$ID get user id cmpy #0 super-user? beq chmod10 yes, he can do it ldb #E$FNA prime for error cmpy FD.Own,x user's own file? orcc #Carry prime the carry bne chexit no, return error chmod10 ldb Bufsize+12,s get the new attributes stb FD.Att,x update FD puls a,y restore path number ldb #SS.FD write FD code os9 I$SETSTT write the FD bcs chexit bra if error os9 I$CLOSE close the file bra chexit and exit endsect