diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-09-16 21:07:46 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-09-16 21:08:18 +0200 |
commit | 1c975eefd3304e22556459f71ea6ed840ae75c64 (patch) | |
tree | d636e51b2f300442fc3e6209a8ec4f1a185118dd /rbutil | |
parent | f902bbe07e8968af2d5697c6ac3032bed02d56f0 (diff) |
Support "eject" on OS X.
Change-Id: I103587f2fad2b8b31a1bc53afbd107bf55f62c93
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/base/utils.cpp | 39 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 2 |
2 files changed, 40 insertions, 1 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; } diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index aa0c365303..0cdd8365a0 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -111,7 +111,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) } #endif -#if !defined(Q_OS_WIN32) +#if !defined(Q_OS_WIN32) && !defined(Q_OS_MACX) /* eject funtionality is only implemented on W32 right now. */ ui.buttonEject->setEnabled(false); #endif |