summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base/utils.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-09-16 21:07:46 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-09-16 21:08:18 +0200
commit1c975eefd3304e22556459f71ea6ed840ae75c64 (patch)
treed636e51b2f300442fc3e6209a8ec4f1a185118dd /rbutil/rbutilqt/base/utils.cpp
parentf902bbe07e8968af2d5697c6ac3032bed02d56f0 (diff)
downloadrockbox-1c975eefd3304e22556459f71ea6ed840ae75c64.tar.gz
rockbox-1c975eefd3304e22556459f71ea6ed840ae75c64.tar.bz2
rockbox-1c975eefd3304e22556459f71ea6ed840ae75c64.zip
Support "eject" on OS X.
Change-Id: I103587f2fad2b8b31a1bc53afbd107bf55f62c93
Diffstat (limited to 'rbutil/rbutilqt/base/utils.cpp')
-rw-r--r--rbutil/rbutilqt/base/utils.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index cffa4b1cad..eec03fe0ad 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -749,6 +749,45 @@ bool Utils::ejectDevice(QString device)
return success;
#endif
+#if defined(Q_OS_MACX)
+ // FIXME: FSUnmountVolumeSync is deprecated starting with 10.8.
+ // Use DADiskUnmount / DiskArbitration framework eventually.
+ // BSD label does not include folder.
+ QString bsd = Utils::resolveDevicename(device).remove("/dev/");
+ OSStatus result;
+ ItemCount index = 1;
+ bool found = false;
+
+ do {
+ FSVolumeRefNum volrefnum;
+
+ result = FSGetVolumeInfo(kFSInvalidVolumeRefNum, index, &volrefnum,
+ kFSVolInfoFSInfo, NULL, NULL, NULL);
+ if(result == noErr) {
+ GetVolParmsInfoBuffer volparms;
+ HParamBlockRec hpb;
+ hpb.ioParam.ioNamePtr = NULL;
+ hpb.ioParam.ioVRefNum = volrefnum;
+ hpb.ioParam.ioBuffer = (Ptr)&volparms;
+ hpb.ioParam.ioReqCount = sizeof(volparms);
+
+ if(PBHGetVolParmsSync(&hpb) == noErr) {
+ if(volparms.vMServerAdr == 0) {
+ if(bsd == (char*)volparms.vMDeviceID) {
+ pid_t dissenter;
+ result = FSUnmountVolumeSync(volrefnum, 0, &dissenter);
+ found = true;
+ break;
+ }
+ }
+ }
+ }
+ index++;
+ } while(result == noErr);
+ if(result == noErr && found)
+ return true;
+
+#endif
return false;
}