Open System Services Programmer's Guide

/* Set the completion elements for the OSS file and the Guardian file */
comp_elem[0].z_fnum_fd = fd; /* OSS file */
comp_elem[0].u_z_options.z_options.z_filetype = 1;
comp_elem[0].u_z_options.z_options.z_read_ready = 1;
comp_elem[0].u_z_options.z_options.z_exception = 1;
comp_elem[1].z_fnum_fd = filenum; /* Guardian file */
comp_elem[1].u_z_options.z_options.z_filetype = 0;
status = FILE_COMPLETE_SET_((short *) comp_elem, 2, &err_elem);
if(status) {
if(err_elem)
fprintf(stderr, "Error %d in FILE_COMPLETE_SET for OSS file = \
%s\n", err_elem, pathname);
else
fprintf(stderr, "Error %d in FILE_COMPLETE_SET for Guardian file = \
%s\n", err_elem, filename);
exit(1);
}
/* Start non-blocking I/O on OSS file */
nb = read(fd, bufoss, 1024);
if(nb < 0) {
fprintf(stderr, "OSS file read error %d\n", nb);
exit(1);
}
/* Start nowait read on the Guardian file using READX.
Note that a request tag is not required when only one
outstanding read is issued. It is shown here for
demonstration purposes only. */
request_tag = 123; /* form unique request tag */
CC = READX( filenum, /* file number */
bufgdn, /* buffer address */
1024, /* size of buffer */
, /* number of bytes read, not
used for nowait I/O */
request_tag /* unique request tag */
);
/* If the condition code returned is not the one for success,
print a message and exit. */
if(_status_ne(CC)) { /* check the success condition code */
fprintf(stderr, "Read failed on Guardian file\n");
exit(1);
}
/* Get info. about the set of files enabled for common completion */
status = FILE_COMPLETE_GETINFO_(
(short *) info_list, /* array of information elements */
2, /* only two requested */
&num_elem /* actual number of files */
);
if(status) {
fprintf(stderr, "File Complete Getinfo error %d\n", status);
exit(1);
}
/* The program can execute code while the read operations are being
completed by the system. */
for (i = 0; i < 100000; i++) ;
printf("Now issuing FILE_COMPLETE_ to check for I/O completion.\n");
status = FILE_COMPLETE_(
(short *) &comp_info /* completion information */
, /* time limit (* 0.01 sec.) */
, /* array of complete elements */
, /* number of complete elements */
, /* error index */
);
if(status) {
exit(1);
}
/* AWAITIOX completes the READX operation. */
CC = AWAITIOX(&filenum , /* file number */
,
The OSS and Guardian File Systems 61