apple: macOS 12.0 deprecated things called "master" for "main".
Try to look for the new name in the process's namespace before falling back to the old one (and giving up on CD-ROM detection if everything falls apart). iOS has PHYSFS_NO_CDROM_SUPPORT defined, so this isn't used there.
This commit is contained in:
parent
49662cd826
commit
6a7625cd77
|
@ -12,6 +12,7 @@
|
||||||
#ifdef PHYSFS_PLATFORM_APPLE
|
#ifdef PHYSFS_PLATFORM_APPLE
|
||||||
|
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#include "physfs_internal.h"
|
#include "physfs_internal.h"
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ static int darwinIsWholeMedia(io_service_t service)
|
||||||
} /* darwinIsWholeMedia */
|
} /* darwinIsWholeMedia */
|
||||||
|
|
||||||
|
|
||||||
static int darwinIsMountedDisc(char *bsdName, mach_port_t masterPort)
|
static int darwinIsMountedDisc(char *bsdName, mach_port_t mainPort)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
CFMutableDictionaryRef matchingDict;
|
CFMutableDictionaryRef matchingDict;
|
||||||
|
@ -107,10 +108,10 @@ static int darwinIsMountedDisc(char *bsdName, mach_port_t masterPort)
|
||||||
io_iterator_t iter;
|
io_iterator_t iter;
|
||||||
io_service_t service;
|
io_service_t service;
|
||||||
|
|
||||||
if ((matchingDict = IOBSDNameMatching(masterPort, 0, bsdName)) == NULL)
|
if ((matchingDict = IOBSDNameMatching(mainPort, 0, bsdName)) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rc = IOServiceGetMatchingServices(masterPort, matchingDict, &iter);
|
rc = IOServiceGetMatchingServices(mainPort, matchingDict, &iter);
|
||||||
if ((rc != KERN_SUCCESS) || (!iter))
|
if ((rc != KERN_SUCCESS) || (!iter))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -158,13 +159,25 @@ static int darwinIsMountedDisc(char *bsdName, mach_port_t masterPort)
|
||||||
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
||||||
{
|
{
|
||||||
#if !defined(PHYSFS_NO_CDROM_SUPPORT)
|
#if !defined(PHYSFS_NO_CDROM_SUPPORT)
|
||||||
|
/* macOS 12.0 changed "master" names to "main". */
|
||||||
|
typedef kern_return_t (*ioMainPortFn)(mach_port_t, mach_port_t *);
|
||||||
|
static ioMainPortFn ioMainPort = NULL;
|
||||||
const char *devPrefix = "/dev/";
|
const char *devPrefix = "/dev/";
|
||||||
const int prefixLen = strlen(devPrefix);
|
const int prefixLen = strlen(devPrefix);
|
||||||
mach_port_t masterPort = 0;
|
mach_port_t mainPort = 0;
|
||||||
struct statfs *mntbufp;
|
struct statfs *mntbufp;
|
||||||
int i, mounts;
|
int i, mounts;
|
||||||
|
|
||||||
if (IOMasterPort(MACH_PORT_NULL, &masterPort) != KERN_SUCCESS)
|
if (ioMainPort == NULL)
|
||||||
|
{
|
||||||
|
ioMainPort = (ioMainPortFn) dlsym(RTLD_DEFAULT, "IOMainPort");
|
||||||
|
if (!ioMainPort)
|
||||||
|
ioMainPort = (ioMainPortFn) dlsym(RTLD_DEFAULT, "IOMasterPort");
|
||||||
|
if (!ioMainPort)
|
||||||
|
return; /* oh well, no CD-ROMs for you. */
|
||||||
|
} /* if */
|
||||||
|
|
||||||
|
if (ioMainPort(MACH_PORT_NULL, &mainPort) != KERN_SUCCESS)
|
||||||
BAIL(PHYSFS_ERR_OS_ERROR, ) /*return void*/;
|
BAIL(PHYSFS_ERR_OS_ERROR, ) /*return void*/;
|
||||||
|
|
||||||
mounts = getmntinfo(&mntbufp, MNT_WAIT); /* NOT THREAD SAFE! */
|
mounts = getmntinfo(&mntbufp, MNT_WAIT); /* NOT THREAD SAFE! */
|
||||||
|
@ -176,7 +189,7 @@ void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev += prefixLen;
|
dev += prefixLen;
|
||||||
if (darwinIsMountedDisc(dev, masterPort))
|
if (darwinIsMountedDisc(dev, mainPort))
|
||||||
cb(data, mnt);
|
cb(data, mnt);
|
||||||
} /* for */
|
} /* for */
|
||||||
#endif /* !defined(PHYSFS_NO_CDROM_SUPPORT) */
|
#endif /* !defined(PHYSFS_NO_CDROM_SUPPORT) */
|
||||||
|
|
Loading…
Reference in New Issue