From b34b68a26594a813e95eae7ffa95b0630990779b Mon Sep 17 00:00:00 2001
From: Bart Oldeman <bart@dosemu.org>
Date: Sun, 8 Feb 2004 20:58:09 +0000
Subject: [PATCH] FcbOpen/FcbFindFirstNext: Fix a consequence of truename's
 funny behaviour: truename(c:nul) = c:/nul and truename(c:/nul) = c:\nul and
 for FCBs it's still easiest to call truename twice so we have to copy c:/nul
 back to c:nul to compensate. This fixes the EJECT problem from Lucho.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@777 6ac86273-5f31-0410-b378-82cca8765d1b
---
 kernel/fcbfns.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c
index a33efdf..657e9c9 100644
--- a/kernel/fcbfns.c
+++ b/kernel/fcbfns.c
@@ -407,6 +407,13 @@ UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags)
     /* pass attribute without constraints (dangerous for directories) */
     attr = lpXfcb->xfcb_attrib;
 
+  /* for c:/nul c:nul must be opened instead!
+   * this is a consequence of truename's funny behaviour:
+   * truename(c:nul) = c:/nul and truename(c:/nul) = c:\nul
+   * and for FCBs it's easiest to call truename twice
+   */
+  if (SecPathName[2] == '/')
+    strcpy(&SecPathName[2], &SecPathName[3]);
   sft_idx = (short)DosOpenSft(SecPathName, flags, attr);
   if (sft_idx < 0)
   {
@@ -675,6 +682,9 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First)
     lpDir += 7;
   }
 
+  /* for c:/nul c:nul must be opened instead! (see above) */
+  if (SecPathName[2] == '/')
+    strcpy(&SecPathName[2], &SecPathName[3]);
   CritErrCode = -(First ? DosFindFirst(wAttr, SecPathName) : DosFindNext());
   if (CritErrCode != SUCCESS)
   {