From 5124b042d6882a57f6c83d830ad0c50a67130d9e Mon Sep 17 00:00:00 2001 From: Andrew Bird Date: Sat, 28 Nov 2026 15:56:15 +0000 Subject: [PATCH 1/4] IsFileOpen: Let the caller know we are here So that the caller can try to do the right thing with older versions of share, let's clear the Carry Flag. The caller can set it before calling int2f/10a6 and if it's still set afterwards it can be sure that any value in AX is not from us. --- src/amishelp.asm | 15 ++++++++++----- src/share.c | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/amishelp.asm b/src/amishelp.asm index 3db2c8f..4b95320 100644 --- a/src/amishelp.asm +++ b/src/amishelp.asm @@ -1249,11 +1249,11 @@ iispentry i2F, 0, i2D mov [iregs.cx], CX mov [iregs.bx], BX mov [iregs.ax], AX - ; don't need IP or CS or flags - ; (flags weren't ever read or written, - ; and setting flags before iret is pointless. - ; setting them before chaining is minimally - ; more useful but not needed here.) + ; copy the caller's flags from the iret frame into iregs.flags + mov bp, sp + mov bx, [bp + 4] ; frame: ip, cs, flags (bp addresses SS) + mov [iregs.flags], bx + ; don't need IP or CS ; setup stack mov [old_ss], SS @@ -1272,6 +1272,11 @@ iispentry i2F, 0, i2D mov SS, [old_ss] mov SP, [old_sp] + ; write iregs.flags back into the iret frame + mov bp, sp + mov bx, [iregs.flags] + mov [bp + 4], bx + ; restore register input values mov BP, [iregs.bp] mov DI, [iregs.di] diff --git a/src/share.c b/src/share.c index 2ef35b2..3294c8f 100644 --- a/src/share.c +++ b/src/share.c @@ -414,6 +414,7 @@ void inner_handler(void) { /* is_file_open (0xa6)*/ if ((iregs.ax & 0xff) == 0xa6) { iregs.ax = is_file_open(MK_FP(iregs.ds, iregs.si)); + iregs.flags &= ~1; return; } } From 95323bfb30cd973b008416658c58bf535279c5b4 Mon Sep 17 00:00:00 2001 From: Andrew Bird Date: Sat, 28 Nov 2026 15:57:08 +0000 Subject: [PATCH 2/4] IsFileOpen: Optionally return the mode and psp When checking if a file is open, return its original mode and the psp that opened it. This is required for delete / rename / setfattr SHARE_COMPAT fixes and is modelled on patches from FDPP: f15bd2f33a49e50db7a05da7d9751dec1aa6f834 d530b5a65a873a2438b0ff9fd37a406d5fc63f7f --- src/share.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/share.c b/src/share.c index 3294c8f..b5bbac8 100644 --- a/src/share.c +++ b/src/share.c @@ -277,7 +277,7 @@ static int lock_unlock unsigned long len, /* length (in bytes) of region to lock or unlock */ int unlock); /* non-zero to unlock; zero to lock */ -static int is_file_open(char far *filename); +static int is_file_open(char far *filename, unsigned *mode, unsigned *psp); /* Multiplex interrupt handler */ @@ -413,7 +413,7 @@ void inner_handler(void) { /* is_file_open (0xa6)*/ if ((iregs.ax & 0xff) == 0xa6) { - iregs.ax = is_file_open(MK_FP(iregs.ds, iregs.si)); + iregs.ax = is_file_open(MK_FP(iregs.ds, iregs.si), &iregs.cx, &iregs.dx); iregs.flags &= ~1; return; } @@ -728,13 +728,19 @@ static int lock_unlock } } -static int is_file_open(char far *filename) +static int is_file_open(char far *filename, unsigned *mode, unsigned *psp) { int i; for (i = 0; i < file_table_size; i++) { - if (fnmatches(filename, file_table[i].filename)) + file_t *f = &file_table[i]; + if (fnmatches(filename, f->filename)) { + if (mode) + *mode = ((unsigned)f->sharemode << 8) | f->openmode; + if (psp) + *psp = f->psp; return 1; + } } return 0; } From 8a06571ac2344f1f76b62d360f9f3ab88d3d18c3 Mon Sep 17 00:00:00 2001 From: Andrew Bird Date: Sat, 28 Nov 2026 23:35:29 +0000 Subject: [PATCH 3/4] rules: Update share table Add / update exceptions to match MS-DOS 6.22 rules documented in RBIL --- src/share.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/share.c b/src/share.c index b5bbac8..54641f0 100644 --- a/src/share.c +++ b/src/share.c @@ -126,16 +126,21 @@ typedef struct { } open_action_exception_t; static open_action_exception_t open_exceptions[] = { - { 0, 0, 2, 0, 3 }, + { 0, 0, 2, 0, 1 }, { 0, 0, 4, 0, 3 }, /* compatibility-read/deny none-read, MED 08/2004 */ - { 2, 0, 0, 0, 4 }, + { 2, 0, 0, 0, 2 }, { 2, 0, 2, 0, 0 }, { 2, 0, 4, 0, 0 }, + { 2, 1, 3, 0, 0 }, + { 2, 1, 4, 0, 0 }, + { 2, 2, 4, 0, 0 }, { 3, 0, 2, 1, 0 }, { 3, 0, 4, 1, 0 }, + { 3, 1, 3, 1, 0 }, { 3, 1, 4, 1, 0 }, + { 3, 2, 3, 1, 1 }, { 3, 2, 4, 1, 0 }, - { 4, 0, 0, 0, 4 }, + { 4, 0, 0, 0, 2 }, { 4, 0, 0, 1, 0 }, /* deny none-read/compatibility-write */ { 4, 0, 0, 2, 0 }, /* deny none-read/compatibility-read+write */ { 4, 0, 2, 0, 0 }, From 353d9344f7628adca8e7d00532ad43623d862719 Mon Sep 17 00:00:00 2001 From: Andrew Bird Date: Sat, 28 Nov 2026 23:39:31 +0000 Subject: [PATCH 4/4] rules: Update share table Update remaining exceptions to match MS-DOS 6.22 rules documented in RBIL. All tests on Dosemu2 test suite passing now, however I'm concerned that I may be breaking the compatibilty fixes introduced in 2004. --- src/share.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/share.c b/src/share.c index 54641f0..6623244 100644 --- a/src/share.c +++ b/src/share.c @@ -127,7 +127,7 @@ typedef struct { static open_action_exception_t open_exceptions[] = { { 0, 0, 2, 0, 1 }, - { 0, 0, 4, 0, 3 }, /* compatibility-read/deny none-read, MED 08/2004 */ + { 0, 0, 4, 0, 1 }, { 2, 0, 0, 0, 2 }, { 2, 0, 2, 0, 0 }, { 2, 0, 4, 0, 0 }, @@ -141,8 +141,8 @@ static open_action_exception_t open_exceptions[] = { { 3, 2, 3, 1, 1 }, { 3, 2, 4, 1, 0 }, { 4, 0, 0, 0, 2 }, - { 4, 0, 0, 1, 0 }, /* deny none-read/compatibility-write */ - { 4, 0, 0, 2, 0 }, /* deny none-read/compatibility-read+write */ + { 4, 0, 0, 1, 2 }, + { 4, 0, 0, 2, 2 }, { 4, 0, 2, 0, 0 }, { 4, 0, 2, 1, 0 }, { 4, 0, 2, 2, 0 },