| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |

December 2004

Boosting your e3000 productivity

MPE for UNIX Users, Part 3
The Complex World of Files

By Robert Green

Last month we explored the directory structure of MPE a bit to explain about logging on. This month we look at files to see how they are different from files in Unix.

The File System is one area where MPE is really different from Unix. And much more complicated. Let’s start by building a file, using the command :build abc.

Seems just like touch abc in Unix, right? Wrong – the build command has lots of optional parameters, all with defaults. To see what we “built,” we use the listf command (this is like ls –l in Unix):

:listf abc,2
ACCOUNT=  GREEN       GROUP=  BOB

FILENAME  CODE  ------------LOGICAL RECORD-----------  ----SPACE----
                   SIZE  TYP        EOF      LIMIT R/B  SECTORS #X MX

ABC               128W  FB           0       1023   1        0  0  *

The listf,2 option shows the most common attributes of an MPE file. Other options show access dates, creator name, and other attributes.

FILENAME – file names are limited to 8 characters and case is not significant; just as explained for user and account names in part 2.

CODE – a file type number that tells you what type of content the file should hold. Some of these have mnemonic labels, but underneath all are integer values. For example, 111 is a QEDIT workfile, 1030 is an NMPROG file. The default code is 0 (i.e., nothing special). For a list of file codes used by HP and third-party vendors, go to www.robelle.com/smugbook/filecode.html

A negative file code makes the file a “privileged file” which can only be opened by a program running in privileged mode (in user mode, programs cannot access or change data that is not their own; in privileged mode, programs can get at data outside the program; the operating system runs in a special privileged mode). The most well known example of privileged files in MPE is database files; they can only be accessed by going through the database API (or by going into privileged mode, access to which is restricted by system security).

SIZE – specifies the record size. Unix files do not have records; a file is just a stream of bytes. But MPE files have a record structure (except for Posix bytestream files, which are like Unix files).

The record size is the amount of data that is read or written by a single call to MPE’s FREAD or FWRITE intrinsic. An intrinsic is an MPE system routine, just like fread and fwrite in Unix.

The default record size is 128 words (which is 256 bytes, because the original HP 3000 was a 16 bit machine).

TYP – FB means “fixed, binary”. Fixed is the record format, meaning that each record contains exactly 128 words. Another option is V for Variable. Binary means that if a fixed record is incomplete, it is filled out with binary zero. The alternative A for ASCII means that incomplete records are filled with blanks. Also, when a file is ASCII, the SIZE column will show the record size in Bytes (128B for example).

EOF – tells you how many logical records have been written into the file (actually, it shows you the highest record number that has been written). An empty file like this always shows 0 for the EOF.

LIMIT – tells you the maximum number of logical records that can be written into the file (for variable length records this number is based on writing maximum length records, so it is often not the real limit). The LIMIT concept is completely alien to Unix. In MPE, a program can fail because it attempts to append a record to a file that has reached its LIMIT, even though the system still has lots of free disk space.

R/B – Records Per Block. In the original MPE you specified the number of logical records to be stored in a physical block of disk storage (a block was the amount normally transferred to/from disk). Over the years, the internals of MPE have changed so much that this attribute does not mean much anymore, although it is maintained for compatibility.

SPACE, SECTORS – Logical disk space in MPE is measured in “sectors,” which are 256 bytes each. As records are written into a new file, disk space is allocated in chunks called “extents” and this SECTOR value goes up. Again this unit of measure is just for historical compatibility, since the current version of MPE actually manages disk space in pages, which are much larger. If you would like more explanation, please see www.robelle.com/smugbook/pages.html

SPACE, #X MX – disk space is allocated in extents, so #X is the number of extents currently allocated to the file and MX is the maximum number that can be allocated. In the old days, MX was limited to 32 and #X went from 0 to 32, at which point the file was full. And all extents, except the last one, were the same size.

Now the default MPE file has * for MX, which means that there is no effective limit on the number of extents. However, you still must have a fixed number for the LIMIT on logical records, even if that number is 2 billion!

Be warned that if you create a file with a fixed number of extents and a large LIMIT in logical records (for example, build def;disc=123456789,32), you may very well get an error such as “extent size too large.”

Here are some additional file attributes for MPE:

USER LABELS are optional 256 byte areas for control information that are tacked onto the start of the file space. Typical examples are Self-Describing files and Powerhouse subfiles, where the data dictionary is stored in the user labels; this leaves all the logical records with the same data format. Historically they come from old mainframe systems, even going back to tape-based systems where the tapes had labels on them! They are most commonly used in COBOL systems that were migrated from these old IBM systems. The typical file on MPE has 0 user labels.

CCTL – stands for Carriage Control. A file with the CCTL attribute has an extra byte at the beginning of each logical record which tells whether to do a page eject, single space, double space, or more obscure function before (or after) printing the record. These are not the same as Spool files; they are more like antique portable print files. This capability goes back to old line printers, which had program tapes, which could be customized for special forms such as pre-printed invoices. What is interesting is that most of MPE’s simulated line printer functionality still works on Deskjet printers and terminal screen emulators because MPE converts the CCTL codes into terminal codes.

The default for an MPE file is build abc;nocctl. For more on CCTL files: see www.robelle.com/smugbook/cctl.html.

TEMP – stands for temporary files. On Unix, temporary files are just permanent files that are built in a special directory, such as /var/temp. Unix does not normally have an automatic cleanup for temporary files after a user logs off. MPE temp files are different because they are actually temporary. They are not recorded in the regular file directory, but in a temp directory that is attached to the user logon (interactive session or batch job). Any process created during the logon can access the temp files of that session/job and when the session/job logs off, the temporary file space is returned to the system.

MPE even has process-temporary files that are private to a program and go away when that process terminates or aborts. These are called NEW files and can be saved as Temporary or Permanent files by the process.

CIR, MSG – stands for Circular or Message file. MPE has special files where the current record pointer either wraps around (CIR) or moves in such a way that a fread erases the record that is read (MSG).

KSAM, KSAMXL – these are indexed sequential files, with KSAM being the original, classic MPE version and KSAMXL being the rewrite for the RISC processors and MPE/XL (now called MPE/iX).

So, you can see that our simple build abc is actually a much more complex command:

:build abc;rec=128,1,F,binary;disc=1024;code=0; &

std;ulabel=0;nocctl

Tune in next month for details on how to work with the content of all these file types!


Copyright The 3000 NewsWire. All rights reserved.