[Kde-hardware-devel] How to determine what drive an Optical Disc is in

Kevin Ottens ervin at kde.org
Thu Jan 31 14:03:13 CET 2008


Le jeudi 31 janvier 2008, Chris Gow a écrit :
> On Thursday 31 January 2008 03:22:05 Kevin Ottens wrote:
> > Le mercredi 30 janvier 2008, Chris Gow a écrit :
> > > If I have a Solid::OpticalDisc object, how do I find out what
> > > device/drive it is mounted in?
> > >
> > > Solid::Device *d = new Solid::Device(someValidDeviceID);
> > > Solid::OpticalDisc *opticalDisc = d->as<Solid::OpticalDisc>();
> > >
> > > QString mountedAt = /* eg. /dev/cdrom or some such */
> >
> > [I assume you meant "/media/cdrom", not "/dev/cdrom" which is not a
> > mountpoint]
>
> Actually, I think either would do. But given my mistake, how can I
> determine what device the CD is in?

For the dev file:
Solid::Block *block = d->as<Solid::Block>();
QString deviceNode = block->device();

Now I wonder what I should improve in the doc so that you could find this by 
yourself... Or you didn't dig in it, or I did something wrong (I guess it's 
the latter, there's room for improvement in the doc).

> > You have to use the StorageAccess interface on the same device object,
> > which would give:
> > Solid::StorageAccess *access = d->as<Solid::StorageAccess>();
> > QString mountedAt = access->filePath();
>
> Ok, on my system (Kubuntu 7.10, KDE 4.0.0), I get the following:
>
> access->filePath() returns ""
> access->isAccessable() returns false
> access->setup() returns true
> access->setupDone() contains errors:
> Error Data  QVariant(QByteArray, "mount: block device /dev/scd0 is
> write-protected, mounting read-only
> mount: wrong fs type, bad option, bad superblock on /dev/scd0,
>        missing codepage or helper program, or other error
>        In some cases useful info is found in syslog - try
>        dmesg | tail  or so
>
> I also get a number of empty return values when I deal with the OpticalDisc
> object too. Not sure if it is a packaging problem, or because the CD isn't
> mounted the methods don't return values.

Because it's not mounted. Note that mounting makes sense only if it's a data 
cd. :-)

Regards.
-- 
Kévin 'ervin' Ottens, http://ervin.ipsquad.net
"Ni le maître sans disciple, Ni le disciple sans maître,
Ne font reculer l'ignorance."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20080131/e6d61c0a/attachment.pgp 


More information about the Kde-hardware-devel mailing list