From f4c4a24ea1cd8711c186c1c60b43f0bf0bc8af10 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Mar 2011 11:31:08 +0100 Subject: apt-pkg/cdrom.{cc,h}: add ScanForRemovable helper --- apt-pkg/cdrom.cc | 23 ++++++++++++++++------- apt-pkg/cdrom.h | 7 ++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 86fe45fbe..deca6b4ac 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -868,8 +868,19 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ return true; } /*}}}*/ + + /*{{{*/ +// compatiblity only with the old API/ABI, can be removed on the next +// ABI break +vector +pkgUdevCdromDevices::Scan() +{ + return ScanForRemovable(true); +}; + /*}}}*/ + /*{{{*/ vector -pkgUdevCdromDevices::Scan() /*{{{*/ +pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly) { vector cdrom_devices; struct udev_enumerate *enumerate; @@ -881,9 +892,10 @@ pkgUdevCdromDevices::Scan() /*{{{*/ udev_ctx = udev_new(); enumerate = udev_enumerate_new (udev_ctx); - udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1"); - //FIXME: just use removalble here to include usb etc - //udev_enumerate_add_match_sysattr(enumerate, "removable", "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); @@ -899,9 +911,6 @@ pkgUdevCdromDevices::Scan() /*{{{*/ if (mountpath == NULL) mountpath = FindMountPointForDevice(devnode); - if (_config->FindB("Debug::Acquire::cdrom", false)) - cerr << "found " << devnode << " mounted on " << mountpath << endl; - // fill in the struct cdrom.DeviceName = string(devnode); if (mountpath) { diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 5f67a3a94..032fae755 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -68,7 +68,7 @@ class pkgCdrom /*{{{*/ /*}}}*/ -// class that uses libudev to find cdrom devices dynamically +// class that uses libudev to find cdrom/removable devices dynamically struct CdromDevice /*{{{*/ { string DeviceName; @@ -101,7 +101,12 @@ class pkgUdevCdromDevices /*{{{*/ // try to open bool Dlopen(); + + // this is the new interface + vector ScanForRemovable(bool CdromOnly); + // FIXME: compat with the old interface/API/ABI only vector Scan(); + }; /*}}}*/ -- cgit v1.2.3