Ejemplo n.º 1
0
static float
identify_partition(int fd, partition_data *partition, void **cookie)
{
	DEBUG_INIT_ETC(NULL, ("fd: %d, id: %ld, offset: %Ld, "
		"size: %Ld, block_size: %ld, flags: 0x%lx", fd,
		partition->id, partition->offset, partition->size,
		partition->block_size, partition->flags));

	device_geometry geometry;
	float result = -1;
	if ((partition->flags & B_PARTITION_IS_DEVICE) != 0
		&& partition->block_size == 2048
		&& ioctl(fd, B_GET_GEOMETRY, &geometry) == 0
		&& geometry.device_type == B_CD) {
		Disc *disc = new(std::nothrow) Disc(fd);
		if (disc != NULL && disc->InitCheck() == B_OK) {
			// If we have only a single session then we can let the file system
			// drivers play directly with the device.
			Session *session = disc->GetSession(1);
			if (session != NULL) {
				result = 0.9f;
				delete session;
			} else
				result = 0.1f;

			*cookie = static_cast<void*>(disc);
		} else
			delete disc;
	}
	PRINT(("returning %g\n", result));
	return result;
}