.TITLE OWN .IDENT /4/ ; 18-JUL-1990 08:21:27 ; OWN is designed to allow the ownership of a file to be changed ; to any UIC rather than the limited choice available from PIP. ; ; MCR>SET /UIC=[grp1,mem1] ; MCR>OWN [grp2,mem2]filename.ext;vers ; ; OWN will change the file ownership to [grp1,mem1]. Note that ; you must be either SYSTEM or the current owner of the file in ; order to change the ownership. In other words, once a non- ; privileged user changes ownership of a file, he will not be ; able to rechange that ownership. ; ; OWN supports wild cards in the name, extension, and version ; fields. Wild carded directories are not supported. .MCALL FSRSZ$,FINIT$,FDBDF$,FDOP$A,QIOW$,DIR$,EXIT$S,GTSK$S .MCALL GCML$,GCMLB$,CSI$,CSI$1,CSI$2,OFID$W,NMBLK$,CLOSE$ SYLUN = 1 TILUN = 2 .NLIST BEX START: GTSK$S #TBUF ;Get task parameters FINIT$ ;Initialize FCS stuff CKMORE: MOV #GCLBLK,R0 ;Point to GCMD control block GCML$ R0 ;Get command line BCC 20$ ;If CC, got one CMPB #GE.EOF,G.ERR(R0) ;Did we get to the end of a command file? BEQ 10$ ;If EQ, yes DIR$ #GETERR ;No, report we couldn't get command line 10$: EXIT$S ;Exit to RSX 20$: TST G.CMLD(R0) ;Check length of command BEQ CKMORE ;If EQ, no command given CSI$1 #CSIBLK,GCLBLK+G.CMLD+2,GCLBLK+G.CMLD ;Interpret file name BCS CSIERR ;If CS, bad command line CSI$2 #CSIBLK,OUTPUT BCS CSIERR ;If CS, bad syntax CLR FILCNT ;Clear file counter CLR WILDFL ;Clear flag for wildcards MOV #FDB,R0 ;Get FDB address MOV #FDB+F.FNB,R1 ;Get FNB address MOV #CSIBLK+C.DSDS,R2 ;Get dataset descriptor MOV #DEFFNB,R3 ;Get default file name block CALL .PARSE ;Parse the file specification BIT #NB.SVR!NB.STP!NB.SNM,N.STAT(R1) ;Were there wild cards? BEQ FIND ;If EQ, no INC WILDFL ;Set wild card flag FIND: BIT #NB.SVR!NB.VER,N.STAT(R1) ;Was a version given? BNE 30$ ;If NE, yes CLR N.FVER(R1) ;Clear prior version number 30$: CALL .FIND ;Find next file that matches BCS FILERR ;If CS, no matching files OFID$W R0 ;Open the file BCS FILERR ;If CS, couldn't open the file INC FILCNT ;Count this file DIR$ #WRITAT ;Write attributes BCS WRTER ;If CS, directive failed CMPB IOSTAT,#IS.SUC ;Did we write OK? BNE WRTER ;If NE, no CLOSE: CLOSE$ R0 ;Close file TST WILDFL ;Doing more than one? BNE FIND ;If NE, try for more BR CKMORE ;Try for more commands .PAGE CSIERR: DIR$ #BADNAM ;Command line error BR CKMORE FILERR: CMPB #IE.PRI,F.ERR(R0) ;Was this a privilege error? BNE 10$ ;If NE, no DIR$ #BADUIC ;Privilege error BR CKMORE 10$: CMPB #IE.NSF,F.ERR(R0) ;Was this No Such File? BNE 20$ ;If NE, no TST FILCNT ;Did we process any files? BNE CKMORE ;If NE, yes DIR$ #NSFILE ;Error message BR CKMORE 20$: DIR$ #NOFILE ;Could not open file BR CKMORE WRTER: CMPB #IE.PRI,IOSTAT ;Was this a privilege error? BNE 10$ ;If NE, no DIR$ #BADUIC ;Privilege error BR CLOSE 10$: DIR$ #BADATT ;Failed to write attributes BR CLOSE WRITAT: QIOW$ IO.WAT,SYLUN,1,,IOSTAT,, WATBLK: .BYTE 1,2 ;Write file owner .WORD NEWOWN ;Buffer address .WORD 0 ;End of block indicator TBUF: .BLKW 18. ;Task parameters buffer NEWOWN=TBUF+G.TSPC ;Address of default UIC BADNAM: QIOW$ IO.WVB,TILUN,1,,IOSTAT,, BADNA1: .ASCII /OWN -- Command line error./ BADNAL=.-BADNA1 .EVEN BADUIC: QIOW$ IO.WVB,TILUN,1,,IOSTAT,, BADUI1: .ASCII /OWN -- Privilege error./ BADUIL=.-BADUI1 .EVEN NOFILE: QIOW$ IO.WVB,TILUN,1,,IOSTAT,, NOFIL1: .ASCII /OWN -- Error during file open./ NOFILL=.-NOFIL1 .EVEN NSFILE: QIOW$ IO.WVB,TILUN,1,,IOSTAT,, NSFIL1: .ASCII /OWN -- No such file./ NSFILL=.-NSFIL1 .EVEN BADATT: QIOW$ IO.WVB,TILUN,1,,IOSTAT,, BADAT1: .ASCII /OWN -- Error during writing of attributes./ BADATL=.-BADAT1 .EVEN GETERR: QIOW$ IO.WVB,TILUN,1,,IOSTAT,, GETER1: .ASCII /OWN -- Error opening command file./ GETERL=.-GETER1 .EVEN IOSTAT: .BLKW 2 ;I/O status buffer WILDFL: .WORD 0 ;Wildcard flag FILCNT: .WORD 0 ;File counter FSRSZ$ 2 ;Define FCS work area DEFFNB: NMBLK$ ,,,SY ;Define default file name block FDB: FDBDF$ ;Define file descriptor block FDOP$A SYLUN,CSIBLK+C.DSDS,DEFFNB,FO.MFY ;File open GCLBLK: GCMLB$ 2,OWN,,TILUN ;Get command line CSI$ ;Define command string interpreter macros CSIBLK: .BLKB C.SIZE ;Define command string interpreter block .END START