File systems

PASE for i programs can access any file or resource that is accessible through the integrated file system, including objects in the QSYS.LIB and QOPT file systems.

Buffered input and output

Input and output to and from external devices is buffered on the IBM® i operating system. It is handled by input and output processors that deal with blocks of data. Conversely, operating systems, such as AIX® and Linux, typically operate with character-by-character (unbuffered) input and output. On the IBM i operating system, only certain input and output signals (for example, the Enter key, function keys, and system request) send an interrupt to the system.

Data conversion support

PASE for i programs pass ASCII (or UTF-8) path names to the open() function to open byte stream files. The names are automatically converted to the encoding scheme used by the IBM i operating system, but any data read or written from the open file is not converted.

Use of file descriptors

The PASE for i run time normally uses ILE C run time support for files stdin, stdout, and stderr, which provide consistent behavior for PASE for i and ILE programs.

PASE for i and ILE C use the same streams for standard input and output (stdin, stdout, and stderr). PASE for i programs always access standard input and output using file descriptors 0, 1, and 2. ILE C, however, does not always use integrated file descriptors for stdin, stdout, and stderr, so PASE for i provides a mapping between PASE for i file descriptors and descriptors in the integrated file system. Because of this mapping, PASE for i programs and ILE C programs can use different descriptor numbers to access the same open file.

You can use the PASE for i extension on the fcntl() function, F_MAP_XPFFD, to assign an PASE for i descriptor to an ILE number. This is useful if your PASE for i application needs to do file operations for an ILE descriptor that was not created by PASE for i.

An IBM i system-unique extension to the fstatx() function, STX_XPFFD_PASE, allows an PASE for i program to determine the integrated file system descriptor number for an PASE for i file descriptor. Special values (negative numbers) are returned for any PASE for i descriptor attached to ILE C runtime support for files stdin, stdout, and stderr.

If the ILE environment variable QIBM_USE_DESCRIPTOR_STDIO is set to Y or I when the Qp2RunPase() API is called, PASE for i synchronizes file descriptors 0, 1, and 2 with the integrated file system so that both PASE for i and ILE C programs use the same descriptor numbers for files stdin, stdout, and stderr. When operating in this mode, if either PASE for i code or ILE C code closes or reopens file descriptor 0, 1, or 2, the change affects stdin, stdout, and stderr processing for both environments.

PASE for i run time generally does no character encoding conversion for data read or written through PASE for i file descriptors (including sockets), except that ASCII-to-EBCDIC conversion is done (between the PASE for i CCSID and job default CCSID) for data read from ILE C stdin or written to ILE C stdout and stderr.

Two environment variables control the automatic translation of stdin, stdout, and stderr:

  • The variable that generally applies is QIBM_USE_DESCRIPTOR_STDIO. When set to Y, the ILE runtime uses file descriptor 0, 1, or 2 for these files.
  • The PASE for i system-specific environment variable is QIBM_PASE_DESCRIPTOR_STDIO. It has values of B for binary and T for text.

ASCII-to-EBCDIC conversion for PASE for i stdin, stdout, and stderr is disabled if the ILE environment variable QIBM_USE_DESCRIPTOR_STDIO is set to Y and QIBM_PASE_DESCRIPTOR_STDIO is set to B (allowing binary data to be read from stdin and written to stdout or stderr). The default for QIBM_PASE_DESCRIPTOR_STDIO is T for text. This value causes translation of EBCDIC to ASCII.