summaryrefslogtreecommitdiff
path: root/apt-pkg/cdrom.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2011-03-10 11:31:34 +0100
committerMichael Vogt <mvo@debian.org>2011-03-10 11:31:34 +0100
commit5039a4c529d8c62bfd770fe90347a7805f31724a (patch)
treef6414e867aa5827cc94313a67546d7a79e902bad /apt-pkg/cdrom.cc
parente9ecab0f97be19326c52f2afe04fd9b44eba01ae (diff)
parentc9952021ba65db0581f6053cd6d6e8bf7d563e8f (diff)
merged the lp:~mvo/apt/mvo branch
Diffstat (limited to 'apt-pkg/cdrom.cc')
-rw-r--r--apt-pkg/cdrom.cc31
1 files changed, 27 insertions, 4 deletions
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 04ace10a6..55600fe57 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -854,6 +854,7 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/
libudev_handle = h;
udev_new = (udev* (*)(void)) dlsym(h, "udev_new");
udev_enumerate_add_match_property = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_property");
+ udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_sysattr");
udev_enumerate_scan_devices = (int (*)(udev_enumerate*))dlsym(h, "udev_enumerate_scan_devices");
udev_enumerate_get_list_entry = (udev_list_entry* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_list_entry");
udev_device_new_from_syspath = (udev_device* (*)(udev*, const char*))dlsym(h, "udev_device_new_from_syspath");
@@ -867,8 +868,20 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/
return true;
}
/*}}}*/
+
+ /*{{{*/
+// compatiblity only with the old API/ABI, can be removed on the next
+// ABI break
+vector<CdromDevice>
+pkgUdevCdromDevices::Scan()
+{
+ bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true);
+ return ScanForRemovable(CdromOnly);
+};
+ /*}}}*/
+ /*{{{*/
vector<CdromDevice>
-pkgUdevCdromDevices::Scan() /*{{{*/
+pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly)
{
vector<CdromDevice> cdrom_devices;
struct udev_enumerate *enumerate;
@@ -880,7 +893,10 @@ pkgUdevCdromDevices::Scan() /*{{{*/
udev_ctx = udev_new();
enumerate = udev_enumerate_new (udev_ctx);
- udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1");
+ if (CdromOnly)
+ udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1");
+ else
+ udev_enumerate_add_match_sysattr(enumerate, "removable", "1");
udev_enumerate_scan_devices (enumerate);
devices = udev_enumerate_get_list_entry (enumerate);
@@ -892,11 +908,18 @@ pkgUdevCdromDevices::Scan() /*{{{*/
if (udevice == NULL)
continue;
const char* devnode = udev_device_get_devnode(udevice);
- const char* mountpath = udev_device_get_property_value(udevice, "FSTAB_DIR");
+
+ // try fstab_dir first
+ string mountpath;
+ const char* mp = udev_device_get_property_value(udevice, "FSTAB_DIR");
+ if (mp)
+ mountpath = string(mp);
+ else
+ mountpath = FindMountPointForDevice(devnode);
// fill in the struct
cdrom.DeviceName = string(devnode);
- if (mountpath) {
+ if (mountpath != "") {
cdrom.MountPath = mountpath;
string s = string(mountpath);
cdrom.Mounted = IsMounted(s);