Support nfs4 (nfs4://... or nfs://...?type=nfs4) (fate #306451)
authorMichael Andres <ma@suse.de>
Thu, 10 Sep 2009 17:15:43 +0000 (19:15 +0200)
committerMichael Andres <ma@suse.de>
Thu, 10 Sep 2009 17:15:43 +0000 (19:15 +0200)
Also deprecate MediaManager and MediaAccess url scheme classification
methods. They are now directly provided by class Url (schemeIs*).

12 files changed:
zypp/RepoInfo.cc
zypp/RepoManager.cc
zypp/media/MediaAccess.cc
zypp/media/MediaAccess.h
zypp/media/MediaHandler.h
zypp/media/MediaISO.cc
zypp/media/MediaManager.cc
zypp/media/MediaManager.h
zypp/media/MediaNFS.cc
zypp/media/MediaPriority.cc
zypp/media/Mount.cc
zypp/repo/PackageProvider.cc

index 1aafa1c..0567ad7 100644 (file)
@@ -262,7 +262,7 @@ namespace zypp
     {
       if (_pimpl->baseUrls.empty())
         return false;
-      else if ( media::MediaAccess::downloads( *baseUrlsBegin() ) )
+      else if ( baseUrlsBegin()->schemeIsDownloading() )
         return true;
       else
         return false;
index 59969d8..c817854 100644 (file)
@@ -1209,7 +1209,7 @@ namespace zypp
       }
 
       // if it is a non-downloading URL denoting a directory
-      if ( ! media::MediaManager::downloads(url) )
+      if ( ! url.schemeIsDownloading() )
       {
         MediaMounter media( url );
         if ( PathInfo(media.getPathName()).isDir() )
index 8fd21ca..cff2d01 100644 (file)
@@ -115,7 +115,7 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point)
     */
     if (scheme == "cd" || scheme == "dvd")
         _handler = new MediaCD (url,preferred_attach_point);
-    else if (scheme == "nfs")
+    else if (scheme == "nfs" || scheme == "nfs4")
         _handler = new MediaNFS (url,preferred_attach_point);
     else if (scheme == "iso")
         _handler = new MediaISO (url,preferred_attach_point);
@@ -165,22 +165,6 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point)
     MIL << "Opened: " << *this << endl;
 }
 
-// STATIC
-bool
-MediaAccess::downloads(const Url &url)
-{
-    std::string scheme( url.getScheme());
-    return (scheme == "ftp" || scheme == "http" || scheme == "https");
-}
-
-// STATIC
-bool
-MediaAccess::canBeVolatile(const Url &url)
-{
-    std::string scheme( url.getScheme());
-    return ! (scheme == "cd" || scheme == "dvd");
-}
-
 // Type of media if open, otherwise NONE.
 std::string
 MediaAccess::protocol() const
index 8aa60cd..76e078b 100644 (file)
@@ -105,29 +105,10 @@ namespace zypp {
         */
        bool        downloads() const;
 
-       /**
-        * Hint if files will be downloaded when using the
-        * specified media \p url.
-        *
-        * @note This hint is based on the \p url scheme
-        * only and does not imply, that the URL is valid.
-        *
-        * @param url The media URL to check.
-        * @return True, if the files are downloaded.
-        */
+       /** \deprecated Use \ref Url::schemeIsVolatile */
        static
-       bool        downloads(const Url &url);
-       /**
-        * Hint whether the media can provide volatile contents
-        *
-        * @note This hint is based on the \p url scheme
-        * only and does not imply, that the URL is valid.
-        *
-        * @param url The media URL to check.
-        * @return True, if the files are downloaded.
-        */
-       static
-       bool        canBeVolatile(const Url &url);
+       ZYPP_DEPRECATED bool canBeVolatile(const Url &url)
+        { return url.schemeIsVolatile(); }
 
        /**
         * Used Protocol if media is opened, otherwise 'unknown'.
@@ -168,14 +149,14 @@ namespace zypp {
         *
         **/
        bool isAttached() const;
-        
+
         bool hasMoreDevices() const;
-        
+
         /**
          * Fill in a vector of detected ejectable devices and the index of the
          * currently attached device within the vector. The contents of the vector
          * are the device names (/dev/cdrom and such).
-         * 
+         *
          * \param devices  vector to load with the device names
          * \param index    index of the currently used device in the devices vector
          */
@@ -340,7 +321,7 @@ namespace zypp {
          *
          **/
         bool doesFileExist( const Pathname & filename ) const;
-        
+
        /**
         * Destructor
         **/
index 6a5ce99..349c150 100644 (file)
@@ -1,3 +1,4 @@
+
 /*---------------------------------------------------------------------\
 |                          ____ _   __ __ ___                          |
 |                         |__  / \ / / . \ . \                         |
@@ -682,15 +683,15 @@ class MediaHandler {
         bool doesFileExist( const Pathname & filename ) const;
 
         /**
-         * Check if the media has one more device available for attach(true). 
+         * Check if the media has one more device available for attach(true).
          */
         virtual bool hasMoreDevices();
-        
+
         /**
          * Fill in a vector of detected ejectable devices and the index of the
          * currently attached device within the vector. The contents of the vector
          * are the device names (/dev/cdrom and such).
-         * 
+         *
          * \param devices  vector to load with the device names
          * \param index    index of the currently used device in the devices vector
          */
index 8193795..9accb70 100644 (file)
@@ -102,12 +102,12 @@ namespace zypp
             << src.asString() << std::endl;
         ZYPP_THROW(MediaUnsupportedUrlSchemeException(src));
       }
-#if 1
       else
       if( !(src.getScheme() == "hd"   ||
             src.getScheme() == "dir"  ||
             src.getScheme() == "file" ||
             src.getScheme() == "nfs"  ||
+            src.getScheme() == "nfs4" ||
             src.getScheme() == "smb"  ||
             src.getScheme() == "cifs"))
       {
@@ -115,7 +115,6 @@ namespace zypp
             << src.asString() << std::endl;
         ZYPP_THROW(MediaUnsupportedUrlSchemeException(src));
       }
-#endif
 
       MediaManager manager;
 
index fa8a884..149f565 100644 (file)
@@ -351,14 +351,6 @@ namespace zypp
     }
 
     // ---------------------------------------------------------------
-    // STATIC
-    bool
-    MediaManager::downloads(const Url &url)
-    {
-      return MediaAccess::downloads( url);
-    }
-
-    // ---------------------------------------------------------------
     Url
     MediaManager::url(MediaAccessId accessId) const
     {
index 65c3d01..5142428 100644 (file)
@@ -265,7 +265,7 @@ namespace zypp
      *       Optional parameter specifying the URL to the directory containing
      *       the iso file.<br>
      *       The supported URL schemes are: <i><b>hd</b>, <b>dir</b>,
-     *       <b>file</b>, <b>nfs</b>, <b>smb</b>, <b>cifs</b>.</i>
+     *       <b>file</b>, <b>nfs</b>, <b>nfs4</b>, <b>smb</b>, <b>cifs</b>.</i>
      *     - <tt>mnt</tt>:
      *       Optional parameter specifying the prefered attach point for the
      *       source media url.
@@ -282,16 +282,21 @@ namespace zypp
      * The access handler for media on NFS exported directory tree.
      *   - Scheme:
      *     - <b>nfs</b>
+     *     - <b>nfs</b>
      *   - Examples:
      *     \code
      *        "nfs://nfs-server/exported/path"
      *        "nfs://nfs-server/exported/path?mountoptions=ro"
+     *        "nfs://nfs-server/exported/path&type=nfs4"
+     *        "nfs4://nfs-server/exported/path"
      *     \endcode
      *   - Query parameters:
      *     - <tt>mountoptions</tt>:
      *       The mount options separated by comma ','.
      *       Default is the "ro" option.
-     *   - Authority:
+     *     - <tt>type=nfs4</tt>:
+     *       Whether to mount as nfs4. This is the default for scheme nfs4.
+      *   - Authority:
      *     The authority component has to provide a hostname.
      *     Username, password and port are currently ignored.
      *   - Path name:
@@ -504,18 +509,10 @@ namespace zypp
       bool
       downloads(MediaAccessId accessId) const;
 
-      /**
-       * Hint if files will be downloaded when using the
-       * specified media \p url.
-       *
-       * @note This hint is based on the \p url scheme
-       * only and does not imply, that the URL is valid.
-       *
-       * @param url The media URL to check.
-       * @return True, if the files are downloaded.
-       */
-      static bool
-      downloads(const Url &url);
+     /** \deprecated Use \ref Url::schemeIsDownloading */
+      static
+      ZYPP_DEPRECATED bool downloads(const Url &url)
+      { return url.schemeIsDownloading(); }
 
       /**
        * Returns the \ref MediaAccessUrl of the media access id.
index ec34874..63c1fc5 100644 (file)
@@ -86,8 +86,7 @@ namespace zypp {
        return;
       }
 
-      const char* const filesystem = "nfs";
-      std::string       mountpoint = attachPoint().asString();
+      std::string mountpoint( attachPoint().asString() );
       Mount mount;
 
       if( !isUseableAttachPoint(attachPoint()))
@@ -98,6 +97,12 @@ namespace zypp {
        setAttachPoint( mountpoint, true);
       }
 
+      std::string filesystem( _url.getScheme() );
+      if ( filesystem != "nfs4" && _url.getQueryParam("type") == "nfs4" )
+      {
+        filesystem = "nfs4";
+      }
+
       string options = _url.getQueryParam("mountoptions");
       if(options.empty())
       {
index 5731ad4..b063661 100644 (file)
@@ -66,6 +66,7 @@ namespace zypp
 
          case 'n':
            RETURN_IF( "nfs",   3 );
+           RETURN_IF( "nfs4",  3 );
            break;
 
          case 's':
index 899adbb..66da0df 100644 (file)
@@ -124,7 +124,7 @@ void Mount::mount( const std::string & source,
        }
        else if  ( value.find ( "Not a directory" ) != string::npos )
        {
-           if( filesystem == "nfs")
+           if( filesystem == "nfs" || filesystem == "nfs4" )
            {
                err = "Nfs path is not a directory";
            }
index c5b17a9..551bfef 100644 (file)
 #include "zypp/TmpPath.h"
 #include "zypp/ZConfig.h"
 #include "zypp/RepoInfo.h"
-#include "zypp/media/MediaManager.h"
 
 using std::endl;
-using zypp::media::MediaManager;
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -159,7 +157,7 @@ namespace zypp
         url = * info.baseUrlsBegin();
 
       // check whether to process patch/delta rpms
-      if ( MediaManager::downloads(url) || ZConfig::instance().download_use_deltarpm_always() )
+      if ( url.schemeIsDownloading() || ZConfig::instance().download_use_deltarpm_always() )
         {
           std::list<DeltaRpm> deltaRpms;
           if ( ZConfig::instance().download_use_deltarpm() )