From 91a0da2e0aff195c55dbf446ade180ee53788e19 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 21 Dec 2014 08:36:44 -0500 Subject: [PATCH] PBHOpenDeny can create files? Need to test on real software. --- toolbox/os_internal.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/toolbox/os_internal.cpp b/toolbox/os_internal.cpp index 213e4e9..3e77ca1 100644 --- a/toolbox/os_internal.cpp +++ b/toolbox/os_internal.cpp @@ -443,9 +443,14 @@ namespace OS { namespace Internal { if (filename.empty()) return MacOS::bdNamErr; int access = 0; - ioPermission &= ~0x30; // drop deny read/write + if (ioPermission != 0x33) ioPermission &= ~0x30; // drop deny read/write switch(ioPermission) { + case 0x33: + // PBHOpenDeny exclusive access. + access = O_RDWR | O_CREAT; // | O_EXCL; + break; + case fsWrPerm: case fsRdWrPerm: case fsRdWrShPerm: @@ -466,7 +471,7 @@ namespace OS { namespace Internal { Log(" open(%s, %04x)\n", xname.c_str(), access); - fd = ::open(xname.c_str(), access); + fd = ::open(xname.c_str(), access, 0666); if (fd < 0 && ioPermission == fsCurPerm && errno == EACCES) { fd = ::open(xname.c_str(), O_RDONLY);