From: hoffman@xdelta.zko.dec.nospam
Sent: Thursday, January 06, 2000 5:43 PM
To: Info-VAX@Mvb.Saic.Com
Subject: Re: SET FILE/DIRECTORY (was Re: VMS wish list)


In article <38750018.5703C8AB@advocatehealth.com>, djesys <David.Dachtera@advocatehealth.com> writes:
:Of course, it depends upon DFU, since even V7.1-2 lacks a SET
:FILE/DIRECTORY command to restore the "directory" attribute.

  Have a ball...  It's been a looong time since I've played with the
  attached, um, hack, so beware...  This code probably won't compile 
  on OpenVMS Alpha without a little help, but it did (once) solve a
  (rather obvious) problem I encountered on an OpenVMS VAX box...


	.title	    SETDIRBIT fixes the DIRECTORY bit
	;
	; this program is used to turn on the "DIRECTORY" bit in the
	; file header.  The file (more correctly directory) to be
	; reset is specified by FID (file identification) and device.
	; (The FID can be retrieved from a DIRECTORY/FULL command.)
	;
	;   a) Put the FID into the "fid" buffer, below.
	;
	;   b) The device the FID is from must also be plugged into
	;	the "dev" descriptor, below.
	;
	; The UCHAR field is protected -- see the I/O Abuser's Guide,
	; Part I, ACP/QIO Interface.  (SYSTEM or OWNER access to the
	; file (directory) is required.)
	;
	; 11-Apr-1988	Stephen Hoffman, DIGITAL Equipment Corp.
	;	This was written up...  No claims to style or content:
	;	intended simply to solve a one-shot problem.  MINIMAL
	;	error checking and user-hostile!
	;
	.library    'Sys$Library:LIB.Mlb'

	$atrdef	    ; File attribute definitions
	$fchdef	    ; File characteristics
	$fibdef	    ; File Information Block
	$iodef	    ; I/O definitions
	$ssdef	    ; System Service Definitions

	.psect	    data,wrt,noexe,long,noshr,usr

fid:	;   A file id (FID) looks like this: [NUM,SEQ,RVN]
	.word	    652		    ; file NUM
	.word	    9		    ; file SEQ
	.word	    0		    ; file RVN
	.word	    0		    ; (so we can use a MOVQ)
	;
dev:	; And the name of the disk the file id is from...
	.ascid	    /HSC000$DUA2:/
	;
iosb:	.blkw	    4		    ; garden variety IOSB
	;
fchan:	.blkw	    1		    ; channel to the disk
	;
FIBSIZE=22			    ; use the short FIB
fibbuf:	.blkb	    FIBSIZE	    ; here's the FIB itself
fib:	.long	    FIBSIZE	    ; here's the FIB descriptor
	.address    fibbuf
	;
uchar:	.blkb	    ATR$S_UCHAR	    ; the FAT characteristics buffer
fat:	; The File Attributes itemlist follows:
	.word	    ATR$S_UCHAR	    ; length of the buffer
	.word	    ATR$C_UCHAR	    ; address of the buffer
	.address    uchar	    ; where the UCHAR field is...
	.blkq	    0		    ; zero marks the end...
	;
	.psect	    code,nowrt,exe,long,shr,usr
	.entry	    SETDIRBIT, ^M<R2>
	;
	; Get a channel to the device
	;
	$ASSIGN_S -
	    devnam=dev,-
	    chan=fchan
	blbs	    r0,10$
	ret
	;
10$:	;
	; Move the two important "bits" of trivia out to the FIB.
	;
	moval	fibbuf,R0
	movq	fid,FIB$W_FID(R0)
	movl	#FIB$M_WRITE,FIB$L_ACCTL(R0)
	;
	; Access the file (directory)
	;
	$QIOW_S -
	    chan=fchan,-
	    func=#<IO$_ACCESS!IO$M_ACCESS>,-
	    iosb=IOSB,-
	    p1=fib,-
	    p5=#fat
	blbc	    r0,19$
	blbs	    iosb,20$
19$:	ret
	;
20$:	;
	; Force the DIRECTORY bit on!
	;
	bisl2	    #FCH$M_DIRECTORY,uchar
	;
	; Write the modified characteristics out...
	;
	$QIOW_S -
	    chan=fchan,-
	    func=#<IO$_MODIFY>,-
	    iosb=IOSB,-
	    p1=fib,-
	    p5=#fat
	blbc	    r0,29$
	blbs	    iosb,30$
29$:	ret
	;
30$:	;
	; And deaccess the file (directory)
	;
	$QIOW_S -
	    chan=fchan,-
	    func=#<IO$_DEACCESS>,-
	    iosb=IOSB
	blbc	    r0,39$
	blbs	    iosb,40$
39$:	ret
	;
40$:	;
	; Deassign the channel to the disk
	;
	$DASSGN_S -
	    chan=fchan
	movzwl	    #SS$_NORMAL,R0
	;
	; And bail out...
	;
	ret
	.END	    SETDIRBIT

-- 
 --------------------------- pure personal opinion ---------------------------
   Hoff (Stephen) Hoffman   OpenVMS Engineering   hoffman#xdelta.zko.dec.com
