<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>87637</bug_id>
          
          <creation_ts>2004-08-20 21:22:10 +0000</creation_ts>
          <short_desc>KFloppy: no user visible error message when fdformat finds an error at verify</short_desc>
          <delta_ts>2005-05-07 16:59:06 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kfloppy</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>Compiled Sources</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nicolas Goutte">nicolasg</reporter>
          <assigned_to name="Bernd Wuebben">wuebben</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>260524</commentid>
    <comment_count>0</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2004-08-20 21:22:10 +0000</bug_when>
    <thetext>Version:            (using KDE KDE 3.3.0)
Installed from:    Compiled From Sources
Compiler:          gcc 3.3.1 -march=pentium2
OS:                Linux

When fdformat finds an error on the floppy, KFloppy returns to the normal dialog without any error.

The problem is that an user might assume that formatting is finished and then wonders that the floppy does not work, as it has not any file system.

Have a nice day!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>267024</commentid>
    <comment_count>1</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2004-09-09 00:40:48 +0000</bug_when>
    <thetext>Problem still remaining.

There are 2 problems:
- fdformat complains with a string having a number, so the current code assumes that the number is a track number. (Not good!)
- when an &quot;action&quot; quits with an error, the user is not informed. (Not good either!)

Have a nice day!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>298524</commentid>
    <comment_count>2</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2005-01-01 17:51:14 +0000</bug_when>
    <thetext>CVS commit by goutte: 

Process two error messages of fdformat
(Especially useful, as one of the errors is typical for a failed verify.)
(Linux only)
CCBUG:87637


  M +17 -2     format.cpp   1.25


--- kdeutils/kfloppy/format.cpp  #1.24:1.25
@@ -483,8 +483,23 @@ void FDFormat::processStdOut(KProcess *,
         DEBUGS(s);
         QRegExp regexp( &quot;([0-9]+)&quot; );
-        if ( regexp.search(s) &gt; -1 )
+        if (s.startsWith(&quot;bad data at cyl&quot;) || s.startsWith(&quot;Problem reading cylinder&quot;))
+        {
+            const int track = regexp.cap(1).toInt();
+            if (track&gt;=0)
         {
+                emit status(i18n(&quot;Low-level formatting error at track %1!&quot;).arg(track), -1);
+            }
+            else
+            {
+                // This error should not happen
+                emit status(i18n(&quot;Low-level formatting error: %1&quot;).arg(s), -1);
+            }
+            return;
+        }
+        else if ( regexp.search(s) &gt; -1 )
+        {
+            // Normal track number (formatting or verifying)
             const int p = regexp.cap(1).toInt();
-            if ((p&gt;0) &amp;&amp; (p&lt;deviceInfo-&gt;tracks))
+            if ((p&gt;=0) &amp;&amp; (p&lt;deviceInfo-&gt;tracks))
             {
                     emit status(QString::null,


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>339962</commentid>
    <comment_count>3</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2005-05-06 16:23:57 +0000</bug_when>
    <thetext>Waldo Bastian has probably fixed this in the revision 39550 of the file kdeutils/kfloppy/format.cpp
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>339963</commentid>
    <comment_count>4</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2005-05-06 16:24:52 +0000</bug_when>
    <thetext>I meant revision 395550 </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>339988</commentid>
    <comment_count>5</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2005-05-06 17:41:53 +0000</bug_when>
    <thetext>SVN commit 410059 by goutte:

- Try to give useful messages why a program (especially fdformat) has failed
  (Especially allow more than one error message to be passed to the dialog.)
- Be more careful while processing fdformat errors
  (Checking for numbers must be last, as /dev/fd0u1440 contains a number too.)
CCBUG:87637

- Give a better error message if fdformat cannot work because the device
  is mounted. (The work is done only for fdformat now.)
CCBUG:103954


 M  +14 -1     trunk/KDE/kdeutils/kfloppy/floppy.cpp  
 M  +19 -12    trunk/KDE/kdeutils/kfloppy/format.cpp  


--- trunk/KDE/kdeutils/kfloppy/floppy.cpp #410058:410059
@@ -410,6 +410,9 @@
   // formatbutton-&gt;setText(i18n(&quot;A&amp;bort&quot;));
   setEnabled(false);
 
+        // Erase text box
+        frame-&gt;setText( QString::null );
+
 	if (!findDevice())
 	{
 		reset();
@@ -515,7 +518,17 @@
 {
     kdDebug(2002) &lt;&lt; &quot;FloppyData::formatStatus: &quot; &lt;&lt; s &lt;&lt; &quot; : &quot;  &lt;&lt; p &lt;&lt; endl;
 	if (!s.isEmpty())
-		frame-&gt;setText(s);
+        {
+            const QString oldText ( frame-&gt;text() );
+            if ( oldText.isEmpty() )
+            {
+                frame-&gt;setText( s );
+            }
+            else
+            {
+                frame-&gt;setText( oldText + &apos;\n&apos; + s );
+            }
+        }
 
 	if ((0&lt;=p) &amp;&amp; (p&lt;=100))
 		progress-&gt;setValue(p);
--- trunk/KDE/kdeutils/kfloppy/format.cpp #410058:410059
@@ -332,13 +332,13 @@
 		}
 		else
 		{
-			emit status(i18n(&quot;%1 terminated with an error.&quot;).arg(theProcessName),100);
+			emit status(i18n(&quot;The program %1 terminated with an error.&quot;).arg(theProcessName),100);
 			emit done(this,false);
 		}
 	}
 	else
 	{
-		emit status(i18n(&quot;%1 terminated abnormally.&quot;).arg(theProcessName),100);
+		emit status(i18n(&quot;The program %1 terminated abnormally.&quot;).arg(theProcessName),100);
 		emit done(this,false);
 	}
 }
@@ -504,16 +504,6 @@
             }
             return;
         }
-        else if ( regexp.search(s) &gt; -1 )
-        {
-            // Normal track number (formatting or verifying)
-            const int p = regexp.cap(1).toInt();
-            if ((p&gt;=0) &amp;&amp; (p&lt;deviceInfo-&gt;tracks))
-            {
-                    emit status(QString::null,
-                            p * 100 / deviceInfo-&gt;tracks);
-            }
-        }
 	else if (s.find(&quot;ioctl(FDFMTBEG)&quot;)!=-1)
 	{
             emit status (i18n(
@@ -522,11 +512,28 @@
                     &quot;have selected a valid floppy drive.&quot;),-1);
             return;
 	}
+        else if (s.find(&quot;busy&quot;)!=-1) // &quot;Device or resource busy&quot;
+        {
+            emit status(i18n(&quot;Device busy!\nPerhaps you need to unmount the floppy first!&quot;),-1);
+            return;
+        }
+        // Be careful to leave &quot;iotcl&quot; as last before checking numbers
         else if (s.find(&quot;ioctl&quot;)!=-1)
         {
             emit status(i18n(&quot;Low-level format error: %1&quot;).arg(s),-1);
             return;
         }
+        // Check for numbers at last (as /dev/fd0u1440 has numbers too)
+        else if ( regexp.search(s) &gt; -1 )
+        {
+            // Normal track number (formatting or verifying)
+            const int p = regexp.cap(1).toInt();
+            if ((p&gt;=0) &amp;&amp; (p&lt;deviceInfo-&gt;tracks))
+            {
+                    emit status(QString::null,
+                            p * 100 / deviceInfo-&gt;tracks);
+            }
+        }
 #endif
 	return;
 }
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>339991</commentid>
    <comment_count>6</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2005-05-06 17:51:44 +0000</bug_when>
    <thetext>SVN commit 410067 by goutte:

Propagate the &quot;device busy&quot; error to the user (FAT, Ext2, Minix)
(Unfortunately, it is shown two times currently!)
(Linux only)

CCBUG: 103954
CCBUG: 87637


 M  +55 -1     trunk/KDE/kdeutils/kfloppy/format.cpp  
 M  +9 -1      trunk/KDE/kdeutils/kfloppy/format.h  


--- trunk/KDE/kdeutils/kfloppy/format.cpp #410066:410067
@@ -626,11 +626,29 @@
 	}
 }
 
+void FATFilesystem::processStdOut(KProcess *, char *b, int l)
+{
+#ifdef ANY_BSD
+    // ### TODO: do some checks
+#elif defined(ANY_LINUX)
+    QString s ( QString::fromLatin1( b, l ) );
+    kdDebug(KFAREA) &lt;&lt; s &lt;&lt; endl;
+    if (s.find(&quot;mounted file system&quot;)!=-1) // &quot;/dev/fd0 contains a mounted file system
+    {
+        emit status(i18n(&quot;Floppy is mounted!\nYou need to unmount the floppy first!&quot;),-1);
+        return;
+    }
+    else if (s.find(&quot;busy&quot;)!=-1) // &quot;Device or resource busy&quot;
+    {
+        emit status(i18n(&quot;Device busy!\nPerhaps you need to unmount the floppy first!&quot;),-1);
+        return;
+    }
+#endif
+}
 
 
 
 
-
 #ifdef ANY_BSD
 
 /* static */ QString UFSFilesystem::newfs = QString::null ;
@@ -758,8 +776,28 @@
 	}
 }
 
+void Ext2Filesystem::processStdOut(KProcess *, char *b, int l)
+{
+#ifdef ANY_BSD
+    // ### TODO: do some checks
+#elif defined(ANY_LINUX)
+    QString s ( QString::fromLatin1( b, l ) );
+    kdDebug(KFAREA) &lt;&lt; s &lt;&lt; endl;
+    if (s.find(&quot;mounted&quot;)!=-1) // &quot;/dev/fd0 is mounted; will not make a filesystem here!&quot;
+    {
+        emit status(i18n(&quot;Floppy is mounted!\nYou need to unmount the floppy first!&quot;),-1);
+        return;
+    }
+    else if (s.find(&quot;busy&quot;)!=-1) // &quot;Device or resource busy&quot;
+    {
+        emit status(i18n(&quot;Device busy!\nPerhaps you need to unmount the floppy first!&quot;),-1);
+        return;
+    }
+#endif
+}
 
 
+
 #endif
 
 #ifdef ANY_LINUX
@@ -833,6 +871,22 @@
 	}
 }
 
+void MinixFilesystem::processStdOut(KProcess *, char *b, int l)
+{
+    QString s ( QString::fromLatin1( b, l ) );
+    kdDebug(KFAREA) &lt;&lt; s &lt;&lt; endl;
+    if (s.find(&quot;mounted&quot;)!=-1) // &quot;mkfs.minix: /dev/fd0 is mounted; will not make a filesystem here!&quot;
+    {
+        emit status(i18n(&quot;Floppy is mounted!\nYou need to unmount the floppy first!&quot;),-1);
+        return;
+    }
+    else if (s.find(&quot;busy&quot;)!=-1) // &quot;Device or resource busy&quot;
+    {
+        emit status(i18n(&quot;Device busy!\nPerhaps you need to unmount the floppy first!&quot;),-1);
+        return;
+    }
+}
+
 #endif
 
 #include &quot;format.moc&quot;
--- trunk/KDE/kdeutils/kfloppy/format.h #410066:410067
@@ -283,6 +283,9 @@
 	 */	
 	bool configure(bool verify, bool label, const QString &amp;l);
 	
+        /// Parse output
+        virtual void processStdOut(KProcess*, char* b, int l);
+        
 protected:
 	static QString newfs_fat;
 	
@@ -313,6 +316,9 @@
 	
 	/// Same args as FATFilesystem::configure
 	bool configure(bool verify, bool label, const QString &amp;l);
+
+        /// Parse output
+        virtual void processStdOut(KProcess*, char* b, int l);
 	
 protected:
 	static QString newfs;
@@ -358,7 +364,9 @@
 	
 	/// Same args as FATFilesystem::configure
 	bool configure(bool verify, bool label, const QString &amp;l);
-	
+        
+        /// Parse output
+        virtual void processStdOut(KProcess*, char* b, int l);
 protected:
 	static QString newfs;
 	
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>339997</commentid>
    <comment_count>7</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2005-05-06 18:44:48 +0000</bug_when>
    <thetext>SVN commit 410082 by goutte:

- avoid that messages from the high-level formatters would be duplicated
- fix the detecting of the track number when fdformat fails verifying
  (Linux only)
CCBUG:87637


 M  +0 -16     trunk/KDE/kdeutils/kfloppy/floppy.cpp  
 M  +2 -3      trunk/KDE/kdeutils/kfloppy/format.cpp  


--- trunk/KDE/kdeutils/kfloppy/floppy.cpp #410081:410082
@@ -444,10 +444,6 @@
 	if ( filesystemComboBox-&gt;currentText() == i18n(&quot;DOS&quot;) )
 	{
 		FATFilesystem *f = new FATFilesystem(this);
-		connect(f,SIGNAL(status(const QString &amp;,int)),
-			this,SLOT(formatStatus(const QString &amp;,int)));
-		connect(f,SIGNAL(done(KFAction *,bool)),
-			this,SLOT(reset()));
 		f-&gt;configure(verifylabel-&gt;isChecked(),
 			labellabel-&gt;isChecked(),
 			lineedit-&gt;text());
@@ -463,10 +459,6 @@
 			lineedit-&gt;text());
 		if (f)
 		{
-			connect(f,SIGNAL(status(const QString &amp;,int)),
-				this,SLOT(formatStatus(const QString &amp;,int)));
-			connect(f,SIGNAL(done(KFAction *,bool)),
-				this,SLOT(reset()));
 			f-&gt;configureDevice(drive,blocks);
 			formatActions-&gt;queue(f);
 		}
@@ -480,10 +472,6 @@
 
 		if (f)
 		{
-			connect(f,SIGNAL(status(const QString &amp;,int)),
-				this,SLOT(formatStatus(const QString &amp;,int)));
-			connect(f,SIGNAL(done(KFAction *,bool)),
-				this,SLOT(reset()));
 			f-&gt;configureDevice(drive,blocks);
 			formatActions-&gt;queue(f);
 		}
@@ -499,10 +487,6 @@
 			lineedit-&gt;text());
 		if (f)
 		{
-			connect(f,SIGNAL(status(const QString &amp;,int)),
-				this,SLOT(formatStatus(const QString &amp;,int)));
-			connect(f,SIGNAL(done(KFAction *,bool)),
-				this,SLOT(reset()));
 			f-&gt;configureDevice(drive,blocks);
 			formatActions-&gt;queue(f);
 		}
--- trunk/KDE/kdeutils/kfloppy/format.cpp #410081:410082
@@ -133,7 +133,6 @@
 
 	if (!success)
 	{
-            // ### TODO: the user must be told that the action has failed.
 		DEBUGS(&quot;Action failed.&quot;);
 		emit done(this,false);
 		return;
@@ -492,9 +491,9 @@
         QRegExp regexp( &quot;([0-9]+)&quot; );
         if (s.startsWith(&quot;bad data at cyl&quot;) || s.startsWith(&quot;Problem reading cylinder&quot;))
         {
-            const int track = regexp.cap(1).toInt();
-            if (track&gt;=0)
+            if ( regexp.search( s ) &gt; -1 )
             {
+                const int track = regexp.cap(1).toInt();
                 emit status(i18n(&quot;Low-level formatting error at track %1!&quot;).arg(track), -1);
             }
             else
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>340166</commentid>
    <comment_count>8</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2005-05-07 16:59:06 +0000</bug_when>
    <thetext>This works now for &quot;trunk&quot;. I will have to see what can be backported while giving sense without new user-visible messages.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>