File Error Information [ Getting System Information Programmer's Guide ] MPE/iX 5.0 Documentation
Getting System Information Programmer's Guide
File Error Information
Several file system intrinsics are designed specifically for handling
errors. If an I/O error occurs, most file system intrinsics return a
condition code indicating this. Three intrinsics are used to determine
the nature of the error, to return an error message, and to print a file
information display. These are described in the following paragraphs.
Returning file system error codes with FCHECK
The FCHECK intrinsic returns an error code that indicates the nature of a
file system I/O error. A table of error codes appears in the MPE/iX
Intrinsics Reference Manual (32650-90028), or you can use FERRMSG
(described below) to display an error message.
NOTE FCHECK cannot be used to determine a file system error number for a
failed HPFOPEN call. Check the status parameter of HPFOPEN for
this information.
FCHECK has five optional parameters. The filenum parameter indicates the
file for which error information is to be returned. If you set this
parameter to zero, FCHECK assumes that you want information about the
last failed FOPEN call. The error code is returned in the errorcode
parameter.
Three other parameters give additional information about file system
errors. The tlog parameter returns the number of halfwords read or
written if an I/O error occurs. The blknum parameter gives the logical
record count for a spoolfile or the physical record count for any other
type of file. The numrecs parameter returns the number of logical
records in the block where an error occurred.
You must use the FCHECK intrinsic prior to calling FERRMSG, since the
error code returned by FCHECK is used as a parameter in the call to
FERRMSG.
Returning error messages with FERRMSG
The FERRMSG intrinsic is used following a call to FCHECK, to return an
error message explaining the nature of a file system error. It has three
required parameters: errorcode is the error number returned by FCHECK,
msgbuf returns the error message, and msglgth returns the length of the
error message returned in msgbuf.
Example 2-11 demonstrates how to use FCHECK and FERRMSG to return an
error message. This example shows a call to FCLOSE. If this returns a
CCL condition, a call to FCHECK requests the error code; then FERRMSG
returns the error message associated with this code:
_________________________________________________
| |
| |
| |
| FCLOSE(FILENUM,1,0); |
| IF < |
| THEN BEGIN |
| FCHECK(FILENUM,ERRNUM); |
| FERRMSG(ERRNUM,MESSAGE,LENGTH); |
| PRINT(MESSAGE,-LENGTH,0); |
| END; |
| TERMINATE; |
| |
_________________________________________________
Example 2-11. Using FERRMSG to Return an Error Message
If the FCHECK code has no assigned meaning, the following message
appears:
UNDEFINED ERROR errorcode
Displaying file error information with PRINTFILEINFO
The PRINTFILEINFO intrinsic (spelled PRINT'FILE'INFO for SPL users)
prints a file information display on the job or session list device. The
information shown depends upon whether or not a file was opened when the
error occurred. The significance of the fields on these displays is
explained in detail in the MPE/iX Intrinsics Reference Manual
(32650-90028).
For files not yet opened, or for which the FOPEN intrinsic failed, the
display is shown in example 2-12.
______________________________________________________________
| |
| |
| +F-I-L-E---I-N-F-O-R-M-A-T-I-O-N---D-I-S-P-L-A-Y+ |
| ! FILE NUMBER 5 IS UNDEFINED. ! |
| ! ERROR NUMBER: 2 RESIDUE: 0 (WORDS) ! |
| ! BLOCK NUMBER: 0 NUMREC: 0 ! |
| +-----------------------------------------------+ |
| |
______________________________________________________________
Example 2-12. File Information Display - Unopened File
For files that were open when a CCG (EOF error) or CCL (irrecoverable
file error) was returned, the file information display appears as shown
in example 2-13.
______________________________________________________________
| |
| |
| +-F-I-L-E---I-N-F-O-R-M-A-T-I-O-N---D-I-S-P-L-A-Y+ |
| ! FILE NAME IS TREEFILE.PSMG.LOZAR ! |
| ! FOPTIONS: NEW,ASCII,FORMAL,F,NOCCTL,FEQ, ! |
| ! NOLABEL ! |
| ! AOPTIONS: INPUT,NOMR,NOLOCK,DEF,BUF,NOMULTI, ! |
| ! WAIT,NOCOPY ! |
| ! DEVICE TYPE: 0 DEVICE SUBTYPE: 9 ! |
| ! LDEV: 2 DRT: 4 UNIT: 1 ! |
| ! RECORD SIZE: 256 BLOCK SIZE: 256 (BYTES) ! |
| ! EXTENT SIZE: 128 MAX EXTENTS: 8 ! |
| ! RECPTR: 0 RECLIMIT: 1023 ! |
| ! LOGCOUNT: 0 PHYSCOUNT: 0 ! |
| ! EOF AT: 0 LABEL ADDR: %00201327630 ! |
| ! FILE CODE: 0 ID IS PAULA ULABELS: 0 ! |
| ! PHYSICAL STATUS: 1000000000000001 ! |
| ! NUMBER WRITERS: 0 NUMBER READERS: 1 ! |
| ! ERROR NUMBER: 0 RESIDUE: 0 ! |
| ! BLOCK NUMBER: 0 NUMREC: 1 ! |
| +------------------------------------------------+ |
| |
______________________________________________________________
Example 2-13. File Information Display - Opened File
Writing a file system error check procedure
Error checking intrinsics can be used throughout a program every time
there is an intrinsic call. Instead of repeating a call to PRINTFILEINFO
many times, it is more efficient to write an error check procedure and
call this procedure where necessary.
Example 2-14 is a sample error check procedure, named FILERROR. This
procedure is declared at the beginning of the program; from that point
on, it can be called with a single statement.
The procedure contains two parameters. FILENO is an identifier through
which the file number is passed; PRINTFILEINFO then prints a file
information display for that file. QUITNO is part of the abort message
printed by the QUIT intrinsic. This enables you to determine the point
at which the process was aborted. For more information, refer to the
Process Management Programmer's Guide (32650-90023).
________________________________________________
| |
| |
| PROCEDURE FILERROR(FILENO,QUITNO); |
| VALUE QUITNO; |
| INTEGER FILENO,QUITNO; |
| BEGIN |
| PRINTFILEINFO(FILENO); |
| QUIT(QUITNO); |
| END; |
| |
________________________________________________
example 2-14. Error Check Procedure Using PRINTFILEINFO
MPE/iX 5.0 Documentation