diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2021-01-15 20:14:50 +0200 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2021-01-15 20:14:50 +0200 |
commit | d523b1c1e830092a0ce2fc5b8b9f4bcc27f04d3d (patch) | |
tree | 80f87134cf10649a5fd72b63746232869f7b75c0 | |
parent | b487b5bb8b314d381b6d13dcf4f49898f24b6f4a (diff) | |
download | klamav-d523b1c1e830092a0ce2fc5b8b9f4bcc27f04d3d.tar.gz klamav-d523b1c1e830092a0ce2fc5b8b9f4bcc27f04d3d.zip |
Klamscan: handle block devices correctly.
This resolves issue #12.
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rw-r--r-- | src/directorylist.h | 4 | ||||
-rw-r--r-- | src/klamscan.cpp | 22 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/directorylist.h b/src/directorylist.h index 4e4c058..6c6b451 100644 --- a/src/directorylist.h +++ b/src/directorylist.h @@ -108,12 +108,12 @@ class DeviceItem : public TQObject, public TQCheckListItem void stateChange( bool ); // reimpl. void activate(); // reimpl. void paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width, int align ); // reimpl. + TQString getMountPoint(const TQString & device); public slots: void newItems( const KFileItemList& ); void completed() { if( childCount() == 0 ) { setExpandable( false ); repaint(); } } private: - void mountDevice(const TQString & device); - TQString getMountPoint(const TQString & device); + void mountDevice(const TQString & device); KDirLister m_lister; KURL m_url; bool m_listed; diff --git a/src/klamscan.cpp b/src/klamscan.cpp index 57245c4..0015088 100644 --- a/src/klamscan.cpp +++ b/src/klamscan.cpp @@ -33,6 +33,9 @@ #include <dcopref.h> #include <dcopclient.h> + +#include <sys/stat.h> // TDEIO does not seem to have what we need + using namespace KlamAV; Klamscan::Klamscan(TQWidget *parent, const char *name) @@ -477,9 +480,26 @@ TQStringList Klamscan::pruneSelectedDirs(){ listOfUrlsToScan.sort(); TQString prev; TQStringList prevdirs; + struct stat sb; for (TQStringList::Iterator it = listOfUrlsToScan.begin(); it != listOfUrlsToScan.end(); it++ ){ //kdDebug() << "dir: " << (*it) << endl; - (*it) = (*it).stripWhiteSpace() + "/"; + (*it) = (*it).stripWhiteSpace(); + + // replace block devices with mountpoints + lstat( (*it), &sb ); + if ( (sb.st_mode & S_IFMT) == S_IFBLK ) { + // This is actually from directorylist.cpp + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call( "properties", (*it) ); + + TQStringList properties; + reply.get( properties, "TQStringList" ); + + (*it) = * (properties.at(7) ); + } else { + (*it) = (*it) + "/"; + } + if (prevdirs.isEmpty()){ //kdDebug() << (*it) << endl; filepattern.append(*it); |