Remove dead code paths processing only automounted media.
authorMichael Andres <ma@suse.de>
Fri, 23 Apr 2010 19:08:40 +0000 (21:08 +0200)
committerMichael Andres <ma@suse.de>
Mon, 26 Apr 2010 10:04:43 +0000 (12:04 +0200)
- This code was not active but required libhal to detect auomounted media.
  As libhal is dropped, it's time for cleanup.

zypp/media/MediaCD.cc
zypp/media/MediaCD.h
zypp/media/MediaDISK.cc
zypp/media/MediaHandler.cc
zypp/media/MediaHandler.h

index 5d91182..a7a5eb3 100644 (file)
 
 #include <linux/cdrom.h>
 
-#define NO_HAL
-
-/*
-** try umount of foreign (user/automounter) media on eject
-**   0 = don't force, 1 = automounted only, 2 == all
-*/
-#define  FORCE_RELEASE_FOREIGN   2
-
-/*
-** Reuse foreign (user/automounter) mount points.
-** 0 = don't use, 1 = automounted only, 2 = all
-*/
-#define  REUSE_FOREIGN_MOUNTS    2
-
 /*
 ** if to throw exception on eject errors or ignore them
 */
@@ -371,7 +357,6 @@ namespace zypp {
         break;
       }
 
-#if REUSE_FOREIGN_MOUNTS > 0
       {
         MediaManager  manager;
         MountEntries  entries( manager.getMountEntries());
@@ -393,12 +378,6 @@ namespace zypp {
           {
             AttachPointRef ap( new AttachPoint(e->dir, false));
             AttachedMedia  am( media, ap);
-            //
-            // 1 = automounted only, 2 == all
-            //
-#if REUSE_FOREIGN_MOUNTS == 1
-            if( isAutoMountedMedia(am))
-#endif
             {
               DBG << "Using a system mounted media "
                   << media->name
@@ -419,7 +398,6 @@ namespace zypp {
         if( mountsucceeded)
           break;
       }
-#endif  // REUSE_FOREIGN_MOUNTS
 
       // close tray
       closeTray( it->name );
@@ -531,10 +509,7 @@ namespace zypp {
       ZYPP_CAUGHT(excpt_r);
       if (!ejectDev.empty())
       {
-#if FORCE_RELEASE_FOREIGN > 0
-        /* 1 = automounted only, 2 = all */
-        forceRelaseAllMedia(false, FORCE_RELEASE_FOREIGN == 1);
-#endif
+        forceRelaseAllMedia(false);
         if(openTray( ejectDev ))
           return;
       }
@@ -544,10 +519,7 @@ namespace zypp {
     // eject device
     if (!ejectDev.empty())
     {
-#if FORCE_RELEASE_FOREIGN > 0
-      /* 1 = automounted only, 2 = all */
-      forceRelaseAllMedia(false, FORCE_RELEASE_FOREIGN == 1);
-#endif
+      forceRelaseAllMedia(false);
       if( !openTray( ejectDev ))
       {
 #if REPORT_EJECT_ERRORS
@@ -637,10 +609,7 @@ namespace zypp {
         AttachedMedia ret( findAttachedMedia( media));
         if( !ret.mediaSource)
         {
-#if FORCE_RELEASE_FOREIGN > 0
-          /* 1 = automounted only, 2 = all */
-          forceRelaseAllMedia(media, false, FORCE_RELEASE_FOREIGN == 1);
-#endif
+          forceRelaseAllMedia(media, false);
           if ( openTray( it->name ) )
           {
             ejected = true;
@@ -657,69 +626,6 @@ namespace zypp {
     }
   }
 
-  bool MediaCD::isAutoMountedMedia(const AttachedMedia &media)
-  {
-    bool is_automounted = false;
-    if( media.mediaSource && !media.mediaSource->name.empty())
-    {
-#ifndef NO_HAL
-      using namespace zypp::target::hal;
-      try
-      {
-        HalContext hal(true);
-
-        HalVolume vol = hal.getVolumeFromDeviceFile(media.mediaSource->name);
-        if( vol)
-        {
-          std::string udi = vol.getUDI();
-          std::string key;
-          std::string mnt;
-
-          try
-          {
-            key = "info.hal_mount.created_mount_point";
-            mnt = hal.getDevicePropertyString(udi, key);
-
-            if(media.attachPoint->path == mnt)
-              is_automounted = true;
-          }
-          catch(const HalException &e1)
-          {
-            ZYPP_CAUGHT(e1);
-
-            try
-            {
-              key = "volume.mount_point";
-              mnt = hal.getDevicePropertyString(udi, key);
-
-              if(media.attachPoint->path == mnt)
-                is_automounted = true;
-            }
-            catch(const HalException &e2)
-            {
-              ZYPP_CAUGHT(e2);
-            }
-          }
-        }
-      }
-      catch(const HalException &e)
-      {
-        ZYPP_CAUGHT(e);
-      }
-#else // NO_HAL
-#warning Can not detect automounted media without HAL
-    INT << "Can not detect automounted media without HAL!" << endl;
-    // ma@: This codepath is probably unused due to 'REUSE_FOREIGN_MOUNTS == 2'
-    // Maybe we should cleanup all this automount-specail-handling.
-#endif
-    }
-    DBG << "Media "        << media.mediaSource->asString()
-        << " attached on " << media.attachPoint->path
-        << " is"           << (is_automounted ? "" : " not")
-        << " automounted"  << std::endl;
-    return is_automounted;
-  }
-
   ///////////////////////////////////////////////////////////////////
   //
   //  METHOD NAME : MediaCD::isAttached
index 647f511..e93415f 100644 (file)
@@ -56,8 +56,6 @@ namespace zypp {
 
         virtual void forceEject(const std::string & ejectDev);
 
-       virtual bool isAutoMountedMedia(const AttachedMedia &media);
-        
         virtual bool hasMoreDevices();
 
         virtual void
index d1e5ff5..bdffe59 100644 (file)
 #define DELAYED_VERIFY           1
 
 /*
-** Reuse foreign (user/automounter) mount points.
-** 0 = don't use, 1 = automounted only, 2 = all
-*/
-#define  REUSE_FOREIGN_MOUNTS    2
-
-/*
 ** Path to the vol_id tool (normal system, instsys)
 */
 #define VOL_ID_TOOL_PATHS        { "/sbin/vol_id", "/lib/udev/vol_id", NULL}
@@ -252,10 +246,10 @@ namespace zypp {
       //   mount /dev/<partition> /tmp_mount
       //   mount /tmp_mount/<dir> <to> --bind -o ro
       // FIXME: try all filesystems
-    
+
       if(_device.empty())
        ZYPP_THROW(MediaBadUrlEmptyDestinationException(url()));
-    
+
       PathInfo dev_info(_device);
       if(!dev_info.isBlk())
         ZYPP_THROW(MediaBadUrlEmptyDestinationException(url()));
@@ -309,15 +303,8 @@ namespace zypp {
        if( is_device && media->maj_nr == dev_info.major() &&
                         media->min_nr == dev_info.minor())
        {
-#if REUSE_FOREIGN_MOUNTS > 0
          AttachPointRef ap( new AttachPoint(e->dir, false));
          AttachedMedia  am( media, ap);
-         //
-         // 1 = automounted only, 2 == all
-         //
-#if REUSE_FOREIGN_MOUNTS == 1
-         if( isAutoMountedMedia(am))
-#endif
          {
            DBG << "Using a system mounted media "
                << media->name
@@ -331,9 +318,6 @@ namespace zypp {
            setAttachPoint(ap);
            return;
          }
-#else
-         media->bdir = e->dir;
-#endif
        }
       }
 
@@ -434,7 +418,7 @@ namespace zypp {
     {
       MediaHandler::getFile( filename );
     }
-    
+
     ///////////////////////////////////////////////////////////////////
     //
     // METHOD NAME : MediaDISK::getDir
@@ -446,7 +430,7 @@ namespace zypp {
     {
       MediaHandler::getDir( dirname, recurse_r );
     }
-    
+
     ///////////////////////////////////////////////////////////////////
     //
     //
@@ -460,7 +444,7 @@ namespace zypp {
     {
       MediaHandler::getDirInfo( retlist, dirname, dots );
     }
-    
+
     ///////////////////////////////////////////////////////////////////
     //
     //
@@ -478,8 +462,8 @@ namespace zypp {
     bool MediaDISK::getDoesFileExist( const Pathname & filename ) const
     {
       return MediaHandler::getDoesFileExist( filename );
-    }    
-    
+    }
+
   } // namespace media
 } // namespace zypp
 // vim: set ts=8 sts=2 sw=2 ai noet:
index a202601..f5ab569 100644 (file)
@@ -768,20 +768,13 @@ void MediaHandler::release( const std::string & ejectDev )
   MIL << "Released: " << *this << endl;
 }
 
-bool MediaHandler::isAutoMountedMedia(const AttachedMedia &media)
+void MediaHandler::forceRelaseAllMedia(bool matchMountFs)
 {
-  (void)media;
-  return false;
-}
-
-void MediaHandler::forceRelaseAllMedia(bool matchMountFs, bool autoMountedOny)
-{
-  forceRelaseAllMedia( attachedMedia().mediaSource, matchMountFs, autoMountedOny);
+  forceRelaseAllMedia( attachedMedia().mediaSource, matchMountFs);
 }
 
 void MediaHandler::forceRelaseAllMedia(const MediaSourceRef &ref,
-                                       bool                  matchMountFs,
-                                      bool                  autoMountedOny)
+                                       bool                  matchMountFs)
 {
   if( !ref)
     return;
@@ -806,19 +799,6 @@ void MediaHandler::forceRelaseAllMedia(const MediaSourceRef &ref,
 
       if( ref->equals( media) && e->type != "subfs")
       {
-       if(autoMountedOny)
-       {
-         try {
-           AttachedMedia am(MediaSourceRef(new MediaSource(media)),
-                            AttachPointRef(new AttachPoint(e->dir)));
-           if( !isAutoMountedMedia(am))
-             continue;
-         }
-         catch(...)
-         {
-             continue;
-         }
-       }
         DBG << "Forcing release of media device "
             << ref->asString()
             << " in the mount table as "
@@ -840,19 +820,6 @@ void MediaHandler::forceRelaseAllMedia(const MediaSourceRef &ref,
       MediaSource media(mtype, e->src);
       if( ref->equals( media))
       {
-       if(autoMountedOny)
-       {
-         try {
-           AttachedMedia am(MediaSourceRef(new MediaSource(media)),
-                            AttachPointRef(new AttachPoint(e->dir)));
-           if( !isAutoMountedMedia(am))
-             continue;
-         }
-         catch(...)
-         {
-             continue;
-         }
-       }
        DBG << "Forcing release of media name "
            << ref->asString()
            << " in the mount table as "
index 349c150..97bf4e1 100644 (file)
@@ -278,12 +278,9 @@ class MediaHandler {
         *        mount table (nfs, smb and cifs) or from mediaSource
         *        while compare of a mount entry with mediaSource.
         */
-       void             forceRelaseAllMedia(bool matchMountFs,
-                                            bool autoMountedOny=true);
+       void             forceRelaseAllMedia(bool matchMountFs);
        void             forceRelaseAllMedia(const MediaSourceRef &ref,
-                                            bool matchMountFs,
-                                            bool autoMountedOnly=true);
-       virtual bool     isAutoMountedMedia(const AttachedMedia &media);
+                                            bool matchMountFs);
 
     protected: