- Fixed attachpoint creation
authorMarius Tomaschewski <mt@suse.de>
Mon, 6 Feb 2006 12:23:45 +0000 (12:23 +0000)
committerMarius Tomaschewski <mt@suse.de>
Mon, 6 Feb 2006 12:23:45 +0000 (12:23 +0000)
zypp/media/MediaCurl.cc
zypp/media/MediaDISK.cc
zypp/media/MediaHandler.cc
zypp/media/MediaNFS.cc
zypp/media/MediaSMB.cc

index 5ccb457..0a88d84 100644 (file)
@@ -103,6 +103,14 @@ void MediaCurl::attachTo (bool next)
   if ( !_url.isValid() )
     ZYPP_THROW(MediaBadUrlException(_url));
 
+  if( attachPoint().empty() || attachPoint().asString() == "/")
+  {
+    std::string mountpoint = createAttachPoint().asString();
+    if( mountpoint.empty())
+      ZYPP_THROW( MediaBadAttachPointException(url()));
+      setAttachPoint( mountpoint, true);
+  }
+
   _curl = curl_easy_init();
   if ( !_curl ) {
     ZYPP_THROW(MediaCurlInitException(_url));
index b9e38bd..121c5dd 100644 (file)
@@ -78,14 +78,22 @@ namespace zypp {
        ZYPP_THROW(MediaBadUrlEmptyFilesystemException(url()));
     
       Mount mount;
-      const char *mountpoint = attachPoint().asString().c_str();
+      std::string mountpoint = attachPoint().asString();
+      if( mountpoint.empty() || mountpoint == "/")
+      {
+       mountpoint = createAttachPoint().asString();
+       if( mountpoint.empty())
+         ZYPP_THROW( MediaBadAttachPointException(url()));
+       setAttachPoint( mountpoint, true);
+      }
+
       string options = _url.getQueryParam("mountoptions");
       if(options.empty())
       {
        options="ro";
       }
     
-      mount.mount(_device,mountpoint,_filesystem,options);
+      mount.mount(_device,mountpoint.c_str(),_filesystem,options);
     }
 
 
index b68bcf9..9948875 100644 (file)
@@ -60,7 +60,7 @@ MediaHandler::MediaHandler ( const Url &      url_r,
 
     PathInfo adir( attach_point_r );
     // FIXME: verify if attach_point_r isn't a mountpoint of other device
-    if ( attach_point_r.asString() == "/" || !adir.isDir() ) {
+    if ( !adir.isDir() ) {
       ERR << "Provided attach point is not a directory: " << adir << endl;
     }
     else {
index 46ca8b0..9f3dbcc 100644 (file)
@@ -63,9 +63,17 @@ namespace zypp {
        ZYPP_THROW(MediaNotSupportedException(_url));
     
       const char* const filesystem = "nfs";
-      const char *mountpoint = attachPoint().asString().c_str();
+      std::string       mountpoint = attachPoint().asString();
       Mount mount;
-    
+
+      if( mountpoint.empty() || mountpoint == "/")
+      {
+       mountpoint = createAttachPoint().asString();
+       if( mountpoint.empty())
+         ZYPP_THROW( MediaBadAttachPointException(url()));
+       setAttachPoint( mountpoint, true);
+      }
+
       string path = _url.getHost();
       path += ':';
       path += _url.getPathName();
@@ -90,7 +98,7 @@ namespace zypp {
        options = str::join( optionList, "," );
       }
     
-      mount.mount(path,mountpoint,filesystem,options);
+      mount.mount(path,mountpoint.c_str(),filesystem,options);
     }
 
 
index 050909b..3077a52 100644 (file)
@@ -122,9 +122,17 @@ namespace zypp {
       if(next)
        ZYPP_THROW(MediaNotSupportedException(_url));
     
-      const char *mountpoint = attachPoint().asString().c_str();
+      std::string mountpoint = attachPoint().asString();
+      if( mountpoint.empty() || mountpoint == "/")
+      {
+       mountpoint = createAttachPoint().asString();
+       if( mountpoint.empty())
+         ZYPP_THROW( MediaBadAttachPointException(url()));
+       setAttachPoint( mountpoint, true);
+      }
+
       Mount mount;
-    
       string path = "//";
       path += _url.getHost() + "/" + getShare( _url.getPathName() );
    
@@ -199,7 +207,7 @@ namespace zypp {
       //
       //////////////////////////////////////////////////////
     
-      mount.mount( path, mountpoint, _vfstype,
+      mount.mount( path, mountpoint.c_str(), _vfstype,
                   options.asString(), environment );
     }