From 2ec100b72e97d3a3ad343439f64a2e1712ccca15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 27 Oct 2008 15:30:58 +0000 Subject: [PATCH] * Implemented Eject(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28345 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/disk_device/DiskDevice.cpp | 38 +++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/kits/storage/disk_device/DiskDevice.cpp b/src/kits/storage/disk_device/DiskDevice.cpp index 9cf19f6fab..75dee71ef0 100644 --- a/src/kits/storage/disk_device/DiskDevice.cpp +++ b/src/kits/storage/disk_device/DiskDevice.cpp @@ -110,26 +110,28 @@ BDiskDevice::IsWriteOnceMedia() const status_t BDiskDevice::Eject(bool update) { -/* // get path - const char* path = Path(); - status_t error = (path ? B_OK : B_NO_INIT); + if (fDeviceData == NULL) + return B_NO_INIT; + // check whether the device media is removable - if (error == B_OK && !IsRemovable()) - error = B_BAD_VALUE; + if (!IsRemovableMedia()) + return B_BAD_VALUE; + // open, eject and close the device - if (error == B_OK) { - int fd = open(path, O_RDONLY); - if (fd < 0 || ioctl(fd, B_EJECT_DEVICE) != 0) - error = errno; - if (fd >= 0) - close(fd); - } - if (error == B_OK && update) - error = Update(); - return error; -*/ - // not implemented - return B_ERROR; + int fd = open(fDeviceData->path, O_RDONLY); + if (fd < 0) + return errno; + + status_t status = B_OK; + if (ioctl(fd, B_EJECT_DEVICE) != 0) + status = errno; + + close(fd); + + if (status == B_OK && update) + status = Update(); + + return status; }