15#include <linux/cdrom.h>
27#include <zypp-media/Mount>
28#include <zypp-media/CDTools>
39#define REPORT_EJECT_ERRORS 0
52 using DeviceList = std::list<MediaSource>;
68 ERR <<
"Can't create udev context." << endl;
75 ERR <<
"Can't create udev list entry." << endl;
79 ::udev_enumerate_add_match_subsystem(
enumerate,
"block" );
80 ::udev_enumerate_add_match_property(
enumerate,
"ID_CDROM",
"1" );
81 ::udev_enumerate_scan_devices(
enumerate );
87 ::udev_list_entry_get_name(
entry ) ),
88 ::udev_device_unref );
91 ERR <<
"Can't create udev device." << endl;
95 if (
supportingDVD_r && ! ::udev_device_get_property_value( device,
"ID_CDROM_DVD" ) )
100 const char *
devnodePtr( ::udev_device_get_devnode( device ) );
103 ERR <<
"Got NULL devicenode." << endl;
114 DBG <<
"Found (udev): " << media << std::endl;
120 WAR <<
"Did not find any CD/DVD device." << endl;
133 , _lastdev_tried( -1 )
137 if (
url_r.getScheme() !=
"dvd" &&
url_r.getScheme() !=
"cd" )
139 ERR <<
"Unsupported schema in the Url: " <<
url_r.asString() << endl;
146 std::vector<std::string>
words;
148 for (
const std::string & device :
words )
150 if ( device.empty() )
155 DBG <<
"use device (delayed verify)" << device << endl;
160 DBG <<
"going to use on-demand device list" << endl;
166 ERR <<
"Unable to find any cdrom drive for " <<
_url.
asString() << endl;
200 WAR <<
"CD/DVD drive detection with UDEV failed! Guessing..." << std::endl;
206 DBG <<
"Found (GUESS): " << media << std::endl;
213 DBG <<
"Found (GUESS): " << media << std::endl;
223 DBG <<
"creating on-demand device list" << endl;
225 std::string device(
"/dev/cdrom" );
283 if ( options.empty() )
306 DBG <<
"skipping device " <<
it->name << endl;
316 if ( !
dinfo.isBlk() )
318 WAR <<
"skipping non block device: " <<
dinfo << endl;
321 DBG <<
"trying device " <<
dinfo << endl;
328 if(
ret.mediaSource &&
ret.attachPoint &&
329 !
ret.attachPoint->empty())
331 DBG <<
"Using a shared media "
332 <<
ret.mediaSource->name
334 <<
ret.attachPoint->path
346 MountEntries entries(
manager.getMountEntries());
347 MountEntries::const_iterator
e;
348 for(
e = entries.begin();
e != entries.end(); ++
e)
354 if(
dev_path.compare(0,
sizeof(
"/dev/")-1,
"/dev/") == 0 &&
361 media->min_nr ==
dev_info.devMinor())
366 DBG <<
"Using a system mounted media "
411 WAR <<
"Wait for /proc/mounts update and retry...." << endl;
431 "Unable to verify that the media was mounted",
454 if( !
merr.mountOutput().empty())
459 merr.mountOutput()));
485 if(
am.mediaSource &&
am.mediaSource->iown)
486 mount.
umount(
am.attachPoint->path.asString());
506#if REPORT_EJECT_ERRORS
523#if REPORT_EJECT_ERRORS
540 if( !
dinfo.isBlk() )
542 WAR <<
"skipping non block device: " <<
dinfo << endl;
545 DBG <<
"trying device " <<
dinfo << endl;
549 if( !
ret.mediaSource )
554#if REPORT_EJECT_ERRORS
562#if REPORT_EJECT_ERRORS
666 MIL <<
"got " <<
devices.size() <<
" detected devices, current: "
668 <<
"(" <<
index <<
")" << endl;
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Base class for Exception.
std::string getScheme() const
Returns the scheme name of the URL.
std::string asString() const
Returns a default string representation of the Url object.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
Wrapper class for stat/lstat.
const std::string & asString() const
String representation.
std::list< DirEntry > DirContent
Returned by readdir.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Easy-to use interface to the ZYPP dependency resolver.
std::string asString(const Patch::Category &obj)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.