Filter out large removable media on OSX
This fixes an annoyance where Time Machine backup drives would appear as
options. Those would, of cource, never be good places to overwrite. This
change limits the size of autodetected drives to 65 GiB like is down on
Linux.
@@ -104,6 +104,11 @@ static void scan_disk_appeared_cb(DADiskRef disk, void *c)
if (size < 128000000)
return;
+ // Filter out large devices (> 65 GiB) since those are probably backup drives
+ // and not SDCards.
+ if (size > (65 * ONE_GiB))
+ return;
+
context->count++;
}
}
@@ -146,7 +151,6 @@ int mmc_scan_for_devices(struct mmc_device *devices, int max_devices)
context.count = 0;
DARegisterDiskAppearedCallback(da_session, toMatch, scan_disk_appeared_cb, &context);
-
// Scan for removable media for 100 ms
// NOTE: It's not clear how long the event loop has to run. Ideally, it would
// terminate after all devices have been found, but I don't know how to do that.
