예제 #1
0
 /** Check whether the sysfs block entry is valid for a DVD device and
  * initialise the string data members for the object.  We try to get all
  * the information we need from sysfs if possible, to avoid unnecessarily
  * poking the device, and if that fails we fall back to an SCSI INQUIRY
  * command. */
 void validateAndInitForDVD()
 {
     char szVendor[128], szModel[128];
     ssize_t cchVendor, cchModel;
     int64_t type = RTLinuxSysFsReadIntFile(10, "block/%s/device/type",
                                            mpcszName);
     if (type >= 0 && type != TYPE_ROM)
         return;
     if (type == TYPE_ROM)
     {
         cchVendor = RTLinuxSysFsReadStrFile(szVendor, sizeof(szVendor),
                                             "block/%s/device/vendor",
                                             mpcszName);
         if (cchVendor >= 0)
         {
             cchModel = RTLinuxSysFsReadStrFile(szModel, sizeof(szModel),
                                                "block/%s/device/model",
                                                mpcszName);
             if (cchModel >= 0)
             {
                 misValid = true;
                 dvdCreateDeviceStrings(szVendor, szModel,
                                        mszDesc, sizeof(mszDesc),
                                        mszUdi, sizeof(mszUdi));
                 return;
             }
         }
     }
     if (!noProbe())
         probeAndInitForDVD();
 }
 /** Check whether the sysfs block entry is valid for a DVD device and
  * initialise the string data members for the object.  We try to get all
  * the information we need from sysfs if possible, to avoid unnecessarily
  * poking the device, and if that fails we fall back to an SCSI INQUIRY
  * command. */
 void validateAndInitForDVD()
 {
     char szVendor[128], szModel[128];
     int64_t type = 0;
     int rc = RTLinuxSysFsReadIntFile(10, &type, "block/%s/device/type", mpcszName);
     if (RT_SUCCESS(rc) && type != TYPE_ROM)
         return;
     if (type == TYPE_ROM)
     {
         rc = RTLinuxSysFsReadStrFile(szVendor, sizeof(szVendor), NULL,
                                      "block/%s/device/vendor", mpcszName);
         if (RT_SUCCESS(rc))
         {
             rc = RTLinuxSysFsReadStrFile(szModel, sizeof(szModel), NULL,
                                          "block/%s/device/model", mpcszName);
             if (RT_SUCCESS(rc))
             {
                 misValid = true;
                 dvdCreateDeviceStrings(szVendor, szModel,
                                        mszDesc, sizeof(mszDesc),
                                        mszUdi, sizeof(mszUdi));
                 return;
             }
         }
     }
     if (!noProbe())
         probeAndInitForDVD();
 }