     1                                  ;	SCCSID = @(#)share.asm	1.1 85/04/10
     2                                  ;TITLE   SHARING ROUTINES - Routines for file Sharing
     3                                  ;NAME    SHARE
     4                                  
     5                                  %include "dosseg.nas"
     1                              <1> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     2                              <1> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     3                              <1> ;
     4                              <1> ; segment ordering for MSDOS
     5                              <1> ;
     6                              <1> 
     7                              <1> %include "ddataseg.nas"
     1                              <2> 
     2                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
     1          ******************  <3>  warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
     6                                  
     7                                  section DOSCODECODE
     8                                  
     9                                  [list -]
     9          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
     9          ******************       warning: out: BPB.INC... [-w+user]
     9          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
     9          ******************       warning: out: DEVSYM.INC... [-w+user]
    15                                  
    16                                  %ifndef IBM
    17                                   %iassign IBM 0
    18                                  %endif
    19                                  %ifndef Installed
    20                                   %iassign Installed 0
    21                                  %endif
    22                                  
    23                                  True equ TRUE	; NASM port equate
    24                                  %iassign Installed True
    25                                  
    26                                  	i_need  THISDPB,DWORD
    27                                  	i_need  EXTERR,WORD
    28                                  	i_need  ReadOp,BYTE
    29                                  	i_need  ThisSFT,DWORD
    30                                  	i_need  ALLOWED,BYTE
    31                                  	I_need  RetryCount,WORD
    32                                  	i_need  JShare,DWORD
    33                                  
    34                                   assume nocheck, ss:DOSGROUP
    35                                  
    36                                  ; Inputs:
    37                                  ;       [THISSFT] Points to filled in local file/device SFT for new
    38                                  ;               instance of file sf_mode ALWAYS has mode (even on FCB SFTs)
    39                                  ;       [WFP_START] has full path of name
    40                                  ;       [USER_ID] Set
    41                                  ;       [PROC_ID] Set
    42                                  ; Function:
    43                                  ;       Check for sharing violations on local file/device access
    44                                  ; Outputs:
    45                                  ;    Carry clear
    46                                  ;       Sharing approved
    47                                  ;    Carry set
    48                                  ;       A sharing violation detected
    49                                  ;           AX is error code
    50                                  ; USES    ALL but DS
    51                                  
    52                                  	procedure   SHARE_CHECK,NEAR
    52          ******************       warning: proc SHARE_CHECK... [-w+user]
    53                                  	DOSAssume   CS,<DS>,"Share_Check"
    54                                  	ASSUME  ES:NOTHING
    55                                  
    56                                  %if installed
    57 00000000 FF1E[0400]              	call    far [JShare + 1 * 4]
    58                                  %else
    59                                  	Call    MFT_Enter
    60                                  %endif
    61 00000004 C3                      	return
    62                                  
    63                                  EndProc SHARE_CHECK
    64                                  
    65                                  ; Inputs:
    66                                  ;       [THISDPB] Set
    67                                  ;       AX has error code
    68                                  ; Function:
    69                                  ;       Handle Sharing errors
    70                                  ; Outputs:
    71                                  ;       Carry set if user says FAIL, causes error_sharing_violation
    72                                  ;       Carry clear if user wants a retry
    73                                  ;
    74                                  ; DS, ES, DI preserved, others destroyed
    75                                  
    76                                  	procedure   SHARE_VIOLATION,NEAR
    76          ******************       warning: proc SHARE_VIOLATION... [-w+user]
    77                                  	DOSAssume   CS,<DS>,"Share_Violation"
    78                                  	ASSUME  ES:NOTHING
    79                                  
    80 00000005 1E                      	PUSH    DS
    81 00000006 06                      	PUSH    ES
    82 00000007 57                      	PUSH    DI
    83                                  READOP equ ReadOp	; NASM port label
    84 00000008 C606[0000]00            	MOV     byte [READOP],0                      ; All share errors are reading
    85                                  allowed_FAIL equ Allowed_FAIL	; NASM port equate
    86                                  allowed_RETRY equ Allowed_RETRY	; NASM port equate
    87 0000000D C606[0000]18            	MOV     byte [ALLOWED],allowed_FAIL + allowed_RETRY
    88 00000012 C42E[0000]              	LES     BP,[THISDPB]
    89 00000016 BF0100                  	MOV     DI,1                            ; Fake some registers
    90 00000019 89F9                    	MOV     CX,DI
    91 0000001B 268B5611                	MOV     DX,[ES:BP + dpb_dir_sector]
    92 0000001F E8(0000)                	invoke  HARDERR_DOS
    93 00000022 5F                      	POP     DI
    94 00000023 07                      	POP     ES
    95                                   assume es:nothing
    96 00000024 1F                      	POP     DS
    97                                   assume ds:DOSGROUP
    98 00000025 3C01                    	CMP     AL,1
    99 00000027 74DB                    	retz                    ; 1 = retry, carry clear
   100 00000029 F9                      	STC
   101 0000002A C3                      	return
   102                                  
   103                                  EndProc SHARE_VIOLATION
   104                                  
   105                                  ;   ShareEnd - terminate sharing info on a particular SFT/UID/PID.  This does
   106                                  ;       NOT perform a close, it merely asserts that the sharing information
   107                                  ;       for the SFT/UID/PID may be safely released.
   108                                  ;
   109                                  ;   Inputs:     ES:DI points to an SFT
   110                                  ;   Outputs:    None
   111                                  ;   Registers modified: all except DS,ES,DI
   112                                  
   113                                  	procedure   ShareEnd,Near
   113          ******************       warning: proc ShareEnd... [-w+user]
   114                                  	DOSAssume   CS,<DS>,"ShareEnd"
   115                                  	ASSUME  ES:NOTHING
   116                                  
   117                                  %if installed
   118 0000002B FF1E[0800]              	Call    far [JShare + 2 * 4]
   119                                  %else
   120                                  	Call    MFTClose
   121                                  %endif
   122 0000002F C3                      	return
   123                                  
   124                                  EndProc ShareEnd
   125                                  
   126                                  break <ShareEnter - attempt to enter a node into the sharing set>
   127                                  
   128                                  ;
   129                                  ;   ShareEnter - perform a retried entry of a nodde into the sharing set.  If
   130                                  ;   the max number of retries is exceeded, we notify the user via int 24.
   131                                  ;
   132                                  ;   Inputs:     ThisSFT points to the SFT
   133                                  ;               WFP_Start points to the WFP
   134                                  ;   Outputs:    Carry clear => successful entry
   135                                  ;               Carry set => failed system call
   136                                  ;   Registers modified: all
   137                                  
   138                                  Procedure   ShareEnter,NEAR
   138          ******************       warning: proc ShareEnter... [-w+user]
   139                                  	DOSAssume   CS,<DS>,"ShareEnter"
   140                                  	assume  es:nothing
   141                                  
   142 00000030 51                      	SaveReg <CX>
   143                                  .retry:
   144 00000031 8B0E[0000]              	mov     cx,[RetryCount]
   145                                  .attempt:
   146 00000035 C43E[0000]              	les     di,[ThisSFT]              ; grab sft
   147 00000039 31C0                    	XOR     AX,AX
   148 0000003B 26894533                	MOV     [ES:DI + sf_MFT],AX       ; indicate free SFT
   149 0000003F 51                      	SaveReg <CX>
   150                                  Share_Check equ SHARE_CHECK	; NASM port label
   151 00000040 E8BDFF                  	call    Share_Check             ; attempt to enter into the sharing set
   152 00000043 59                      	RestoreReg  <CX>
   153 00000044 730A                    	jnc     .done                    ; success, let the user see this
   154 00000046 E8(0000)                	invoke  Idle                    ; wait a while
   155 00000049 E2EA                    	loop    .attempt                 ; go back for another attempt
   156                                  Share_violation equ SHARE_VIOLATION	; NASM port label
   157 0000004B E8B7FF                  	call    Share_violation         ; signal the problem to the user
   158 0000004E 73E1                    	jnc     .retry                   ; user said to retry, go do it
   159                                  .done:
   160 00000050 59                      	RestoreReg  <CX>
   161 00000051 C3                      	return
   162                                  EndProc ShareEnter
   163                                  
   164                                      END
