

; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 1

;

;	0001	MODULE MODIFY (

;	0002			LANGUAGE (BLISS32),

;	0003			IDENT = 'A0018A'

;	0004			) =

;	0005	BEGIN

;	0006	

;	0007	!

;	0008	! Copyright (c) 1977

;	0009	! Digital Equipment Corporation, Maynard, Massachusetts 01754

;	0010	!

;	0011	! This software is furnished  under a license for use only on a single

;	0012	! computer  system and  may be  copied only with  the inclusion of the

;	0013	! above copyright notice.  This software, or any other copies thereof,

;	0014	! may not be provided or  otherwise made available to any other person

;	0015	! except for use on such system and to one who agrees to these license

;	0016	! terms.  Title to and  ownership of the  software  shall at all times

;	0017	! remain in DEC.

;	0018	!

;	0019	! The information in this software is subject to change without notice

;	0020	! and should  not be construed  as a commitment  by Digital  Equipment

;	0021	! Corporation.

;	0022	!

;	0023	! DEC assumes  no  responsibility  for  the use or  reliability of its

;	0024	! software on equipment which is not supplied by DEC.

;	0025	

;	0026	!++

;	0027	!

;	0028	! FACILITY:  F11ACP Structure Level 1

;	0029	!

;	0030	! ABSTRACT:

;	0031	!

;	0032	!	This routine implements the MODIFY function.

;	0033	!

;	0034	! ENVIRONMENT:

;	0035	!

;	0036	!	STARLET operating system, including privileged system services

;	0037	!	and internal exec routines.

;	0038	!

;	0039	!--

;	0040	!

;	0041	!

;	0042	! AUTHOR:  Andrew C. Goldstein,	 CREATION DATE:  6-Jan-1977  23:03

;	0043	!

;	0044	! REVISION HISTORY:

;	0045	!

;	0046	!   Andrew C. Goldstein, 16-Feb-1977  15:04

;	0047	!   X0002 - Modify for condition handling

;	0048	!

;	0049	!   Andrew C. Goldstein, 25-Feb-1977  16:20

;	0050	!   X0003 - Add EXTEND function

;	0051	!

;	0052	!   Andrew C. Goldstein, 21-Mar-1977  13:16

;	0053	!   X0004 - Add TRUNCATE function

;	0054	!

;	0055	!   Andrew C. Goldstein, 23-Mar-1977  15:06



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 1-1

;

;	0056	!   X0005 - Key directory search off DID; record FCB address.

;	0057	!

;	0058	!   Andrew C. Goldstein, 25-Mar-1977  18:03

;	0059	!   X0006 - Remove FIB length check

;	0060	!

;	0061	!   Andrew C. Goldstein, 1-Apr-1977  13:39

;	0062	!   X0007 - Change call to FIND

;	0063	!

;	0064	!   Andrew C. Goldstein, 1-Apr-1977  17:01

;	0065	!   X0008 - Move GET_FIB out of kernel mode

;	0066	!

;	0067	!   Andrew C. Goldstein, 4-May-1977  17:36

;	0068	!   X0009 - Add file protection check

;	0069	!

;	0070	!   Andrew C. Goldstein, 9-May-1977  18:12

;	0071	!   X0010 - Make individual protection checks on extend and write attributes

;	0072	!

;	0073	!   Andrew C. Goldstein, 12-Jul-1977  14:30

;	0074	!   X0011 - Move WRITE_ATTRIB out of kernel mode

;	0075	!

;	0076	!   Andrew C. Goldstein, 3-Aug-1977  16:52

;	0077	!   X0012 - Checksum file header at end of operation

;	0078	!

;	0079	!   Andrew C. Goldstein, 10-Aug-1977  15:33

;	0080	!   X0013 - Move update of FCB to WRITE_ATTRIB

;	0081	!

;	0082	!   Andrew C. Goldstein, 26-Sep-1977  14:13

;	0083	!   X0014 - Allow multiple writers; add FID check after directory lookup

;	0084	!

;	0085	!   Andrew C. Goldstein, 12-Dec-1977  13:50

;	0086	!   X0015 - file ID interface changes

;	0087	!

;	0088	!   Andrew C. Goldstein, 3-Feb-1978  16:25

;	0089	!   X0016 - No protection check on open file

;	0090	!

;	0091	!   Andrew C. Goldstein, 19-Jun-78  20:07

;	0092	!   A0017 - Checksum header after write attributes

;	0093	!

;	0094	!   Andrew C. Goldstein, 28-Jun-78  17:06

;	0095	!   A0018 - Add allocation and truncate interlocks, update FCB at end

;	0096	!

;	0097	!**

;	0098	

;	0099	

;	0100	LIBRARY 'SYS$LIBRARY:LIB.L32';

;	0101	REQUIRE 'SRC$:FCPDEF.B32';



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 2

;

;	0420	GLOBAL ROUTINE MODIFY  =

;	0421	

;	0422	!++

;	0423	!

;	0424	! FUNCTIONAL DESCRIPTION:

;	0425	!

;	0426	!	This routine implements the MODIFY function.

;	0427	!

;	0428	! CALLING SEQUENCE:

;	0429	!	MODIFY ()

;	0430	!

;	0431	! INPUT PARAMETERS:

;	0432	!	NONE

;	0433	!

;	0434	! IMPLICIT INPUTS:

;	0435	!	CURRENT_WINDOW: window for file

;	0436	!	PRIMARY_FCB: FCB of file

;	0437	!	IO_PACKET: I/O packet in process

;	0438	!	FILE_HEADER: address of current file header

;	0439	!

;	0440	! OUTPUT PARAMETERS:

;	0441	!	NONE

;	0442	!

;	0443	! IMPLICIT OUTPUTS:

;	0444	!	NONE

;	0445	!

;	0446	! ROUTINE VALUE:

;	0447	!	NONE

;	0448	!

;	0449	! SIDE EFFECTS:

;	0450	!	file and FCB modified

;	0451	!

;	0452	!--

;	0453	

;	0454	BEGIN

;	0455	

;	0456	LOCAL

;	0457		ABD		: REF BBLOCKVECTOR [,ABD$C_LENGTH],

;	0458						! buffer descriptors

;	0459		FIB		: REF BBLOCK,	! FIB

;	0460		FCB		: REF BBLOCK,	! FCB of file

;	0461		HEADER		: REF BBLOCK;	! file header

;	0462	

;	0463	EXTERNAL

;	0464		IO_PACKET	: REF BBLOCK,	! I/O packet in process

;	0465		FILE_HEADER	: REF BBLOCK,	! address of currently resident file header

;	0466		CURRENT_WINDOW	: REF BBLOCK,	! window of file

;	0467		PRIMARY_FCB	: REF BBLOCK,	! FCB of file

;	0468		CURRENT_VCB	: REF BBLOCK;	! VCB of volume

;	0469	

;	0470	EXTERNAL ROUTINE

;	0471		GET_FIB,			! get FIB of request

;	0472		FIND,				! find name in directory

;	0473		SEARCH_FCB,			! search FCB list

;	0474		READ_HEADER,			! read file header



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 2-1

;

;	0475		CHECK_PROTECT,			! check file protection

;	0476		WRITE_ATTRIB,			! write file attributes

;	0477		EXTEND,				! extend file

;	0478		TRUNCATE,			! truncate file

;	0479		CHECKSUM,			! checksum the file header

;	0480		UPDATE_FCB;			! update FCB contents

;	0481	

;	0482	

;	0483	! First find the buffer descriptor, FIB, FCB, etc., and read the header.

;	0484	!

;	0485	

;	0486						! pointer to buffer descriptors

;	0487	ABD = .BBLOCK [.IO_PACKET[IRP$L_SVAPTE], AIB$L_DESCRIPT];

;	0488	FIB = GET_FIB (.ABD);

;	0489	

;	0490	! If a directory ID is present, do a directory search first.

;	0491	!

;	0492	

;	0493	IF .FIB[FIB$W_DID_NUM] NEQ 0

;	0494	THEN FIND (.ABD, .FIB, 0);

;	0495	

;	0496	! If there is a file open on the channel, check the file ID returned by the

;	0497	! FIND against the file ID that is open. If they are different, drop the FCB

;	0498	! and window addresses on the floor.

;	0499	!

;	0500	

;	0501	IF .PRIMARY_FCB NEQ 0

;	0502	THEN

;	0503	    IF .PRIMARY_FCB[FCB$W_FID_NUM] NEQ .FIB[FIB$W_FID_NUM]

;	0504	    OR .PRIMARY_FCB[FCB$W_FID_RVN] NEQ .FIB[FIB$W_FID_RVN]

;	0505	    THEN

;	0506		BEGIN

;	0507		PRIMARY_FCB = 0;

;	0508		CURRENT_WINDOW = 0;

;	0509		END;

;	0510	

;	0511	FCB = SEARCH_FCB (FIB[FIB$W_FID]);

;	0512	PRIMARY_FCB = .FCB;

;	0513	HEADER = READ_HEADER (FIB[FIB$W_FID], .FCB);

;	0514	

;	0515	

;	0516	! Arbitrate access interlocks. If this is the accessor, then the file

;	0517	! must be write accessed. If it is not, then the file must not be

;	0518	! locked against modification and he must pass file protection.

;	0519	!

;	0520	

;	0521	IF .CURRENT_WINDOW NEQ 0

;	0522	THEN

;	0523	    BEGIN

;	0524	    IF NOT .CURRENT_WINDOW[WCB$V_WRITE]

;	0525	    THEN ERR_EXIT (SS$_NOPRIV);

;	0526	    END

;	0527	ELSE

;	0528	    BEGIN

;	0529	    IF .FIB[FIB$V_EXTEND] OR .FIB[FIB$V_TRUNC]



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 2-2

;

;	0530	    THEN

;	0531		BEGIN

;	0532		IF .CURRENT_VCB[VCB$V_NOALLOC]

;	0533		THEN ERR_EXIT (SS$_WRITLCK);

;	0534	

;	0535		IF .FCB NEQ 0

;	0536		THEN

;	0537		    IF .FCB[FCB$V_EXCL]

;	0538		    OR .FCB[FCB$W_LCNT] NEQ 0

;	0539		    THEN ERR_EXIT (SS$_ACCONFLICT);

;	0540		CHECK_PROTECT (WRITE_ACCESS, .HEADER, .FCB);

;	0541		END;

;	0542	    END;

;	0543	

;	0544	

;	0545	! If an attribute list exists, perform the write attributes operation.

;	0546	!

;	0547	

;	0548	IF .IO_PACKET[IRP$W_BCNT] GTR ABD$C_ATTRIB

;	0549	THEN

;	0550	    BEGIN

;	0551	    WRITE_ATTRIB (.HEADER, .ABD);

;	0552	    CHECKSUM (.HEADER);

;	0553	    END;

;	0554	

;	0555	! If the extend enable bit is on, perform the extend operation.

;	0556	! If the truncate bit is on, perform the truncate operation. If both are

;	0557	! on, it is an error.

;	0558	!

;	0559	

;	0560	IF .FIB[FIB$V_EXTEND]

;	0561	THEN

;	0562	    BEGIN

;	0563	    IF .FIB[FIB$V_TRUNC] THEN ERR_EXIT (SS$_BADPARAM);

;	0564	    EXTEND (.FIB, .HEADER);

;	0565	    END;

;	0566	

;	0567	IF .FIB[FIB$V_TRUNC]

;	0568	THEN

;	0569	    BEGIN

;	0570	    IF .FCB[FCB$W_TCNT] NEQ 0

;	0571	    THEN ERR_EXIT (SS$_ACCONFLICT);

;	0572	    TRUNCATE (.FIB, .HEADER, DEALLOC_BLOCKS);

;	0573	    END;

;	0574	

;	0575	HEADER = .FILE_HEADER;

;	0576	CHECKSUM (.HEADER);			! checksum the file header

;	0577	KERNEL_CALL (UPDATE_FCB, .HEADER);

;	0578	

;	0579	RETURN 1;

;	0580	

;	0581	END;					! end of routine MODIFY





							    .TITLE  MODIFY



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 2-3

;

							    .IDENT  \A0018A\



							    .EXTRN  IO_PACKET, FILE_HEADER, CURRENT_WINDOW, PRIMARY_FCB

							    .EXTRN  CURRENT_VCB, GET_FIB, FIND, SEARCH_FCB, READ_HEADER

							    .EXTRN  CHECK_PROTECT, WRITE_ATTRIB, EXTEND, TRUNCATE

							    .EXTRN  CHECKSUM, UPDATE_FCB, SYS$CMKRNL



							    .PSECT  $CODE$,NOWRT,2



					 007C 00000 	    .ENTRY  MODIFY, Save R2,R3,R4,R5,R6				      ; 0420

		         56 	0000G  CF  9E 00002 	    MOVAB   PRIMARY_FCB, R6					      ;

		         50 	0000G  CF  D0 00007 	    MOVL    IO_PACKET, R0					      ; 0487

		         55 	  2C   B0  D0 0000C 	    MOVL    @44(R0), ABD					      ;

				       55  DD 00010 	    PUSHL   ABD							      ; 0488

		  0000G  CF	       01  FB 00012 	    CALLS   #1, GET_FIB						      ;

		         52 	       50  D0 00017 	    MOVL    R0, FIB						      ;

				  0A   A2  B5 0001A 	    TSTW    10(FIB)						      ; 0493

				       0B  13 0001D 	    BEQL    1$							      ;

				       7E  D4 0001F 	    CLRL    -(SP)						      ; 0494

				       52  DD 00021 	    PUSHL   FIB							      ;

				       55  DD 00023 	    PUSHL   ABD							      ;

		  0000G  CF	       03  FB 00025 	    CALLS   #3, FIND						      ;

		         50 	       66  D0 0002A 1$:     MOVL    PRIMARY_FCB, R0					      ; 0501

				       14  13 0002D 	    BEQL    3$							      ;

		    04   A2	  20   A0  B1 0002F 	    CMPW    32(R0), 4(FIB)					      ; 0503

				       07  12 00034 	    BNEQ    2$							      ;

		    08   A2	  24   A0  B1 00036 	    CMPW    36(R0), 8(FIB)					      ; 0504

				       06  13 0003B 	    BEQL    3$							      ;

				       66  D4 0003D 2$:     CLRL    PRIMARY_FCB						      ; 0507

				0000G  CF  D4 0003F 	    CLRL    CURRENT_WINDOW					      ; 0508

				  04   A2  9F 00043 3$:     PUSHAB  4(FIB)						      ; 0511

		  0000G  CF	       01  FB 00046 	    CALLS   #1, SEARCH_FCB					      ;

		         53 	       50  D0 0004B 	    MOVL    R0, FCB						      ;

		         66 	       53  D0 0004E 	    MOVL    FCB, PRIMARY_FCB					      ; 0512

				       53  DD 00051 	    PUSHL   FCB							      ; 0513

				  04   A2  9F 00053 	    PUSHAB  4(FIB)						      ;

		  0000G  CF	       02  FB 00056 	    CALLS   #2, READ_HEADER					      ;

		         54 	       50  D0 0005B 	    MOVL    R0, HEADER						      ;

		         50 	0000G  CF  D0 0005E 	    MOVL    CURRENT_WINDOW, R0					      ; 0521

				       09  13 00063 	    BEQL    4$							      ;

	   38 	    0B   A0	       01  E0 00065 	    BBS     #1, 11(R0), 9$					      ; 0524

				       24  BF 0006A 	    CHMU    #36							      ; 0525

				       34  11 0006C 	    BRB     9$							      ; 0521

	   04 	    16   A2	       07  E0 0006E 4$:     BBS     #7, 22(FIB), 5$					      ; 0529

		         2B 	  17   A2  E9 00073 	    BLBC    23(FIB), 9$						      ;

		         50 	0000G  CF  D0 00077 5$:     MOVL    CURRENT_VCB, R0					      ; 0532

	   04 	    0B   A0	       04  E1 0007C 	    BBC     #4, 11(R0), 6$					      ;

				025C   8F  BF 00081 	    CHMU    #604						      ; 0533

				       53  D5 00085 6$:     TSTL    FCB							      ; 0535

				       0E  13 00087 	    BEQL    8$							      ;

	   05 	    1E   A3	       03  E0 00089 	    BBS     #3, 30(FCB), 7$					      ; 0537

				  1A   A3  B5 0008E 	    TSTW    26(FCB)						      ; 0538

				       04  13 00091 	    BEQL    8$							      ;

				0800   8F  BF 00093 7$:     CHMU    #2048						      ; 0539

				       53  DD 00097 8$:     PUSHL   FCB							      ; 0540



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 2-4

;

				       54  DD 00099 	    PUSHL   HEADER						      ;

				       01  DD 0009B 	    PUSHL   #1							      ;

		  0000G  CF	       03  FB 0009D 	    CALLS   #3, CHECK_PROTECT					      ;

		         50 	0000G  CF  D0 000A2 9$:     MOVL    IO_PACKET, R0					      ; 0548

		         05 	  32   A0  B1 000A7 	    CMPW    50(R0), #5						      ;

				       0E  1B 000AB 	    BLEQU   10$							      ;

				       30  BB 000AD 	    PUSHR   #^M<R4,R5>						      ; 0551

		  0000G  CF	       02  FB 000AF 	    CALLS   #2, WRITE_ATTRIB					      ;

				       54  DD 000B4 	    PUSHL   HEADER						      ; 0552

		  0000G  CF	       01  FB 000B6 	    CALLS   #1, CHECKSUM					      ;

	   0D 	    16   A2	       07  E1 000BB 10$:    BBC     #7, 22(FIB), 12$					      ; 0560

		         02 	  17   A2  E9 000C0 	    BLBC    23(FIB), 11$					      ; 0563

				       14  BF 000C4 	    CHMU    #20							      ;

				       14  BB 000C6 11$:    PUSHR   #^M<R2,R4>						      ; 0564

		  0000G  CF	       02  FB 000C8 	    CALLS   #2, EXTEND						      ;

		         12 	  17   A2  E9 000CD 12$:    BLBC    23(FIB), 14$					      ; 0567

				  46   A3  B5 000D1 	    TSTW    70(FCB)						      ; 0570

				       04  13 000D4 	    BEQL    13$							      ;

				0800   8F  BF 000D6 	    CHMU    #2048						      ; 0571

				       01  DD 000DA 13$:    PUSHL   #1							      ; 0572

				       14  BB 000DC 	    PUSHR   #^M<R2,R4>						      ;

		  0000G  CF	       03  FB 000DE 	    CALLS   #3, TRUNCATE					      ;

		         54 	0000G  CF  D0 000E3 14$:    MOVL    FILE_HEADER, HEADER					      ; 0575

				       54  DD 000E8 	    PUSHL   HEADER						      ; 0576

		  0000G  CF	       01  FB 000EA 	    CALLS   #1, CHECKSUM					      ;

				       54  DD 000EF 	    PUSHL   HEADER						      ; 0577

				       01  DD 000F1 	    PUSHL   #1							      ;

				       5E  DD 000F3 	    PUSHL   SP							      ;

				0000G  CF  9F 000F5 	    PUSHAB  UPDATE_FCB						      ;

	      00000000G  9F	       04  FB 000F9 	    CALLS   #4, @#SYS$CMKRNL					      ;

		         50 	       01  D0 00100 	    MOVL    #1, R0						      ; 0579

					   04 00103 	    RET     							      ; 0420



; Routine Size:  260 bytes





;	0582	

;	0583	END

;	0584	ELUDOM













;				       PSECT SUMMARY

;

;	Name		 Bytes			       Attributes

;

;  $CODE$         	   260  NOWRT,  RD ,  EXE,NOSHR,  LCL,  REL,  CON,NOPIC,ALIGN(2)









;				LIBRARY STATISTICS



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:00:53	DBB3:[F11A.SRC]MODIFY.B32;10					Page 2-5

;

;

;					     -------- Symbols --------    Blocks

;	File				     Total    Loaded   Percent      Read

;

;  DBA4:[SYSLIB]LIB.L32;1		      5582        23         0       243











; Size:		260 code + 0 data bytes

; Run Time:	00:07.6

; Elapsed Time:	00:16.8

; Memory Used:	310 pages

; Compilation Complete

