Пример #1
0
/*
 * Update list of detected modules.
 */
void mod_auto_detect()
{
  hd_data_t *hd_data = NULL;
  hd_t *hd;
  driver_info_t *di;
  str_list_t *sl;
  hd_hw_item_t hw_items[] = { hw_pci, hw_pcmcia, hw_usb, 0 };
  module_t *ml;

  if(config.manual >= 2) return;

  hd_data = calloc(1, sizeof *hd_data);

  hd = hd_list2(hd_data, hw_items, 1);

  for(; hd; hd = hd->next) {
    for(di = hd->driver_info; di; di = di->next) {
      if(di->any.type != di_module) continue;

      for(sl = di->module.names; sl; sl = sl->next) {
        for(ml = config.module.list; ml; ml = ml->next) {
          if(!mod_cmp(ml->name, sl->str)) {
            ml->detected = 1;
            ml->active = di->module.active ? 1 : 0;
          }
        }
      }
    }
  }

  hd_free_hd_data(hd_data);

  free(hd_data);
}
Пример #2
0
void Data::fillDevices(MHWD::DEVICETYPE type)
{
	hd_data_t *hd_data;
	hd_t *hd;
	hw_item hw;
	std::vector<Device*>* devices;

	if (type == MHWD::DEVICETYPE::USB)
	{
		hw = hw_usb;
		devices = &USBDevices;
	}
	else
	{
		hw = hw_pci;
		devices = &PCIDevices;
	}

	// Get the hardware devices
	hd_data = (hd_data_t*) calloc(1, sizeof *hd_data);
	hd = hd_list(hd_data, hw, 1, nullptr);

	Device *device;
	for (; hd; hd = hd->next)
	{
		device = new Device();
		device->type = type;
		device->classID = from_Hex(hd->base_class.id, 2) + from_Hex(hd->sub_class.id, 2).toLower();
		device->vendorID = from_Hex(hd->vendor.id, 4).toLower();
		device->deviceID = from_Hex(hd->device.id, 4).toLower();
		device->className = from_CharArray(hd->base_class.name);
		device->vendorName = from_CharArray(hd->vendor.name);
		device->deviceName = from_CharArray(hd->device.name);
		device->sysfsBusID = from_CharArray(hd->sysfs_bus_id);
		device->sysfsID = from_CharArray(hd->sysfs_id);
		devices->push_back(device);
	}

	hd_free_hd_list(hd);
	hd_free_hd_data(hd_data);
	free(hd_data);
}
Пример #3
0
int main(int argc, char **argv)
{
    hd_data_t *hd_data;
    hd_t *hd;

    hd_data = calloc(1, sizeof *hd_data);

    hd = hd_list(hd_data, hw_scsi, 1, NULL);

    for(; hd; hd = hd->next) {
        hd_dump_entry(hd_data, hd, stdout)
    }

    hd_free_hd_list(hd);		/* free it */
    hd_free_hd_data(hd_data);

    free(hd_data);

    return 0;
}
Пример #4
0
void mhwd::printDeviceDetails(mhwd::TYPE type, FILE *f) {
    hd_data_t *hd_data;
    hd_t *hd;
    hw_item hw;

    if (type == mhwd::TYPE_USB)
        hw = hw_usb;
    else
        hw = hw_pci;

    hd_data = (hd_data_t*)calloc(1, sizeof *hd_data);
    hd = hd_list(hd_data, hw, 1, NULL);

    for(; hd; hd = hd->next) {
        hd_dump_entry(hd_data, hd, f);
    }

    hd_free_hd_list(hd);
    hd_free_hd_data(hd_data);
    free(hd_data);
}
Пример #5
0
void mhwd::fillDevices(mhwd::Data *data, mhwd::TYPE type) {
    hd_data_t *hd_data;
    hd_t *hd;
    hw_item hw;
    std::vector<mhwd::Device*>* devices;

    if (type == mhwd::TYPE_USB) {
        hw = hw_usb;
        devices = &data->USBDevices;
    }
    else {
        hw = hw_pci;
        devices = &data->PCIDevices;
    }


    // Get the hardware devices
    hd_data = (hd_data_t*)calloc(1, sizeof *hd_data);
    hd = hd_list(hd_data, hw, 1, NULL);

    for(; hd; hd = hd->next) {
        struct mhwd::Device *device = new mhwd::Device();
        device->type = type;
        device->classID = from_Hex(hd->base_class.id, 2) + from_Hex(hd->sub_class.id, 2).toLower();
        device->vendorID = from_Hex(hd->vendor.id, 4).toLower();
        device->deviceID = from_Hex(hd->device.id, 4).toLower();
        device->className = from_CharArray(hd->base_class.name);
        device->vendorName = from_CharArray(hd->vendor.name);
        device->deviceName = from_CharArray(hd->device.name);
        device->sysfsBusID = from_CharArray(hd->sysfs_bus_id);
        device->sysfsID = from_CharArray(hd->sysfs_id);

        devices->push_back(device);
    }

    hd_free_hd_list(hd);
    hd_free_hd_data(hd_data);
    free(hd_data);
}
Пример #6
0
ActionReply Helper::probevbe(QVariantMap args)
{
    Q_UNUSED(args)
    ActionReply reply;

#if HAVE_HD
    QStringList gfxmodes;
    hd_data_t hd_data;
    memset(&hd_data, 0, sizeof(hd_data));
    hd_t *hd = hd_list(&hd_data, hw_framebuffer, 1, NULL);
    for (hd_res_t *res = hd->res; res; res = res->next) {
        if (res->any.type == res_framebuffer) {
            gfxmodes += QString("%1x%2x%3").arg(QString::number(res->framebuffer.width), QString::number(res->framebuffer.height), QString::number(res->framebuffer.colorbits));
        }
    }
    hd_free_hd_list(hd);
    hd_free_hd_data(&hd_data);
    reply.addData("gfxmodes", gfxmodes);
#else
    reply = ActionReply::HelperErrorReply();
#endif

    return reply;
}
Пример #7
0
static int ntfs_device_get_geo(struct ntfs_device *dev)
{
	int err;

	if (!dev) {
		errno = EINVAL;
		return -1;
	}
	err = EOPNOTSUPP;
#ifdef ENABLE_HD
	{
		hd_data_t *hddata;
		hd_t *hd, *devlist, *partlist = NULL;
		str_list_t *names;
		hd_res_t *res;
		const int d_name_len = strlen(dev->d_name) + 1;
		int done = 0;

		hddata = calloc(1, sizeof(*hddata));
		if (!hddata) {
			err = ENOMEM;
			goto skip_hd;
		}
		/* List all "disk" class devices on the system. */
		devlist = hd_list(hddata, hw_disk, 1, NULL);
		if (!devlist) {
			free(hddata);
			err = ENOMEM;
			goto skip_hd;
		}
		/*
		 * Loop over each disk device looking for the device with the
		 * same unix name as @dev.
		 */
		for (hd = devlist; hd; hd = hd->next) {
			if (hd->unix_dev_name && !strncmp(dev->d_name,
					hd->unix_dev_name, d_name_len))
				goto got_hd;
			if (hd->unix_dev_name2 && !strncmp(dev->d_name,
					hd->unix_dev_name2, d_name_len))
				goto got_hd;
			for (names = hd->unix_dev_names; names;
					names = names->next) {
				if (names->str && !strncmp(dev->d_name,
						names->str, d_name_len))
					goto got_hd;
			}
		}
		/*
		 * Device was not a whole disk device.  Unless it is a file it
		 * is likely to be a partition device.  List all "partition"
		 * class devices on the system.
		 */
		partlist = hd_list(hddata, hw_partition, 1, NULL);
		for (hd = partlist; hd; hd = hd->next) {
			if (hd->unix_dev_name && !strncmp(dev->d_name,
					hd->unix_dev_name, d_name_len))
				goto got_part_hd;
			if (hd->unix_dev_name2 && !strncmp(dev->d_name,
					hd->unix_dev_name2, d_name_len))
				goto got_part_hd;
			for (names = hd->unix_dev_names; names;
					names = names->next) {
				if (names->str && !strncmp(dev->d_name,
						names->str, d_name_len))
					goto got_part_hd;
			}
		}
		/* Failed to find the device.  Stop trying and clean up. */
		goto end_hd;
got_part_hd:
		/* Get the whole block device the partition device is on. */
		hd = hd_get_device_by_idx(hddata, hd->attached_to);
		if (!hd)
			goto end_hd;
got_hd:
		/*
		 * @hd is now the whole block device either being formatted or
		 * that the partition being formatted is on.
		 *
		 * Loop over each resource of the disk device looking for the
		 * BIOS legacy geometry obtained from EDD which is what Windows
		 * needs to boot.
		 */
		for (res = hd->res; res; res = res->next) {
			/* geotype 3 is BIOS legacy. */
			if (res->any.type != res_disk_geo ||
					res->disk_geo.geotype != 3)
				continue;
			dev->d_heads = res->disk_geo.heads;
			dev->d_sectors_per_track = res->disk_geo.sectors;
			done = 1;
		}
end_hd:
		if (partlist)
			hd_free_hd_list(partlist);
		hd_free_hd_list(devlist);
		hd_free_hd_data(hddata);
		free(hddata);
		if (done) {
			ntfs_log_debug("EDD/BIOD legacy heads = %u, sectors "
					"per track = %u\n", dev->d_heads,
					dev->d_sectors_per_track);
			return 0;
		}
	}
skip_hd:
#endif
#ifdef HDIO_GETGEO
	{	struct hd_geometry geo;

		if (!dev->d_ops->ioctl(dev, HDIO_GETGEO, &geo)) {
			dev->d_heads = geo.heads;
			dev->d_sectors_per_track = geo.sectors;
			ntfs_log_debug("HDIO_GETGEO heads = %u, sectors per "
					"track = %u\n", dev->d_heads,
					dev->d_sectors_per_track);
			return 0;
		}
		err = errno;
	}
#endif
	errno = err;
	return -1;
}
Пример #8
0
void free_hd_structs (hd_data_t * hd_data, hd_t * hd) {
    hd_free_hd_list(hd);          /* free it */
    hd_free_hd_data(hd_data);

    free(hd_data);
}