[mythtv] Ticket #3077: Default CD Device selection

Nigel Pearson nigel at ind.tansu.com.au
Thu Mar 8 22:28:46 UTC 2007


> I already did some code to support both:

Nice and small, but it only gets the sysfs model, and not the vendor.
Here is my bloated one:

static void LookupModel(MythMediaDevice* device)
{
     QString   desc;
     QString   devname = device->getDevicePath();
     QFileInfo devpath(devname);


     // Paths like /dev/cdrom usually point to something like /dev/hdc
     if (devpath.isSymLink())
         devname = devpath.readLink();


     // Given something like /dev/sdb1, extract sdb
     devname.mid(5,3);


#ifdef linux
     if (devname.startsWith("hd"))  // IDE drive
     {
         QFile  file("/proc/ide/" + devname + "/model");
         if (file.open(IO_ReadOnly))
         {
             QTextStream stream(&file);

             desc.append(stream.read());
             file.close();
         }
     }

     if (devname.startsWith("sd"))  // SATA/USB/FireWire
     {
         QString path = devname.prepend("/sys/block/");
         path.append("/device/");

         QFile  file(path + "vendor");
         if (file.open(IO_ReadOnly))
         {
             QTextStream stream(&file);

             desc.append(stream.read());
             desc.append(' ');
             file.close();
         }

         file.setName(path + "model");
         if (file.open(IO_ReadOnly))
         {
             QTextStream stream(&file);

             desc.append(stream.read());
             desc.append(' ');
             file.close();
         }
     }
#endif

     device->setDeviceModel(desc);
}


...
> However, I do wonder how many people actually have
> more than two drives (or even one) in their systems...

Indeed. Probably morphing molehill into mountain.


I have two at home, but am only using one because
MythTV can't easily distinguish between them.
Annoyingly, they are both Pioneer A108s,
so the vendor/model won't help :(

--
Nigel Pearson, nigel at ind.tansu.com.au|"Beware - I am a carrier
Telstra Net. Eng., Sydney, Australia |          of surrealism"
Office: 9202 3900    Fax:  9261 3912 |       D  A
Mobile: 0408 664435  Home: 9792 6998 |       L  I



More information about the mythtv-dev mailing list