コード例 #1
0
ファイル: filter-usable.c プロジェクト: cardamon/lvm2
static int _native_check_pv_min_size(struct device *dev)
{
	uint64_t size;
	int ret = 0;

	/* Check it's accessible */
	if (!dev_open_readonly_quiet(dev)) {
		log_debug_devs("%s: Skipping: open failed", dev_name(dev));
		return 0;
	}

	/* Check it's not too small */
	if (!dev_get_size(dev, &size)) {
		log_debug_devs("%s: Skipping: dev_get_size failed", dev_name(dev));
		goto out;
	}

	if (size < pv_min_size()) {
		log_debug_devs("%s: Skipping: %s", dev_name(dev),
				_too_small_to_hold_pv_msg);
		goto out;
	}

	ret = 1;
out:
	if (!dev_close(dev))
		stack;

	return ret;
}
コード例 #2
0
ファイル: dev-type.c プロジェクト: amyvmiwei/bittern
static int _native_dev_is_partitioned(struct dev_types *dt, struct device *dev)
{
	int r;

	if (!_is_partitionable(dt, dev))
		return 0;

	/* Unpartitioned DASD devices are not supported. */
	if (MAJOR(dev->dev) == dt->dasd_major)
		return 1;

	if (!dev_open_readonly_quiet(dev)) {
		log_debug_devs("%s: failed to open device, considering device "
			       "is partitioned", dev_name(dev));
		return 1;
	}

	r = _has_partition_table(dev);

	if (!dev_close(dev))
		stack;

	return r;
}