From 55c3601ac453a026914dbcb52538b53f4019244a Mon Sep 17 00:00:00 2001
From: Calvin Morrison <calvin@pobox.com>
Date: Fri, 22 May 2026 21:56:10 -0400
Subject: kdf: optionally hide certain fixed size read only filesystems

hide squashfs or iso9960 etc which are fixed size and dont change,
made it a config setting and by default hide them
fix bug with UUID=
fix bad ifdef

Signed-off-by: Calvin Morrison <calvin@pobox.com>
---
 kdf/disklist.cpp  | 27 ++++++++++++++++++++-------
 kdf/disklist.h    |  2 +-
 kdf/kdfconfig.cpp |  9 +++++++++
 kdf/kdfconfig.h   |  1 +
 kdf/stdoption.cpp | 20 ++++++++++++++++++--
 kdf/stdoption.h   |  3 +++
 6 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/kdf/disklist.cpp b/kdf/disklist.cpp
index e4165271..506605d4 100644
--- a/kdf/disklist.cpp
+++ b/kdf/disklist.cpp
@@ -31,7 +31,7 @@
 #include "disklist.h"
 
 #define BLANK ' '
-#define DELIMITER '#'
+#define DELIMITER "#"
 #define FULL_PERCENT 95.0
 
 /***************************************************************************
@@ -183,9 +183,9 @@ TQFile f(FSTAB);
     while (! t.eof()) {
       s=t.readLine();
       s=s.simplifyWhiteSpace();
-      if ( (!s.isEmpty() ) && (s.find(DELIMITER)!=0) && (s.find("LABEL=")!=0) ) {
+      if ( !s.isEmpty() && !s.startsWith(DELIMITER) && !s.startsWith("LABEL=") && !s.startsWith("UUID=") ) {
                // not empty or commented out by '#'
-	       // skip LABEL entries as long as kdf can't handle them properly
+	       // skip LABEL/UUID entries as long as kdf can't handle them properly
 	//	kdDebug() << "GOT: [" << s << "]" << endl;
 	disk = new DiskEntry();// TQ_CHECK_PTR(disk);
         disk->setMounted(false);
@@ -273,6 +273,11 @@ void DiskList::dfDone()
   if (updatesDisabled)
       return; //Don't touch the data for now..
 	  
+  TQString oldgroup=config->group();
+  config->setGroup("KDFConfig");
+  bool hideROFs = config->readBoolEntry("HideReadOnlyFilesystems", true);
+  config->setGroup(oldgroup);
+
   readingDFStdErrOut=true;
   for ( DiskEntry *disk=disks->first(); disk != 0; disk=disks->next() )
     disk->setMounted(false);  // set all devs unmounted
@@ -333,6 +338,12 @@ void DiskList::dfDone()
       disk->setMountPoint(s);
       //kdDebug() << "    MountPoint:       [" << disk->mountPoint() << "]" << endl;
 
+      bool isROFs = (disk->fsType() == "squashfs"
+                  || disk->fsType() == "iso9660"
+                  || disk->fsType() == "udf"
+                  || disk->fsType() == "romfs"
+                  || disk->fsType() == "cramfs");
+
       if ( (disk->kBSize() > 0)
 	   && (disk->deviceName() != "none")
 	   && (disk->fsType() != "swap")
@@ -340,11 +351,13 @@ void DiskList::dfDone()
 	   && (disk->mountPoint() != "/dev/swap")
 	   && (disk->mountPoint() != "/dev/pts")
 	   && (disk->mountPoint() != "/dev/shm")
-	   && (disk->mountPoint().find("/proc") == -1 ) ) {
+	   && (disk->mountPoint().find("/proc") == -1 )
+	   && !(hideROFs && isROFs) ) {
         disk->setMounted(true);    // its now mounted (df lists only mounted)
-	replaceDeviceEntry(disk);
-      } else
-	delete disk;
+        replaceDeviceEntry(disk);
+      } else {
+        delete disk;
+      }
 
     }//if not header
   }//while further lines available
diff --git a/kdf/disklist.h b/kdf/disklist.h
index b0088ad5..3b2c6782 100644
--- a/kdf/disklist.h
+++ b/kdf/disklist.h
@@ -37,7 +37,7 @@
 
 #define DF_COMMAND    "df"
 // be pessimistic: df -T only works under linux !??
-#if defined(_OS_LINUX_) || defined(__dilos__) || defined(__FreeBSD__)
+#if defined(Q_OS_LINUX) || defined(__dilos__) || defined(__FreeBSD__)
 #define DF_ARGS       "-kT"
 #define NO_FS_TYPE    false
 #else
diff --git a/kdf/kdfconfig.cpp b/kdf/kdfconfig.cpp
index 1e5946c7..9e24ef7a 100644
--- a/kdf/kdfconfig.cpp
+++ b/kdf/kdfconfig.cpp
@@ -138,6 +138,12 @@ KDFConfigWidget::KDFConfigWidget(TQWidget *parent, const char *name, bool init)
     TQ_CHECK_PTR(mPopupFullCheck);
     topLayout->addWidget( mPopupFullCheck );
     connect(mPopupFullCheck,TQ_SIGNAL(toggled(bool)),this,TQ_SLOT(slotChanged()));
+
+    text = i18n("Hide read-only filesystems (squashfs, iso9660, etc.)");
+    mHideROCheck = new TQCheckBox( text, this );
+    TQ_CHECK_PTR(mHideROCheck);
+    topLayout->addWidget( mHideROCheck );
+    connect(mHideROCheck,TQ_SIGNAL(toggled(bool)),this,TQ_SLOT(slotChanged()));
   }
 
   loadSettings();
@@ -174,6 +180,7 @@ void KDFConfigWidget::applySettings( void )
     mStd.setUpdateFrequency( mScroll->value() );
     mStd.setPopupIfFull( mPopupFullCheck->isChecked() );
     mStd.setOpenFileManager( mOpenMountCheck->isChecked() );
+    mStd.setHideReadOnlyFilesystems( mHideROCheck->isChecked() );
     mStd.writeConfiguration();
 
     TQListViewItem *item = mList->firstChild();
@@ -206,6 +213,7 @@ void KDFConfigWidget::loadSettings( void )
     mLCD->display( mStd.updateFrequency() );
     mPopupFullCheck->setChecked( mStd.popupIfFull() );
     mOpenMountCheck->setChecked( mStd.openFileManager() );
+    mHideROCheck->setChecked( mStd.hideReadOnlyFilesystems() );
     mFileManagerEdit->setText( mStd.fileManager() );
 
     TQListViewItem *item = mList->firstChild();
@@ -230,6 +238,7 @@ void KDFConfigWidget::defaultsBtnClicked( void )
   mLCD->display( mStd.updateFrequency() );
   mPopupFullCheck->setChecked( mStd.popupIfFull() );
   mOpenMountCheck->setChecked( mStd.openFileManager() );
+  mHideROCheck->setChecked( mStd.hideReadOnlyFilesystems() );
   mFileManagerEdit->setText( mStd.fileManager() );
 
   TQListViewItem *item = mList->firstChild();
diff --git a/kdf/kdfconfig.h b/kdf/kdfconfig.h
index 955a1a7d..522f0af1 100644
--- a/kdf/kdfconfig.h
+++ b/kdf/kdfconfig.h
@@ -85,6 +85,7 @@ class KDFConfigWidget : public TQWidget
     TQLineEdit  *mFileManagerEdit;
     TQCheckBox  *mOpenMountCheck;
     TQCheckBox  *mPopupFullCheck;
+    TQCheckBox  *mHideROCheck;
     CStdOption mStd;
 
   signals:
diff --git a/kdf/stdoption.cpp b/kdf/stdoption.cpp
index 96920a84..9386963c 100644
--- a/kdf/stdoption.cpp
+++ b/kdf/stdoption.cpp
@@ -53,10 +53,12 @@ void CStdOption::updateConfiguration( void )
     "FileManagerCommand", mDefaultFileManager );
   mUpdateFrequency = config.readNumEntry( 
     "UpdateFrequency", mDefaultUpdateFrequency );
-  mPopupIfFull = config.readBoolEntry( 
+  mPopupIfFull = config.readBoolEntry(
     "PopupIfFull", true );
-  mOpenFileManagerOnMount = config.readBoolEntry( 
+  mOpenFileManagerOnMount = config.readBoolEntry(
     "OpenFileMgrOnMount", false );
+  mHideReadOnlyFilesystems = config.readBoolEntry(
+    "HideReadOnlyFilesystems", false);
 }
 
 
@@ -68,6 +70,7 @@ void CStdOption::writeConfiguration( void )
   config.writePathEntry( "FileManagerCommand", mFileManager );
   config.writeEntry( "PopupIfFull", mPopupIfFull );
   config.writeEntry( "OpenFileMgrOnMount", mOpenFileManagerOnMount );
+  config.writeEntry( "HideReadOnlyFilesystems", mHideReadOnlyFilesystems );
   config.sync();
 }  
 
@@ -112,6 +115,7 @@ void CStdOption::setDefault( void )
   mUpdateFrequency = mDefaultUpdateFrequency;
   mPopupIfFull     = true;
   mOpenFileManagerOnMount = false;
+  mHideReadOnlyFilesystems = false;
 }
 
 
@@ -139,6 +143,18 @@ void CStdOption::setOpenFileManager( bool openFileManagerOnMount )
 }
 
 
+bool CStdOption::hideReadOnlyFilesystems( void )
+{
+  return( mHideReadOnlyFilesystems );
+}
+
+
+void CStdOption::setHideReadOnlyFilesystems( bool hide )
+{
+  mHideReadOnlyFilesystems = hide;
+}
+
+
 
 
 
diff --git a/kdf/stdoption.h b/kdf/stdoption.h
index 9ebd09de..aab0ac71 100644
--- a/kdf/stdoption.h
+++ b/kdf/stdoption.h
@@ -44,12 +44,14 @@ class CStdOption
     int     updateFrequency( void );
     bool    popupIfFull( void );
     bool    openFileManager( void );
+    bool    hideReadOnlyFilesystems( void );
 
     void setDefault( void );
     void setFileManager( const TQString &fileManager );
     void setUpdateFrequency( int frequency );
     void setPopupIfFull( bool popupIfFull );
     void setOpenFileManager( bool openFileManagerOnMount );
+    void setHideReadOnlyFilesystems( bool hide );
 
   private:
     static TQString mDefaultFileManager;
@@ -58,6 +60,7 @@ class CStdOption
     int     mUpdateFrequency;
     bool    mPopupIfFull;
     bool    mOpenFileManagerOnMount;
+    bool    mHideReadOnlyFilesystems;
 };
 
 #endif
-- 
cgit v1.2.3

