dosfns: Check share table before delete/rename

Delete and Rename should not be able to remove an open file,
so check share's open file table first. Behaviour is now identical
to MS-DOS 6.22.

Note: Uses a new subfunction of the FreeDOS share multiplex
      interrupt int2f/0x10a6 called is_file_open()

A similar patch was applied to FDPP at
https://github.com/dosemu2/fdpp/commit/691721f1

Fixes dosemu2 tests:
  test_fat_ds3_share_open_rename_fcb
  test_fat_ds3_share_open_rename_ds2
  test_fat_ds3_share_open_delete_ds2
  test_fat_ds3_share_open_delete_fcb
This commit is contained in:
Andrew Bird 2020-05-01 23:37:06 +01:00 committed by Kenneth J Davis
parent 78d0e09e98
commit 5b9e8fedcc
3 changed files with 33 additions and 0 deletions

View File

@ -86,6 +86,13 @@ extern int ASMPASCAL
unsigned long len, /* length (in bytes) of region to lock or unlock */
int unlock); /* one to unlock; zero to lock */
/* DOS calls this to see if share already has the file marked as open.
Returns:
1 if open
0 if not */
extern int ASMPASCAL
share_is_file_open(const char far * filename);
/* /// End of additions for SHARE. - Ron Cemer */
STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */
@ -1214,6 +1221,9 @@ COUNT DosDelete(BYTE FAR * path, int attrib)
if (result & IS_DEVICE)
return DE_FILENOTFND;
if (IsShareInstalled(TRUE) && share_is_file_open(PriPathName))
return DE_ACCESS;
return dos_delete(PriPathName, attrib);
}
@ -1226,6 +1236,9 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib)
if (FP_OFF(current_ldt) == 0xFFFF || (current_ldt->cdsFlags & CDSNETWDRV))
return network_redirector(REM_RENAME);
if (IsShareInstalled(TRUE) && share_is_file_open(path1))
return DE_ACCESS;
return dos_rename(path1, path2, attrib);
}

View File

@ -342,6 +342,25 @@ SHARE_LOCK_UNLOCK:
mov ax,0x10a4
jmp short share_common
; DOS calls this to see if share already has the file marked as open.
; Returns:
; 1 if open
; 0 if not
; STATIC WORD share_is_file_open(const char far *filename) /* pointer to fully qualified filename */
global SHARE_IS_FILE_OPEN
SHARE_IS_FILE_OPEN:
mov si, ds
mov es, si ; save ds
pop ax ; save return address
pop si ; filename
pop ds ; SEG filename
push ax ; restore return address
mov ax, 0x10a6
int 0x2f ; returns ax
mov si, es ; restore ds
mov ds, si
ret
; Int 2F Multipurpose Remote System Calls
;
; added by James Tabor jimtabor@infohwy.com

View File

@ -114,6 +114,7 @@ SECTIONS
_share_close_file = SHARE_CLOSE_FILE;
_share_access_check = SHARE_ACCESS_CHECK;
_share_lock_unlock = SHARE_LOCK_UNLOCK;
_share_is_file_open = SHARE_IS_FILE_OPEN;
_call_nls = CALL_NLS;
_fl_reset = FL_RESET;
_fl_diskchanged = FL_DISKCHANGED;