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 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'apt-pkg/cdrom.cc') 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) { -- cgit v1.2.3 From 02aa6f67360bbd8f15c29fb0701badda99fc8c75 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Mar 2011 12:15:13 +0100 Subject: apt-pkg/contrib/cdromutl.{cc,h}: return string for mountpath; apt-pkg/cdrom.cc: use string --- apt-pkg/cdrom.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index deca6b4ac..83438f1c4 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -907,13 +907,18 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly) if (udevice == NULL) continue; const char* devnode = udev_device_get_devnode(udevice); - const char* mountpath = udev_device_get_property_value(udevice, "FSTAB_DIR"); - if (mountpath == NULL) + + // 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); -- cgit v1.2.3 From c9952021ba65db0581f6053cd6d6e8bf7d563e8f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Mar 2011 11:13:44 +0100 Subject: * apt-pkg/contrib/cdromutl.{cc,h}, apt-pkg/cdrom.{cc,h}: - deal with missing FSTAB_DIR when using libudev to discover cdrom - add experimental APT::cdrom::CdromOnly option (on by default). When this is set to false apt-cdrom will handle any removable deivce (like a usb-stick) as a "cdrom/dvd" source --- apt-pkg/cdrom.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 83438f1c4..55600fe57 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -875,7 +875,8 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ vector pkgUdevCdromDevices::Scan() { - return ScanForRemovable(true); + bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true); + return ScanForRemovable(CdromOnly); }; /*}}}*/ /*{{{*/ -- cgit v1.2.3