Bug 143353 - "safely remove" unmounts usb flash disk while it is still in use (flashing)
Summary: "safely remove" unmounts usb flash disk while it is still in use (flashing)
Status: RESOLVED FIXED
Alias: None
Product: kde
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal with 40 votes (vote)
Target Milestone: ---
Assignee: Stephan Kulow
URL:
Keywords:
: 135558 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-22 19:10 UTC by khotyanovsky
Modified: 2007-05-09 17:35 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description khotyanovsky 2007-03-22 19:10:00 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Compiled From Sources
Compiler:          gcc 4.1.1  
OS:                Linux

My configuration: KDE-3.5.5, HAL, pmount, kernel 2.6.19-gentoo-r5

"Safely remove" does not wait for the usb flash to finish copying a large file.
Instead, it immediately unmounts the usb key while it is still flashing red.

1. Copy large (a few hundred Megs) file to usb key.
2. Immediately click "Safely remove".

The usb icon turns into unmounted state (which is true).
After that the user may unplug the usb key, which may result
in fat32 corruption. 

Expected behaviour would be a popped-up dialog window that asks to wait
for the usb key to finish its activity.
Comment 1 khotyanovsky 2007-03-23 18:10:44 UTC
When the usb disk is "safely removed" and its icon turns into unmounted state
the usb disk is still in /etc/mtab, so it is not really unmounted.
Comment 3 Carles Sànchez 2007-03-28 12:03:44 UTC
Exactly the same problem here. My system runs:

KDE 3.5.5 (kubuntu edgy), kernel 2.6.17-11-generic.
Comment 4 khotyanovsky 2007-03-29 07:24:00 UTC
See https://launchpad.net/ubuntu/+source/kdebase/+bug/61946
Comment 5 Wiebe Cazemier 2007-04-19 11:51:53 UTC
I have the same, KDE 3.5.5 (actually, I have had it since many releases back).

And khotyanovsky is right, the system still has it mounted. It has to, otherwise it would be unable to flush cache.

Current specs:
distro: Gentoo
KDE: 3.5.5
HAL: 0.5.7.1
Dbus: 1.0.2
kernel: 2.6.19-gentoo-r5
GCC: 4.1.1
pmount: 0.9.13 
CFLAGS: "-O2 -march=athlon-xp -pipe"

Comment 6 Stephan Kulow 2007-05-08 14:48:13 UTC
SVN commit 662500 by coolo:

make sure we unmount the device before we even try to 
eject - and give correct error message if the device is busy
BUG: 143353


 M  +7 -7      mediamanager/halbackend.cpp  
 M  +9 -5      mounthelper/kio_media_mounthelper.cpp  


--- branches/KDE/3.5/kdebase/kioslave/media/mediamanager/halbackend.cpp #662499:662500
@@ -1037,14 +1037,14 @@
         QString proclist(listUsingProcesses(medium));
 
         qerror = "<qt>";
-        qerror += i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
+        qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
                        "currently mounted at <b>%4</b> could not be unmounted. ").arg(
                           "system:/media/" + medium->name(),
                           medium->deviceNode(),
                           medium->prettyLabel(),
-                          medium->prettyBaseURL().pathOrURL());
-        qerror += i18n("The following error was returned by umount command:");
-        qerror += "<br><pre>" + job->errorText() + "</pre>";
+                          medium->prettyBaseURL().pathOrURL()) + "</p>";
+        qerror += "<p>" + i18n("The following error was returned by umount command:");
+        qerror += "</p><pre>" + job->errorText() + "</pre>";
 
         if (!proclist.isEmpty()) {
             qerror += proclist;
@@ -1273,13 +1273,13 @@
 
         kdDebug() << "unmount failed for " << udi << ": " << error.name << " " << error.message << endl;
         qerror = "<qt>";
-        qerror += i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
+        qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
                        "currently mounted at <b>%4</b> could not be unmounted. ").arg(
                           "system:/media/" + medium->name(),
                           medium->deviceNode(),
                           medium->prettyLabel(),
-                          medium->prettyBaseURL().pathOrURL());
-        qerror += i18n("Unmounting failed due to the following error:");
+                          medium->prettyBaseURL().pathOrURL()) + "</p>";
+        qerror += "<p>" + i18n("Unmounting failed due to the following error:") + "</p>";
         if (!strcmp(error.name, "org.freedesktop.Hal.Device.Volume.Busy")) {
             reason = i18n("Device is Busy:");
         } else if (!strcmp(error.name, "org.freedesktop.Hal.Device.Volume.NotMounted")) {
--- branches/KDE/3.5/kdebase/kioslave/media/mounthelper/kio_media_mounthelper.cpp #662499:662500
@@ -117,10 +117,14 @@
 			DCOPRef mediamanager("kded", "mediamanager");
 			DCOPReply reply = mediamanager.call( "unmount", medium.id());
 			if (reply.isValid())
-			reply.get(m_errorStr);
+                            reply.get(m_errorStr);
+                        if (m_errorStr.isNull())
+                            invokeEject(device, true);
+                        else
+                            error();
 			m_device = device;
-		}
-		invokeEject(device, true);
+		} else
+                    invokeEject(device, true);
 	}
 	else
 	{
@@ -130,7 +134,7 @@
 	    reply.get(m_errorStr);
 	  if (m_errorStr.isNull())
 	    ::exit(0);
-	  else 
+	  else
 	    error();
 	}
 }
@@ -201,5 +205,5 @@
 	app->dcopClient()->attach();
 	return app->exec();
 }
- 
+
 #include "kio_media_mounthelper.moc"
Comment 7 Stephan Kulow 2007-05-08 15:02:33 UTC
*** Bug 135558 has been marked as a duplicate of this bug. ***