Ever wondered how to get some fresh files accessible by FreeAXP without a network connection like FTP, NFS or Samba ?
Using a disk image, is a somewhat cumbersome but effective method it seems.
I tried successfully with a backup container, a zip file and en executable (self extracting zip).
Startup FreeEXP in the configuration screen; point a free device to the file to be imported; Boot FreeAXP; mount/foreign the new device; and copy blocks into a file!
A tricky part was that best I know there is no native OpenVMS tool to copy using Logical Block IO. So I wrote a tool. See below.
(sorry, the ...
tags still drop spaces. Sent Email!)
The cumbersome part is that a config/reboot is needed.
I don't suppose we can dynamically alter the mapping.
The buggy part was that the image is presented as truncated down to 512 bytes blocks. Fine for EXE and BCK files, not so good for ZIP.
Would it be desirable for FreeAXP to round up to the next full 512 rather then truncate? I don't know. It may cause an IO error when the last block is tried to be read. Physically add null bytes to round up?
The workaround I used for this was to APPEND some bytes to the file to fill out the last block, using ECHO or PERL. For example:
# echo "nou, eens ff kijken of we er een blockje bij kunnen toveren" >> test.zip
or
# perl -e "print q(*)x511" >> test.zip
This made it all work for me.
Now if only we had a simple ODS2 & ODS5 non-shared file manipulation tool on Windoze! Just delete and copy in and out to start with. No directory create or growth for starters. INDEXF, BITMAP...
The inverse, export process would be harder as one would need to sufficiently pre-allocate the target. Still, it coudl be a viable method to get for example a somewhat predictable SYSDUMP.DMP file of the system.
Comments?
Hein
$ type COPY_LBN_SIMPLE.C
// copy_lbn_simple.c Hein van den Heuvel, March 2011,
// HvdH Performance Consulting
// A more complete version with statistics, selectable buffers sizes
// and more feature is available. Working on double buffering.
# define DEFAULT_BLOCKS 128
#define __NEW_STARLET
#include rms
#include iodef
#include dvidef
#include prvdef
#include syidef
#include string
#include stdio
__align (8) char io_buffer [ DEFAULT_BLOCKS * 512 ];
int sys$create(), sys$connect(), sys$write(), sys$close();
int sys$assign(), sys$getdviw(), sys$qiow(), sys$setprv();
struct RAB64 rab;
struct FAB fab;
main(int argc, char *argv[]) {
unsigned int privs[] = { PRV$M_LOG_IO, 0}, prvprv[2],
status, mounted, blocks_left, channel = 0, lbn = 0,
io_size = DEFAULT_BLOCKS*512,
blocks_per_io = DEFAULT_BLOCKS;
struct { short status, byte_count_low, byte_count_hi, mbz; } iosb;
struct { long count; void *address; } devnam_desc;
struct { short len, cod; void *address; int *retlen; }
getdvi_items[] = { 4, DVI$_MAXBLOCK, &blocks_left, 0,
4, DVI$_MNT, &mounted, 0, 0,0,0,0};
// Set up FAB and RAB for FIXED Length 512 Byte output file and large buffers
fab = cc$rms_fab;
rab = cc$rms_rab64;
fab.fab$b_fac = FAB$M_PUT | FAB$M_BIO ;
fab.fab$w_mrs = 512;
fab.fab$b_rfm = FAB$C_FIX;
rab.rab64$l_fab = (void *) &fab;
rab.rab64$l_rop = RAB$M_BIO;
rab.rab64$l_rbf = (char *) -1;
rab.rab64$l_ubf = (char *) -1;
rab.rab64$pq_rbf = (void *) io_buffer;
rab.rab64$q_rsz = io_size;
// Check for arguments and grab privs.
if (argc < 3 ) {
fprintf (stderr, "Usage: %s <input_device:> <output_file>\n", argv[0]);
return 268435472;
}
status = sys$setprv ( 1, privs, 0, prvprv);
if (!(status == 1) &&
((privs[0] & prvprv[0]) != privs[0])) { // SS$_NOTALLPRIV = 1665
fprintf (stderr, "Sorry, could not get required LOG_IO privilege.\n");
return status;
}
// Get a channel for QIO access, and obtain target size
devnam_desc.address = argv[1];
devnam_desc.count = strlen (argv[1]);
status=sys$assign(&devnam_desc,&channel,0,0,0);
if (status&1) status = sys$getdviw(0, channel,
0, getdvi_items, &iosb, 0,0 ,0 ,0);
if (!(status & 1)) return (status);
if ( !blocks_left || !mounted ) { // Needs, to be at least FOREIGN mounted.
fprintf (stderr, "%d blocks, device is %s mounted.\n",
blocks_left, (mounted)? "" : "NOT" );
return 124; // %SYSTEM-F-DEVNOTMOUNT, device is not mounted
}
// Create output file with initial size
fab.fab$l_fna = argv[2];
fab.fab$b_fns = strlen( argv[2] );
fab.fab$l_alq = blocks_left;
status = sys$create ( &fab);
if (status & 1) status = sys$connect ( &rab);
// Loop reading and writing while all is well and something left to copy
while (blocks_left && status & 1) {
if (blocks_left < blocks_per_io) {
blocks_per_io = blocks_left;
io_size = blocks_per_io * 512;
rab.rab64$q_rsz = io_size;
}
// Read and write IO
status = sys$qiow(0, channel, IO$_READLBLK, &iosb,
0,0, io_buffer, io_size, lbn, 0,0,0);
if (status & 1) status = iosb.status;
if (status & 1) {
status = sys$write ( &rab );
if (status & 1) {
lbn += blocks_per_io;
blocks_left -= blocks_per_io;
// Read and Write Error handling
} else {
printf ("SYS$WRITE error %d after %d blocks read at LBN %d\n",
status, blocks_per_io, lbn);
}
} else {
printf ("QIO LBN READ error %d for %d blocks read at LBN %d\n",
status, blocks_per_io, lbn);
}
}
// All done
if (status & 1) status = sys$close (&fab);
return (status);
}
Hein van den Heuvel
HvdH Performance Consulting
firstnamelastname.gmail.com |