[kde-freebsd] kde / device-notifier treats ufs partition as removable disk?

Max Brazhnikov makc at freebsd.org
Mon Mar 26 16:28:54 UTC 2012


On Thu, 15 Mar 2012 11:26:58 +0200, Andriy Gapon wrote:
> on 15/03/2012 09:31 Andriy Gapon said the following:
> > I'd rather fix the Device Notifier behavior.
> 
> The following patch seems to work.
> The idea is to correctly go from a filesystem Solid device to its StorageDrive
> device ancestor while ignoring intermediate volume/partition devices.
> A direct parent of a filesystem device could be a partition which does not
> support StorageDrive interface and thus nothing intelligent could be deduced
> about its hot plug properties.

I've never experience this problem, but I see the point. 
Can you please submit it directly upstream?

Cheers,
Max


> --- plasma/generic/applets/devicenotifier/devicenotifier.cpp.orig	2012-03-15
> 10:19:48.791075156 +0200
> +++ plasma/generic/applets/devicenotifier/devicenotifier.cpp	2012-03-15
> 11:14:46.896071677 +0200
> @@ -241,6 +241,20 @@ QGraphicsWidget *DeviceNotifier::graphic
>      return m_dialog->dialog();
>  }
> 
> +namespace {
> +    Solid::StorageDrive * getStorageDriveParent(const Solid::Device &device)
> +    {
> +        Solid::Device parentDevice = device;
> +
> +        while ((parentDevice = parentDevice.parent()).isValid()) {
> +            if (parentDevice.is<Solid::StorageDrive>()) {
> +                return parentDevice.as<Solid::StorageDrive>();
> +            }
> +        }
> +        return NULL;
> +    }
> +}
> +
>  void DeviceNotifier::fillPreviousDevices()
>  {
>      m_fillingPreviousDevices = true;
> @@ -249,8 +263,7 @@ void DeviceNotifier::fillPreviousDevices
>      foreach (const Solid::Device &device, list) {
>          // We manually add non-removable devices that are a priori ignored
>          // discard swap and partition tables
> -        Solid::Device parentDevice = device.parent();
> -        Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
> +        Solid::StorageDrive *drive = getStorageDriveParent(device);
>          const Solid::StorageVolume *volume = device.as<Solid::StorageVolume>();
>          if (drive && (!drive->isHotpluggable() && !drive->isRemovable()) &&
>              (volume->usage() == Solid::StorageVolume::FileSystem)) {
> @@ -364,15 +377,12 @@ void DeviceNotifier::deviceAdded(const S
>  {
>      const QString udi = device.udi();
>      if (m_showDevices == NonRemovableOnly) {
> -        Solid::Device parentDevice = device.parent();
> -        Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
> +        Solid::StorageDrive *drive = getStorageDriveParent(device);
>          if (drive && (drive->isHotpluggable() || drive->isRemovable())) {
>              return;
>          }
>      } else if (m_showDevices == RemovableOnly) {
> -        Solid::Device device = Solid::Device(udi);
> -        Solid::Device parentDevice = device.parent();
> -        Solid::StorageDrive *drive = parentDevice.as<Solid::StorageDrive>();
> +        Solid::StorageDrive *drive = getStorageDriveParent(device);
>          if (drive && (!drive->isHotpluggable() && !drive->isRemovable())) {
>              return;
>          }
> 
> 
> 



More information about the kde-freebsd mailing list