Exemplo n.º 1
0
/**
 * allocate and initialize struct storage_device
 * @param type		device type (STORAGE_TYPE_*)
 * @param host_id	host id
 * @param device_id	device id
 * @param guid		guid of the device (can be NULL)
 * @param sector_size	sector size of the device
 */
struct storage_device *storage_new(int type, int host_id, int device_id, struct guid *guid, int sector_size)
{
	struct storage_device *storage = alloc(sizeof(*storage));

	if (guid == NULL)
		guid = &anyguid;
	memcpy(&storage->guid, guid, sizeof(*guid));
	storage->busid.type = type;
	storage->busid.host_id = host_id;
	storage->busid.device_id = device_id;
	storage->sector_size = sector_size;
	storage_set_keys(storage);
	return storage;
}
Exemplo n.º 2
0
/**
 * allocate and initialize struct storage_device
 * @param type		device type (STORAGE_TYPE_*)
 * @param host_id	host id
 * @param device_id	device id
 * @param guid		guid of the device (can be NULL)
 * @param sector_size	sector size of the device
 */
struct storage_device *
storage_new (int type, int host_id, int device_id, struct guid *guid,
	     struct storage_extend *extend)
{
	struct storage_device *storage = alloc(sizeof(*storage));
	struct storage_init init;

	if (guid == NULL)
		guid = &anyguid;
	init.guid = guid;
	init.type = type;
	init.host_id = host_id;
	init.device_id = device_id;
	init.extend = extend;
	storage_set_keys(storage, &init);
	return storage;
}