From a4e89626d5db2de19888ad3dd87fdc0a6f5b4ec8 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 20 Dec 2014 09:18:49 -0500 Subject: [PATCH] Open/OpenRF should use the directory id / fs spec. --- toolbox/os.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/toolbox/os.cpp b/toolbox/os.cpp index e6c3877..daf3414 100644 --- a/toolbox/os.cpp +++ b/toolbox/os.cpp @@ -52,7 +52,7 @@ #include "os_internal.h" #include "toolbox.h" #include "stackframe.h" - +#include "fs_spec.h" using ToolBox::Log; @@ -339,6 +339,31 @@ namespace OS uint16_t Open(uint16_t trap) { + + enum { + /* IOParam */ + _qLink = 0, + _qType = 4, + _ioTrap = 6, + _ioCmdAddr = 8, + _ioCompletion = 12, + _ioResult = 16, + _ioNamePtr = 18, + _ioVRefNum = 22, + _ioRefNum = 24, + _ioVersNum = 26, + _ioPermssn = 27, + _ioMisc = 28, + _ioBuffer = 32, + _ioReqCount = 36, + _ioActCount = 40, + _ioPosMode = 44, + _ioPosOffset = 46, + + _ioDirID = 48, + + }; + uint32_t d0; int fd; @@ -348,25 +373,54 @@ namespace OS Log("%04x Open(%08x)\n", trap, parm); - uint32_t namePtr = memoryReadLong(parm + 18); + uint32_t namePtr = memoryReadLong(parm + _ioNamePtr); + uint32_t ioDirID = memoryReadLong(parm + _ioDirID); - uint8_t ioPermission = memoryReadByte(parm + 27); + uint8_t ioPermission = memoryReadByte(parm + _ioPermssn); std::string sname = ToolBox::ReadPString(namePtr, true); + sname = FSSpecManager::ExpandPath(sname, ioDirID); + + fd = Internal::FDEntry::open(sname, ioPermission, false); d0 = fd < 0 ? fd : 0; if (fd >= 0) { - memoryWriteWord(fd, parm + 24); + memoryWriteWord(fd, parm + _ioRefNum); } - memoryWriteWord(d0, parm + 16); + memoryWriteWord(d0, parm + _ioResult); return d0; } uint16_t OpenRF(uint16_t trap) { + + enum { + /* IOParam */ + _qLink = 0, + _qType = 4, + _ioTrap = 6, + _ioCmdAddr = 8, + _ioCompletion = 12, + _ioResult = 16, + _ioNamePtr = 18, + _ioVRefNum = 22, + _ioRefNum = 24, + _ioVersNum = 26, + _ioPermssn = 27, + _ioMisc = 28, + _ioBuffer = 32, + _ioReqCount = 36, + _ioActCount = 40, + _ioPosMode = 44, + _ioPosOffset = 46, + + _ioDirID = 48, + + }; + uint32_t d0; int fd; @@ -376,20 +430,22 @@ namespace OS Log("%04x OpenRF(%08x)\n", trap, parm); - uint32_t namePtr = memoryReadLong(parm + 18); + uint32_t namePtr = memoryReadLong(parm + _ioNamePtr); + uint32_t ioDirID = memoryReadLong(parm + _ioDirID); - uint8_t ioPermission = memoryReadByte(parm + 27); + uint8_t ioPermission = memoryReadByte(parm + _ioPermssn); std::string sname = ToolBox::ReadPString(namePtr, true); + sname = FSSpecManager::ExpandPath(sname, ioDirID); fd = Internal::FDEntry::open(sname, ioPermission, true); d0 = fd < 0 ? fd : 0; if (fd >= 0) { - memoryWriteWord(fd, parm + 24); + memoryWriteWord(fd, parm + _ioRefNum); } - memoryWriteWord(d0, parm + 16); + memoryWriteWord(d0, parm + _ioResult); return d0; }