Programming examples, provided by Richard Sims

As a systems programmer of many years, I've had to deal with a lot of things, and have learned a lot in the process. Here, from my experience, are example C programs showing how to accomplish various things. The examples are intended to illuminate and demonstrate approach: they are not necessarily comprehensive, and are not full applications. Nevertheless, they are quite viable unto themselves: they represent the test cases which I subsequently fold into a comprehensive system monitoring facility that I developed. The system facilities upon which the sample programs are based can, of course, change over time. Thus, the sample programs may not contain elements reflecting the most current system features.

The sample programs may contain supplementary functions, located ahead of the main() function (which is a natural, self-prototyping order).

Note: The programs use Tab characters for indentation, which some web browsers may cause to look awry. You would probably want to just copy the examples anyway, as via the Web browser "Save Linked File As..."


3494 tape library inquiry and monitoring

Customers of IBM's 3494 and similar libraries know about the 'mtlib' command, which comes with the atldd device driver. The command is based upon operations documented in the IBM manual set:
  "IBM TotalStorage Tape Device Drivers: Installation and User's Guide",
   (GC35-0154) (a renaming of the earlier manual "IBM SCSI Tape Drive, Medium
    Changer, and Library Device Drivers: Installation and User's Guide", of the
    same publication number)
  "IBM TotalStorage Tape Device Drivers: Programming Reference" (GC35-0346)
   (a renaming of the earlier manual "IBM SCSI Tape Drive, Medium Changer, and
    Library Device Drivers: Programming Reference" (WB2107))
	Available at ftp://ftp.storsys.ibm.com/devdrvr/Doc/
		     (refer to the .message or README file in that directory)
		  or ftp://ftp.software.ibm.com/storage/devdrvr/Doc/  as files:
	 IBM_TotalStorage_tape_IUG.ps      or  IBM_TotalStorage_tape_IUG.pdf
	 IBM_TotalStorage_tape_PROGREF.ps  or  IBM_TotalStorage_tape_PROGREF.pdf
The sample program provided here illustrates inquiring for specific information, and monitoring for events. The mtlibio.h header file is your quick guide as what is and is not possible through the atldd interface: if there's no data definition for something, you can't access it. For example, the device driver does not track tape drive cleanings (which can instead be reported from the AIX Error Log).

The program is written for the AIX environment, but can be readily adapted for other environments by noting the differences per the Programming Reference manual: the open(), ioctl(), and close() calls may vary, but the essence of the calls is the same across platforms.

Notes:
There is no way to retrieve information about what tapes are in what 3494 storage cells. Libraries containing a Library Manager make it unnecessary for host programs to know such info, as tapes are mounted simply by asking the LM to mount the tape, and it knows what cell the tape is in per its database.
Don't overlook TSMManager as an information source.

See 3494 sample program


Tape Labels Inspection

Here's a C program I wrote to inspect tape labels, from an AIX environment... where the environment is ASCII and IBM standard tape labels are EBCDIC. (Refer to topic Tape labels in ADSM QuickFacts for more info on tape labels.)

Whereas the program was written for a certain environment, I would be happy to entertain feedback for generally improving its applicability in other environments and conditions as well.

See the tape labels interpreter sample program


AIX Error Log entries retrieval

AIX systems people know of the 'errpt' command. Throughout the life of AIX4 there was also a (poorly documented) system call to retrieve the same information called error_log_get(). I had "fun" figuring out exactly how it is supposed to be used. Worse, though, is the utterly undocumented task of interpreting detail data that is returned. The sample program illustrates some areas that I have figured out: much mystery remains, however.

AIX 5.x provides a much more straighforward, documented set of C functions for traversing the Error Log, via new /lib/liberrlog.a functions: errlog_open(), errlog_find_first(), errlog_find_next(), errlog_find_sequence(), errlog_set_direction(), errlog_close().

See AIX4 Error Log sample program


If you have any comments or suggestions, you can email me: rbs at bu.edu