From: MERC::"uunet!WKUVX1.BITNET!MacroMan" 23-FEB-1993 04:13:59.91 To: MACRO32@WKUVX1.BITNET CC: Subj: Here is some code for reading ODS-2 using LOGIO Can anyone think of a reason you would want to be able to read an ODS-2 disk by using LOGICAL IO operations or by mounting the device /foreign? If you do, here are the changes required to make that ODS-2 reader for Unix recently posted work under VMS. Changes to get the GETVMS.C ODS-2 reader for Unix running under VMS. e.g. $ define disk$users dka0: $ getvms -l [000000] 000000.DIR;1 BACKUP.SYS;1 BADBLK.SYS;1 BADLOG.SYS;1 BITMAP.SYS;1 CONTIN.SYS;1 CORIMG.SYS;1 EWS$LIBRARY.DIR;1 EWS$SERVER.DIR;1 INDEXF.SYS;1 ...etc... First change references to vms into vmsfd; int vmsfd = -1; Otherwise you would have to #undefine vms Then add a bit of code: #ifdef VMS /* sure this will run under VMS. It might even be the start of a useful hack */ #define index strchr #define rindex strrchr #include #include #include #endif Then modify the procedures openvms and getlb. I didn't want to bother trying to figure out how to get the unix emulation procedures open/lseek/read to work on a disk device mounted foreign. So it was easier to just do the obvious QIO for reading a logical block. With the LBLK code this will work on currently mounted filesystems too. openvms(devname) char *devname; { long ifhbn; if ( strlen(devname) > DEVMAX ) err1("Device name too long (%s)",devname); #ifdef VMS strcpy(vmsdev,""); #else strcpy(vmsdev,"/dev/"); if ( strncmp(devname,"disk$",5) == 0 ) devname += 5; if ( strncmp(devname,"vms",3) != 0 ) strcat(vmsdev,"vms"); #endif strcat(vmsdev,devname); #ifdef VMS {int retcode; struct dsc$descriptor devd; devd.dsc$w_length = strlen(vmsdev); devd.dsc$a_pointer = vmsdev; devd.dsc$b_class = DSC$K_CLASS_S; devd.dsc$b_dtype = DSC$K_DTYPE_T; vmsfd = 0; retcode = sys$assign(&devd,&vmsfd,0,0); if (retcode != SS$_NORMAL) vmsfd = -1;} #else vmsfd=open(vmsdev,0); #endif if ( vmsfd < 0 ) err1("Can't open %s",vmsdev); ..... } getlb(lbn,buf) long lbn; char *buf; { if ( lbn == 0L ) err0("Bad block in file"); #ifdef VMS {int retcode; short iosb[4]; retcode = sys$qiow(0,vmsfd,IO$_READLBLK,&iosb,0,0, buf,BUFSIZ,lbn, 0,0,0); if (retcode != SS$_NORMAL) err1("QIO error %d",retcode); if (iosb[0] != SS$_NORMAL) err1("READLBLK error %d",iosb[0]);} #else if ( lseek(vmsfd,BUFSIZE*lbn,0) == -1L || read(vmsfd,buf,BUFSIZE) != BU FSIZE ) err0("Read error"); #endif return(1); } Then hack gethdr(fnum,hp) to ignore access checks. #ifdef VMS /* the user must have LOGIO priv to run this anyway. */ return(1); #endif if ( ogrp != hp->h_proj || hp->h_fpro&G_DENY ) return(-1); else return(1);