Appendix E.3 Creating an input file on EasyMT tape

EasyMT is a program product that uses a variable-length blocked tape such as in E.2 Creating an input file on variable-length blocked tape and provides tape management by means of volume names and file names.

Organization of this subsection
(1) Main media
(2) File name examples
(3) Creating a file name
(4) Overview
(5) Input file creation example

(1) Main media

DAT,CGMT,OMT

(2) File name examples

/dev/dat/vdat010 (internal DAT),

/dev/cgmt/vcgmt160 (cartridge magnetic tape),

/dev/omt/vomt055 (open reel magnetic tape)

(3) Creating a file name

To install a variable-length blocked device, the file name must first be created.

The super user then executes the following command:

/etc/mknod /dev/dat/vdat010 c 119 0x010001
/bin/chmod 0666 /dev/dat/vdat010
Explanation:
Normally, when this command is executed, a variable-length blocked access device for the internal DAT is created.
/dev/dat/vdat010: Device name
c: Character special file
119: Major number (indicates DAT variable block usage)
0x010001: Minor number (indicates internal DAT is used in compressed mode)
Refer to man below for unknown words or concepts.
mknod or chmod: man lm mknod or man chmod
Instruction name rule for major numbers, minor numbers, and device names: man 6 mt

(4) Overview

EasyMT has the following header formats:

SymbolDescription
EMTVOL_ELEasyMT label
EMTVOL_SLStandard label
EMTVOL_JLJIS code label
EMTVOL_NLNo label

The header is read first by the database load utility (pdload), and then items in a recognizable format are read. An error results if the format is not recognizable or there is no label.

EasyMT has the following record formats:

SymbolDescriptionBlock specificationRecord specificationLabel specification
FFixed-length non-blocked recordsNFSL or EL
FBFixed-length blocked recordsB
VVariable-length non-blocked recordsNV
VBVariable-length blocked recordsB
UUnspecified-length recordsNU

The database load utility (pdload) can support all the above formats. However, the maximum of the set containing the block length, record length, or data length is as follows:

Model where file is createdMaximum value
3050RX Group32KB (32,768 bytes)
3500 Series
HITAC-M Series32KB-8 (32,760 bytes)

Because the length of one record in the F and FB record formats is fixed, only FIX tables and tables in which the column structures of all rows are fixed-length and which are input as a binary file can use these formats. If the input is an ASCII file, these formats can be used only when all data lengths are the same.

The database load utility (pdload) can handle the following two types of files as input files:

(a) Binary-format files

Binary-format files have the record formats shown as follows.

F (Fixed-length non-blocked records)

[Figure]

FB (Fixed-length blocked records)

[Figure]

One row is specified as the data length (record length).

F or FB can be specified only for FIX tables or tables in which the column structures of all rows are fixed in length.

V (Variable-length non-blocked records)

[Figure]

VB (Variable-length blocked records)

[Figure]

U (Unspecified-length records)

[Figure]

(b) DAT-format files

DAT-format files have one record per row (up to NL characters). The normal record formats are V, VB, or U. The F and FB formats can be used only if the data lengths are all the same.

The data length includes NL (LF: 0x0a, '\n'). Records that do not include NL result in an error.

[Figure]

The maximum and minimum values for the data length, record length, and block length above are as follows:

File created on the 3050RX Group and 3500 Series
Record FormatData lengthRecord lengthBlock length
minmaxminmaxminmax
F/FB132,768132,768132,768
V/VB132,760532,764932,768
U132,768----132,768
File created on the HITAC-M Series
Record FormatData lengthRecord lengthBlock length
minmaxminmaxminmax
F/FB132,760132,760132,760
V/VB132,752532,756932,760
U132,760----132,760

(5) Input file creation example

Following is an example of creating an input file on the 3050RX Group or the 3500 Series for the database load utility (pdload) using the functions provided by EasyMT.

The EasyMT definition is specified in the MT attributes definition file.

(a) Program example

The MT attributes definition file is specified in the first argument (argv[1]).

Specify error processing as required.

#include    <stdio.h>
#include    <stdlib.h>
#include    <unistd.h>
#include    "easymt.h"
#define     PROC_BUFSIZ     1024 * 32
char        buf[PROC_BUFSIZ];
int         data_len;               /* data length */
    :
void main(int argc, char *argv[])
{
    EmtDescr_t* emt_fp;
    if (EmtInit(NULL, argv[1])) {
        printf("EmtInit failure, ,EmtErrno=%i\n", EmtErrno);
        exit(EXIT_FAILURE);
    }
    if (emt_fp = EmtAlloc(NULL, argv[1])) {
    } else {
        printf("EmtAlloc failure, ,EmtErrno=%i\n", EmtErrno);
        exit(EXIT_FAILURE);
    }
    if (EmtFopen(emt_fp, NULL)) {
        printf("EmtFopen failure, ,EmtErrno=%i\n", EmtErrno);
        goto proc_free;
    }

    while(while there is data) {
            :

Data is loaded into buf; the data length is assigned to data_len.
For DAT format data, NL (0x0a) is included in the data.

            :
        rc = EmtWrite(emt_fp, buf, data_len);
        if (rc != data_len) {
            printf("EmtWrite failure,EmtErrno=%i\n", EmtErrno);
            goto proc_close;
        }
    }
proc_close:
    if (EmtFclose(emt_fp)) {
        printf("EmtFclose failure,EmtErrno=%i\n", EmtErrno);
        goto proc_free;
    }

proc_free:
    if (EmtFree(emt_fp)) {
        printf("EmtFree failure,EmtErrno=%i\n", EmtErrno);
        exit(EXIT_FAILURE);
    }
}

(b) MT attributes definition file example

In the definition file, a blank immediately following an equals sign (=) means that the corresponding value is omitted.

Device name: /dev/dat/vdat010
Buffer sectors count: 2
Volume name: HiRDB
Label type: Standard label (SL)
File name: input_data
Open mode: Write-specified
Record type: VB maximum value
To handle the M-series, the maximum value is set to 32 KB - 8 bytes (32,760 bytes).
A data length of up to the record length - 4 bytes (32,752 bytes) can be handled.

The following entries in the MT attributes definition file correspond to pdload control information file source statement entries:

MT Attributes definition file entrypdload control information file source statement entryMaximum number of characters
volname=vol=6
filename=file=17#
#: When an MT file is created on the HITAC-M series, a file name of up to 44 characters can be specified; however, only the last 17 characters are valid characters, and must be specified as such.
Because the bufno entry is simply the specification of the buffer sectors count to be used for writing, there is no need to match it to the pdload specification.

An example definition for creating the above file is as follows:

#/*-------------------------------------------------------
#
(1) Operating specifications
#/*-------------------------------------------------------
devname=/dev/dat/vdat010
blking=OFF
bufno=2
#/*-------------------------------------------------------
#   (2) Volume attribute specifications
#/*-------------------------------------------------------
volname=HiRDB
voltype=SL
#/*-------------------------------------------------------
#   (3) File attribute specifications
#/*-------------------------------------------------------
filename=input_data
openmode=EMT_WRONLY
blklen=32760
reclen=32756
blktype=B
rectype=V