PROGRAM READU.CHECK * * Universe semaphore checker * PROMPT '' * CRT @(-1):@(1,0):'Lock cross-reference' * OPEN 'VOC' TO local.voc.file THEN * smat.file.name = '/tmp/smat.':@USERNO * GOSUB 1000; * Init GOSUB 2000; * Open inode table file GOSUB 3000; * Get locking report (and calculate semaphores) * END * GOTO 9999 * * Read tunable parameters * 1000 * * GOSUB 1100 * RETURN * 1100 * * command.line = OCONV(@SENTENCE,'MCU') options = TRIM(FIELD(FIELD(command.line,')',1),'(',2)) command.line = TRIM(FIELD(command.line,'(',1)) * print.on = (INDEX(options,'P',1)#0) suppress.on = (INDEX(options,'N',1)#0) * RETURN * * Open inode table file * 2000 * * inode.list = '' inode.file.open = 0 * GOSUB 2100; * Get current working directory * OPEN 'INODES' TO inode.file THEN GOSUB 2200; * Initialise inode file END ELSE inode.list = '' END * RETURN * 2100 * * exec.cmd = 'SH -c "pwd"' GOSUB 9100 * cwd = FIELD(TRIM(cmd.cap<1,1>),' ',1) CRT 'cwd: ':cwd * RETURN * 2200 * * inode.reconf.reset = 0 inode.file.open = 1 READ inode.file.inode FROM inode.file,'INODES.INODE' ELSE inode.file.inode = '' END exec.cmd = 'SH -c "ls -lid1 INODES"' GOSUB 9100 inode.ls.inode = FIELD(TRIM(cmd.cap<1,1>),' ',1) IF inode.file.inode=inode.ls.inode ELSE CLEARFILE inode.file READU xxx FROM inode.file,'INODES.INODE' ELSE NULL WRITEU inode.ls.inode ON inode.file,'INODES.INODE' RELEASE inode.file,'INODES.INODE' END * RETURN * * Read record locking (which is what we want to report) * 3000 * * cmd = 'SH -c "smat -r < /dev/null > ':smat.file.name:' 2>&1"' EXECUTE cmd * OPENSEQ smat.file.name TO smat.capture.file THEN * GOSUB 3100 * LOOP READSEQ smat.capture.line FROM smat.capture.file ELSE smat.read.finished = 1 UNTIL smat.read.finished DO keyword=OCONV(FIELD(smat.capture.line,' ',1),'MCU') IF OCONV(keyword,'MCN')=keyword AND keyword#'' THEN BEGIN CASE CASE lock.type='G' NULL CASE lock.type='R' GOSUB 3300 CASE lock.type='W' GOSUB 3400 END CASE END ELSE IF keyword='ACTIVE' THEN lock.line = OCONV(smat.capture.line,'MCU') BEGIN CASE CASE INDEX('READ WAITERS',lock.line,1) lock.type = 'W' CASE 1 lock.type = FIELD(lock.line,' ',2)[1,1] END CASE smat.capture.line = smat.capture.line:' (':lock.type:')' IF print.on OR suppress.on THEN CRT smat.capture.line END END IF suppress.on ELSE PRINT smat.capture.line REPEAT * READU xxx FROM local.voc.file,t.file.ptr.key THEN DELETE local.voc.file,t.file.ptr.key END ELSE RELEASE local.voc.file,t.file.ptr.key END * CLOSESEQ smat.capture.file * GOSUB 3900 * END * RETURN * 3100 * * IF suppress.on ELSE IF print.on THEN * * Set the output * sp.cmd = 'SETPTR 0,156,48,1,1,1,FORM LP,PRINTER DEV-LJ,BRIEF' EXECUTE sp.cmd * PRINTER ON * PRINT CHAR(27):'E':; * Reset printer PRINT CHAR(27):'&l1O':; * Orientation Landscape PRINT CHAR(27):'(11U':; * Symbol set PRINT CHAR(27):'(s0p16.67h8.5v0s0b0T': * END END * t.file.ptr = '' t.file.ptr.key = 'SEM.CHECK.':@USERNO lock.type='' last.file.path = '' smat.read.finished = 0 * RETURN * 3300 * * device.no = TRIM(smat.capture.line[1,10]) inode = TRIM(smat.capture.line[12,9]) netnode = TRIM(smat.capture.line[23,7]) userno = TRIM(smat.capture.line[31,6]) item.id = TRIM(smat.capture.line[60,LEN(smat.capture.line) - = 59]) GOSUB 9200; * Find associated file name exec.cmd = 'RECORD ':t.file.ptr.key:' ':item.id GOSUB 9100 group.output = cmd.cap<1> hash.group = FIELD(group.output,' ',6) smat.capture.line = smat.capture.line'L#88':' ':file.name:' = (G':hash.group:')' * RETURN * 3400 * * inode = FIELD(TRIM(smat.capture.line),' ',2) GOSUB 9200 smat.capture.line = smat.capture.line'L#48':' ':file.name * RETURN * 3900 * * IF suppress.on ELSE IF print.on THEN PRINT CHAR(27):'E': PRINTER CLOSE PRINTER OFF END END * RETURN * * Execute command and trim results * 9100 * * EXECUTE exec.cmd, OUT > cmd.cap * LOOP WHILE cmd.cap#'' AND TRIM(cmd.cap<1>)='' DO cmd.cap = DELETE(cmd.cap,1) REPEAT * RETURN * * Find file-name associated with inode * 9200 * * file.path = '' * IF inode.file.open THEN IF inode.reconf.reset ELSE inode.list = '' READU inode.list FROM inode.file,'INODE.LIST' THEN inode.list = DELETE(inode.list,3) inode.reconf.reset = 1 END END END * LOCATE(inode,inode.list,1;i.ptr) THEN file.path = inode.list<2,i.ptr> IF inode.list<3,i.ptr> ELSE exec.cmd = 'SH -c "ls -i1 ':file.path:'"' GOSUB 9100 IF FIELD(TRIM(cmd.cap<1>),' ',1)=inode THEN inode.list<3,i.ptr> = 1 WRITEU inode.list ON inode.file,'INODE.LIST' END ELSE file.path = '' inode.list = '' END END END * IF file.path='' THEN * i.ptr = DCOUNT(inode.list<1>,CHAR(253)) + 1 * CRT 'Searching for inode ':inode'R#6' * * Look in the current directory... * sc = DCOUNT(cwd,'/') LOOP IF sc>1 THEN fwd = OCONV(cwd,'G/':sc) ELSE fwd = '/' exec.cmd = 'SH -c "nice -n 18 find ':fwd:' -inum ':inode:'"' CRT exec.cmd GOSUB 9100 WHILE cmd.cap='' AND sc>1 DO sc = sc - 1 REPEAT * file.path = TRIM(cmd.cap<1>) CRT ' ':file.path IF file.path='' ELSE LOCATE(inode,inode.list,1;i.ptr;'AR') ELSE NULL inode.list = INSERT(inode.list,1,i.ptr;inode) inode.list = INSERT(inode.list,2,i.ptr;file.path) inode.list = INSERT(inode.list,3,i.ptr;1) IF inode.file.open THEN WRITEU inode.list ON inode.file,'INODE.LIST' END * END * IF inode.file.open THEN RELEASE inode.file,'INODE.LIST' * IF file.path=last.file.path ELSE delim.count = DCOUNT(file.path,'/') IF delim.count>1 THEN root.path = OCONV(file.path,'G/':delim.count - 1):'/' file.name = FIELD(file.path,'/',delim.count) END ELSE root.path = '' file.name = FIELD(file.path,'/',delim.count) END droot.path = root.path IF droot.path='/avro/DATA/' OR droot.path='' THEN droot.path = '/avro/TL.DICTS/' END t.file.ptr = 'F' t.file.ptr<2> = root.path:file.name t.file.ptr<3> = droot.path:'D_':file.name READU xxx FROM local.voc.file,t.file.ptr.key ELSE NULL WRITE t.file.ptr ON local.voc.file,t.file.ptr.key RELEASE local.voc.file,t.file.ptr.key last.file.path = file.path END * RETURN * 9999 * * END