23 #include <sys/types.h>
24 #include <sys/mount.h>
31 #define DELAYED_VERIFY 1
52 MediaDISK::MediaDISK(
const Url & url_r,
53 const Pathname & attach_point_hint_r )
58 MIL <<
"MediaDISK::MediaDISK(" << url_r <<
", " << attach_point_hint_r <<
")" << endl;
63 ERR <<
"Media url does not contain a device specification" << std::endl;
67 DBG <<
"Verify of " <<
_device <<
" delayed" << std::endl;
91 if( dev_name.empty() ||
92 dev_name.asString().compare(0,
sizeof(
"/dev/")-1,
"/dev/"))
94 ERR <<
"Specified device name " << dev_name
95 <<
" is not allowed" << std::endl;
99 PathInfo dev_info(dev_name);
100 if( !dev_info.isBlk())
102 ERR <<
"Specified device name " << dev_name
103 <<
" is not a block device" << std::endl;
109 Pathname dpath(
"/dev/disk/by-uuid");
110 std::list<Pathname> dlist;
113 std::list<Pathname>::const_iterator it;
114 for(it = dlist.begin(); it != dlist.end(); ++it)
116 PathInfo vol_info(*it);
117 if( vol_info.isBlk() && vol_info.major() == dev_info.major() &&
118 vol_info.minor() == dev_info.minor())
120 DBG <<
"Specified device name " << dev_name
121 <<
" is a volume (disk/by-uuid link "
122 << vol_info.path() <<
")"
133 Pathname dpath(
"/dev/disk/by-label");
134 std::list<Pathname> dlist;
137 std::list<Pathname>::const_iterator it;
138 for(it = dlist.begin(); it != dlist.end(); ++it)
140 PathInfo vol_info(*it);
141 if( vol_info.isBlk() && vol_info.major() == dev_info.major() &&
142 vol_info.minor() == dev_info.minor())
144 DBG <<
"Specified device name " << dev_name
145 <<
" is a volume (disk/by-label link "
146 << vol_info.path() <<
")"
157 args.push_back(
"blkid" );
158 args.push_back(
"-p" );
159 args.push_back( dev_name.asString() );
163 if ( cmd.
close() != 0 )
166 <<
"Specified device name " << dev_name
167 <<
" is not a usable disk volume"
196 if(!dev_info.isBlk())
199 DBG <<
"Verifying " <<
_device <<
" ..." << std::endl;
210 "disk",
_device, dev_info.major(), dev_info.minor()
218 DBG <<
"Using a shared media "
232 MountEntries::const_iterator e;
233 for( e = entries.begin(); e != entries.end(); ++e)
235 bool is_device =
false;
236 std::string dev_path(Pathname(e->src).asString());
239 if( dev_path.compare(0,
sizeof(
"/dev/")-1,
"/dev/") == 0 &&
240 dev_info(e->src) && dev_info.isBlk())
245 if( is_device && media->maj_nr == dev_info.major() &&
246 media->min_nr == dev_info.minor())
251 DBG <<
"Using a system mounted media "
271 if( mountpoint.empty())
282 if( !media->bdir.empty())
285 mount.
mount(media->bdir, mountpoint,
"none", options);
298 while( !(mountsucceeded=
isAttached()) && --limit)
315 "Unable to verify that the media was mounted",
385 const Pathname & dirname,
bool dots )
const
399 const Pathname & dirname,
bool dots )
const
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
const std::string & execError() const
Some detail telling why the execution failed, if it failed.
std::vector< std::string > Arguments
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::list< DirEntry > DirContent
Returned by readdir.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
std::string asString(const Patch::SeverityFlag &obj)
int close()
Wait for the progamm to complete.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.