[mythtv] Ticket #3077: Default CD Device selection
Andrew Nicholson
abhuman at gmail.com
Wed Mar 7 05:10:11 UTC 2007
On Sun, Mar 04, 2007 at 03:52:47PM +0000, Matthew Wire wrote:
> The code for this is quite simple. Passing a device (eg. /dev/hdb)
> returns either the name (eg. LITE-ON DVDRW SOHW-832S) or the device
> (/dev/hdb) if it cannot find a name. It only retrieves a name for ide
> drives.
>
> QString MediaMonitor::GetCDDeviceModel(QString &dev)
> {
> #ifdef linux
> QString devname = dev.mid(5);
> if (devname.startsWith("hd"))
> { // Is an IDE drive
> QFile file("/proc/ide/"+devname+"/model");
> if (file.open(IO_ReadOnly))
> {
> QTextStream stream(&file);
> dev = stream.read();
> file.close();
> }
> }
> #endif
> return dev.stripWhiteSpace();
> }
Even better, for those of us with sysfs:
QFile file("/sys/block/"+devname+"/device/model");
This should work for any block device.
Cheers,
Andrew
More information about the mythtv-dev
mailing list