/** 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 floppy device and * initialise the string data members for the object. Since we only * support floppies using the basic "floppy" driver, we check the driver * using the entry name and a driver-specific ioctl. */ void validateAndInitForFloppy() { bool haveName = false; floppy_drive_name szName; char szDriver[8]; if ( mpcszName[0] != 'f' || mpcszName[1] != 'd' || mpcszName[2] < '0' || mpcszName[2] > '7' || mpcszName[3] != '\0') return; if (!noProbe()) haveName = floppyGetName(mszNode, mpcszName[2] - '0', szName); if (RTLinuxSysFsGetLinkDest(szDriver, sizeof(szDriver), "block/%s/%s", mpcszName, "device/driver") >= 0) { if (RTStrCmp(szDriver, "floppy")) return; } else if (!haveName) return; floppyCreateDeviceStrings(haveName ? szName : NULL, mpcszName[2] - '0', mszDesc, sizeof(mszDesc), mszUdi, sizeof(mszUdi)); misValid = true; }
/** 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(); }