Path: utzoo!utgpu!water!watmath!clyde!ima!marc From: marc@ima.ima.isc.com (Marc Evans) Newsgroups: comp.unix.wizards Subject: Re: VMS vs. UNIX file system Message-ID: <2670@ima.ima.isc.com> Date: 20 Sep 88 17:45:48 GMT References: <411@marob.MASA.COM> <178@arnold.UUCP> <1986@bucsb.UUCP> <3506@ihlpe.ATT.COM> <68853@sun.uucp> <3518@ihlpe.ATT.COM> Reply-To: ima!edogte!marc Organization: Synergytics, Pelham, NH Lines: 160 Below is a program which I received from DEC a while back which demonstraits a mechanism which can be used to modify the type of file that RMS thinks any file is. I have used this as it is below, to work under VMS, while maintaining UNIX like file IO characteristics. Happy Hacking... =============================================================================== Marc Evans | decvax<--\ /-->marc<--\ | That's not a bug...It's Synergytics| harvard<--\ / \ /--->norton | a design feature... 8-) Pelham, NH | necntc<---->ima<---->symetrx<---->dupont | ======================= =============================================================================== -------------------- C U T H E R E ------------------------------------------ #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh'mungattr.c' <<'END_OF_FILE' X/**************************************************************************** X * Program: mungattr.c X * Purpose: This program changes the file attributes and record X * length to a specified value. X * Author: Mark Turner - Language Support Team (DEC) X * Date: June, 1988 X **************************************************************************** X * Modified: Marc Evans - Independant Contractor (Synergytics) X * Date: Sept., 1988 X ****************************************************************************/ X X#include X#include X#include X#include X#include X#include X#include "fatdef.h" X struct X{ short cond_value, count; X int info; X} iosb; X struct X{ unsigned short w_size, w_type; X unsigned int l_addr; X} acb[2]; X struct fibdef fib; struct stat my_buff; struct X{ unsigned char rtype, rattrib; X short rsize; X char filler_2[12]; X short mrec; X char filler_3[14]; X} ratt_area; X int status; X short func_code, chan; X X$DESCRIPTOR(fibdesc, &fib); X$DESCRIPTOR(device, "SYS$DISK:"); /* Disk the file is on */ X main(argc,argv) char **argv; X{ X char *filename; X X /* Did the invoker supply a filename? */ X if (argc != 2) X { fprintf(stderr,"USAGE: %s filename\n",argv[0]); X exit(1); X } X filename = argv[1]; X X /* Get the FID of the file */ X stat(filename, &my_buff); X X /* Assign a channel to the disk */ X if ((status = SYS$ASSIGN(&device,&chan,0,0)) & 1 != 1) X { LIB$STOP(status); } X X /* Init the appropriate fields of the FIB */ X fibdesc.dsc$w_length = FIB$C_LENGTH; X fib.fib$r_acctl_overlay.fib$r_acctl_bits0.fib$v_write = 1; X fib.fib$r_fid_overlay.fib$w_fid[0] = my_buff.st_ino[0]; X fib.fib$r_fid_overlay.fib$w_fid[1] = my_buff.st_ino[1]; X fib.fib$r_fid_overlay.fib$w_fid[2] = my_buff.st_ino[2]; X X /* Set up the attribute control block */ X acb[1].w_size = 0; X acb[1].w_type = 0; X acb[1].l_addr = 0; X acb[0].w_size = ATR$S_RECATTR; X acb[0].w_type = ATR$C_RECATTR; X acb[0].l_addr = &ratt_area; X X /* Access the file */ X func_code = IO$_ACCESS | IO$M_ACCESS; X status = SYS$QIOW(0,chan,func_code,&iosb,0,0,&fibdesc,0,0,0,&acb,0); X if ((status & 1) != 1) X { LIB$STOP(status); } X if ((iosb.cond_value & 1) != 1) X { LIB$STOP(iosb.cond_value); } X X /* Change the file to a sequential stream file */ X ratt_area.rtype = FAT$C_FIXED | FAT$C_SEQUENTIAL; X ratt_area.rsize = 512; X ratt_area.mrec = 512; X ratt_area.rattrib = FAT$M_IMPLIEDCC; X X /* Modify the file header information */ X status = SYS$QIOW(0,chan,IO$_MODIFY,&iosb,0,0,&fibdesc,0,0,0,&acb,0); X if ((status & 1) != 1) X { LIB$STOP(status); } X if ((iosb.cond_value & 1) != 1) X { LIB$STOP(iosb.cond_value); } X X /* Deaccess the file */ X func_code = IO$_DEACCESS; X status = SYS$QIOW(0,chan,func_code,&iosb,0,0,&fibdesc,0,0,0,0,0); X if ((status & 1) != 1) X { LIB$STOP(status); } X if ((iosb.cond_value & 1) != 1) X { LIB$STOP(iosb.cond_value); } X X} END_OF_FILE if test 2842 -ne `wc -c <'mungattr.c'`; then echo shar: \"'mungattr.c'\" unpacked with wrong size! fi # end of 'mungattr.c' fi if test -f 'build.com' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'build.com'\" else echo shar: Extracting \"'build.com'\" \(80 characters\) sed "s/^X//" >'build.com' <<'END_OF_FILE' X$ set verify X$ cc/opt/nodebug mungattr.c X$ link/nodebug mungattr X$ set noverify END_OF_FILE if test 80 -ne `wc -c <'build.com'`; then echo shar: \"'build.com'\" unpacked with wrong size! fi # end of 'build.com' fi echo shar: End of shell archive. exit 0