Article 4284 of vmsnet.internals:
Path: nntpd.lkg.dec.com!pa.dec.com!decwrl!genmagic!sgigate.sgi.com!swrinde!elroy.jpl.nasa.gov!lll-winken.llnl.gov!fnnews.fnal.gov!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
Newsgroups: vmsnet.internals
Subject: Re: block I/O error
Date: 22 Aug 1995 16:13:55 GMT
Organization: HST Wide Field/Planetary Camera
Lines: 98
Distribution: world
Message-ID: <41cvo3$nof@gap.cco.caltech.edu>
References: <41ctc4$g9p@news.arc.nasa.gov>
Reply-To: carl@SOL1.GPS.CALTECH.EDU
NNTP-Posting-Host: sol1.gps.caltech.edu

In article <41ctc4$g9p@news.arc.nasa.gov>, ragosta@merlin.arc.nasa.gov writes:
=
=I admit it, I'm confused.  The following program is intended to checksum all of
=the executables in the SYS$SYSTEM directory for security purposes.  It works
=fine, except that some of the files are open, thus returning a "file currently
=locked by other user" status from the SYS$OPEN.  This shouldn't cause a
=problem, as I check this status and don't process these files.

Actually, no, you don't.  Oh, you don't do all your explicit processing, but
you don't properly indicate to the Fortran RTL that the OPEN failed.

=      character *(*) infile
=      external myopen
=c
=      write(6,*) 'Processing ' // infile(1:length(infile))
=      OPEN (UNIT=2, FILE=infile(1:length(infile)), STATUS='OLD',
=     $  useropen=myopen, ERR=100)
=c
=      write(6,*) 'Done ' // infile(1:length(infile))
=      close(2,err=200)
=      return
=c
=100   i_crc = 0
=      i_auto = 0
=200   return
=      end
=c
=c---end checks
=c
=      integer function myopen (fab,rab,lun)
=      include '($fabdef)'
=      include '($rabdef)'
=      include '($syssrvnam)'
=      record /fabdef/ fab
=      record /rabdef/ rab
=      character *512 buff
=      common /table/ crc_table(16,2), i_crc, i_auto
=      integer crc_table
=c
=      i_crc  = 0
=      i_auto = 0
=      myopen = 1
=c
=c --- set block mode
=c
=      fab.fab$b_fac = fab.fab$b_fac .or. fab$m_bio
=c
=      istat = sys$open(fab)
=      if (istat) then
=      write(6,*) '>',istat
=         istat = sys$connect(rab)
=         if (.not. istat) then
=            i_crc  = istat
=            i_auto = 0
=            return
=         endif
=      write(6,*) '>>',istat
=      else
=         i_crc  = istat
=         i_auto = 0
=         return
=      endif
=c
=c --- num bytes to read/buffer
=c
=      rab.rab$w_usz = 512
=      rab.rab$l_ubf = %loc (buff)
=c
=c --- read blocks
=c
=10    istat = sys$read(rab)
=      if (.not. istat) then
=c        if (istat .ne. rms$_eof) ???
=      write(6,*) '>>>',istat
=         return
=      endif
=      i_crc  = lib$crc (crc_table(1,1), i_crc, buff)
=      i_auto = lib$crc (crc_table(1,2), i_auto, buff)
=      go to 10
=c
=      end
=c
=c---end myopen
=c

Note that myopen always returns 1.  It shouldn't do that.  It should return the
status returned by SYS$OPEN (if it fails) or SYS$CONNECT (if SYS$OPEN
succeeds).  That's the only way the Fortran RTL knows whether the OPEN call
succeeded or failed.  I don't know whether that's the reason for your problem,
but it might be.
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.


