Gnome Disk Utility Issues incorrect command when ejecting a SATA Harddisk or Solid State Drive

Bug #1858860 reported by Damiön la Bagh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
udisks
Unknown
Unknown
gnome-disk-utility (Ubuntu)
Triaged
Low
Unassigned

Bug Description

Use case: As a user of hot swap-able SATA disks using a Harddrive Riser over eSATA. I need a safe, easy and convenient way to remove the hot swap-able SATA disk without rebooting and without having to go to the command line.

When attempting to eject an harddisk or a solid state disk using the eject button in "Gnome Disk Utility" it issues the 'eject' command which results in an IOCTL error.
The correct commands the eject button in the GUI should issue to eject a SATA HDD or SSD are:

# where X is the drive letter of the drive being worked with

# -Y Put drive to sleep
sudo hdparm -Y /dev/sdX
# remove the device from the kernel
sudo sh -c 'echo 1 > /sys/block/sdX/device/delete'

Please see the screen shots for the error.
This should be an easy fix (20 minutes) for someone who is good a programmer.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: gnome-disk-utility 3.28.3-0ubuntu1~18.04.1
ProcVersionSignature: Ubuntu 4.15.0-74.84-generic 4.15.18
Uname: Linux 4.15.0-74-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.9-0ubuntu7.9
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Wed Jan 8 21:07:32 2020
InstallationDate: Installed on 2018-11-11 (423 days ago)
InstallationMedia: Ubuntu 18.04.1 LTS "Bionic Beaver" - Release amd64 (20180725)
SourcePackage: gnome-disk-utility
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Damiön la Bagh (kat-amsterdam) wrote :
Revision history for this message
Damiön la Bagh (kat-amsterdam) wrote :

Translation of the Error message to English:

Removal of the medium has failed

Error ejecting /dev/sdi: Command-line `eject"/dev/sdi"' exited with a non-zero status 1:
eject: could not eject, last error:
Incorrect ioctl() for device
(udisks-error-quark, 0)

So you can see in the error message that the incorrect command was used for the type of drive.

Revision history for this message
Damiön la Bagh (kat-amsterdam) wrote :

The Source code file location where this happens I'm pretty sure is here:

/src/disks/gduwindow.c

/* ---------------------------------------------------------------------------------------------------- */

static void
eject_cb (UDisksDrive *drive,
          GAsyncResult *res,
          gpointer user_data)
{
  GduWindow *window = GDU_WINDOW (user_data);
  GError *error;

  error = NULL;
  if (!udisks_drive_call_eject_finish (drive,
                                       res,
                                       &error))
    {
      gdu_utils_show_error (GTK_WINDOW (window),
                            _("Error ejecting media"),
                            error);
      g_error_free (error);
    }
  g_object_unref (window);
}

static void
eject_ensure_unused_cb (GduWindow *window,
                        GAsyncResult *res,
                        gpointer user_data)
{
  UDisksObject *object = UDISKS_OBJECT (user_data);
  if (gdu_window_ensure_unused_finish (window, res, NULL))
    {
      UDisksDrive *drive = udisks_object_peek_drive (object);
      udisks_drive_call_eject (drive,
                               g_variant_new ("a{sv}", NULL), /* options */
                               NULL, /* cancellable */
                               (GAsyncReadyCallback) eject_cb,
                               g_object_ref (window));
    }
  g_object_unref (object);
}

static void
on_devtab_drive_eject_button_clicked (GtkButton *button,
                                      gpointer user_data)
{
  GduWindow *window = GDU_WINDOW (user_data);
  gdu_window_ensure_unused (window,
                            window->current_object,
                            (GAsyncReadyCallback) eject_ensure_unused_cb,
                            NULL, /* GCancellable */
                            g_object_ref (window->current_object));
}

/* ---------------------------------------------------------------------------------------------------- */

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug report. The eject command is issues by udisks so issue is more likely there
Could you maybe report it also upstream on https://github.com/storaged-project/udisks/ ?

Changed in gnome-disk-utility (Ubuntu):
importance: Undecided → Low
Revision history for this message
Damiön la Bagh (kat-amsterdam) wrote :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks!

Changed in gnome-disk-utility (Ubuntu):
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.