7 |
|
* |
8 |
|
* Based on Apple's CDROMSample.c and Evan Jones' cd-discid.c patches |
9 |
|
* |
10 |
< |
* Basilisk II (C) 1997-2004 Christian Bauer |
10 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
11 |
|
* |
12 |
|
* This program is free software; you can redistribute it and/or modify |
13 |
|
* it under the terms of the GNU General Public License as published by |
129 |
|
|
130 |
|
void DarwinAddFloppyPrefs(void) |
131 |
|
{ |
132 |
– |
#ifdef MAC_OS_X_VERSION_10_2 |
132 |
|
mach_port_t masterPort; // The way to talk to the kernel |
133 |
< |
io_iterator_t allFloppies; // List of CD drives on the system |
133 |
> |
io_iterator_t allFloppies; // List of possible floppys |
134 |
|
CFMutableDictionaryRef classesToMatch; |
135 |
|
io_object_t nextFloppy; |
136 |
|
|
139 |
|
bug("IOMasterPort failed. Won't be able to do anything with floppy drives\n"); |
140 |
|
|
141 |
|
|
142 |
+ |
// This selects all partitions of all disks |
143 |
|
classesToMatch = IOServiceMatching(kIOMediaClass); |
144 |
|
if ( classesToMatch ) |
145 |
|
{ |
146 |
< |
// We acually want removables that are _not_ CDs, |
147 |
< |
// but I don't know how to do that yet. |
146 |
> |
// Skip drivers and partitions |
147 |
> |
CFDictionarySetValue(classesToMatch, |
148 |
> |
CFSTR(kIOMediaWholeKey), kCFBooleanTrue); |
149 |
> |
|
150 |
> |
// Skip fixed drives (hard disks?) |
151 |
|
CFDictionarySetValue(classesToMatch, |
152 |
< |
CFSTR(kIOMediaRemovableKey), kCFBooleanTrue); |
152 |
> |
CFSTR(kIOMediaEjectableKey), kCFBooleanTrue); |
153 |
|
} |
154 |
|
|
155 |
|
if ( IOServiceGetMatchingServices(masterPort, |
168 |
|
IORegistryEntryCreateCFProperty(nextFloppy, |
169 |
|
CFSTR(kIOBSDNameKey), |
170 |
|
kCFAllocatorDefault, 0); |
171 |
+ |
long size; |
172 |
+ |
CFTypeRef sizeAsCFNumber = |
173 |
+ |
IORegistryEntryCreateCFProperty(nextFloppy, |
174 |
+ |
CFSTR(kIOMediaSizeKey), |
175 |
+ |
kCFAllocatorDefault, 0); |
176 |
+ |
|
177 |
+ |
if ( CFNumberGetValue((CFNumberRef)sizeAsCFNumber, |
178 |
+ |
kCFNumberSInt32Type, &size) ) |
179 |
+ |
{ |
180 |
+ |
D(bug("Got size of %ld\n", size)); |
181 |
+ |
if ( size < 800 * 1024 || size > 1440 * 1024 ) |
182 |
+ |
{ |
183 |
+ |
D(puts("Device does not appear to be 800k or 1440k")); |
184 |
+ |
continue; |
185 |
+ |
} |
186 |
+ |
} |
187 |
+ |
else |
188 |
+ |
bug("Couldn't get kIOMediaSizeKey of device"); |
189 |
+ |
|
190 |
+ |
|
191 |
|
*bsdPath = '\0'; |
192 |
|
if ( bsdPathAsCFString ) |
193 |
|
{ |
215 |
|
|
216 |
|
IOObjectRelease(nextFloppy); |
217 |
|
IOObjectRelease(allFloppies); |
195 |
– |
#endif |
218 |
|
} |
219 |
|
|
220 |
|
|