Ejemplo n.º 1
0
static status_t
get_geometry(cd_handle *handle, device_geometry *geometry)
{
	cd_driver_info *info = handle->info;

	status_t status = update_capacity(info);

	// it seems that Be expects B_GET_GEOMETRY to always succeed unless
	// the medium has been changed; e.g. if we report B_DEV_NO_MEDIA, the
	// info is ignored by the CDPlayer and CDBurner
	if (status == B_DEV_MEDIA_CHANGED)
		return B_DEV_MEDIA_CHANGED;

	geometry->bytes_per_sector = info->block_size;
	geometry->sectors_per_track = 1;
	geometry->cylinder_count = info->capacity;
	geometry->head_count = 1;
	geometry->device_type = info->device_type;
	geometry->removable = info->removable;

	// TBD: for all but CD-ROMs, read mode sense - medium type
	// (bit 7 of block device specific parameter for Optical Memory Block Device)
	// (same for Direct-Access Block Devices)
	// (same for write-once block devices)
	// (same for optical memory block devices)
	geometry->read_only = true;
	geometry->write_once = info->device_type == scsi_dev_WORM;

	TRACE("scsi_disk: get_geometry(): %ld, %ld, %ld, %ld, %d, %d, %d, %d\n",
		geometry->bytes_per_sector, geometry->sectors_per_track,
		geometry->cylinder_count, geometry->head_count, geometry->device_type,
		geometry->removable, geometry->read_only, geometry->write_once);

	return B_OK;
}
Ejemplo n.º 2
0
static status_t
get_geometry(das_handle* handle, device_geometry* geometry)
{
    das_driver_info* info = handle->info;

    status_t status = update_capacity(info);
    if (status < B_OK)
        return status;

    geometry->bytes_per_sector = info->block_size;
    geometry->sectors_per_track = 1;
    geometry->cylinder_count = info->capacity;
    geometry->head_count = 1;
    geometry->device_type = B_DISK;
    geometry->removable = info->removable;

    // TBD: for all but CD-ROMs, read mode sense - medium type
    // (bit 7 of block device specific parameter for Optical Memory Block Device)
    // (same for Direct-Access Block Devices)
    // (same for write-once block devices)
    // (same for optical memory block devices)
    geometry->read_only = false;
    geometry->write_once = false;

    TRACE("scsi_disk: get_geometry(): %ld, %ld, %ld, %ld, %d, %d, %d, %d\n",
          geometry->bytes_per_sector, geometry->sectors_per_track,
          geometry->cylinder_count, geometry->head_count, geometry->device_type,
          geometry->removable, geometry->read_only, geometry->write_once);

    return B_OK;
}
Ejemplo n.º 3
0
void MetaspaceCounters::update_all() {
  if (UsePerfData) {
    update_used();
    update_capacity();
    update_max_capacity();
    _current_size->set_value(MetaspaceAux::reserved_in_bytes());
  }
}
Ejemplo n.º 4
0
static status_t
cd_init_device(void* _info, void** _cookie)
{
	cd_driver_info* info = (cd_driver_info*)_info;

	update_capacity(info);
		// Get initial capacity, but ignore the result; we do not care
		// whether or not a media is present

	*_cookie = info;
	return B_OK;
}
Ejemplo n.º 5
0
static status_t
cd_init_device(void* _info, void** _cookie)
{
	cd_driver_info* info = (cd_driver_info*)_info;

	// and get (initial) capacity
	status_t status = update_capacity(info);
	if (status != B_OK)
		return status;

	*_cookie = info;
	return B_OK;
}
 inline void update_all() {
   update_used();
   update_capacity();
 }
Ejemplo n.º 7
0
static status_t
cd_ioctl(void* cookie, uint32 op, void* buffer, size_t length)
{
	cd_handle* handle = (cd_handle*)cookie;
	cd_driver_info *info = handle->info;

	TRACE("ioctl(op = %lu)\n", op);

	switch (op) {
		case B_GET_DEVICE_SIZE:
		{
			status_t status = update_capacity(info);
			if (status != B_OK)
				return status;

			size_t size = info->capacity * info->block_size;
			return user_memcpy(buffer, &size, sizeof(size_t));
		}

		case B_GET_GEOMETRY:
		{
			if (buffer == NULL /*|| length != sizeof(device_geometry)*/)
				return B_BAD_VALUE;

		 	device_geometry geometry;
			status_t status = get_geometry(handle, &geometry);
			if (status != B_OK)
				return status;

			return user_memcpy(buffer, &geometry, sizeof(device_geometry));
		}

		case B_GET_ICON_NAME:
			return user_strlcpy((char*)buffer, "devices/drive-optical",
				B_FILE_NAME_LENGTH);

		case B_GET_VECTOR_ICON:
		{
			device_icon iconData;
			if (length != sizeof(device_icon))
				return B_BAD_VALUE;
			if (user_memcpy(&iconData, buffer, sizeof(device_icon)) != B_OK)
				return B_BAD_ADDRESS;

			if (iconData.icon_size >= (int32)sizeof(kCDIcon)) {
				if (user_memcpy(iconData.icon_data, kCDIcon,
						sizeof(kCDIcon)) != B_OK)
					return B_BAD_ADDRESS;
			}

			iconData.icon_size = sizeof(kCDIcon);
			return user_memcpy(buffer, &iconData, sizeof(device_icon));
		}

		case B_SCSI_GET_TOC:
			// TODO: we pass a user buffer here!
			return get_toc(info, (scsi_toc *)buffer);

		case B_EJECT_DEVICE:
		case B_SCSI_EJECT:
			return load_eject(info, false);

		case B_LOAD_MEDIA:
			return load_eject(info, true);

		case B_SCSI_GET_POSITION:
		{
			if (buffer == NULL)
				return B_BAD_VALUE;

			scsi_position position;
			status_t status = get_position(info, &position);
			if (status != B_OK)
				return status;

			return user_memcpy(buffer, &position, sizeof(scsi_position));
		}

		case B_SCSI_GET_VOLUME:
			// TODO: we pass a user buffer here!
			return get_set_volume(info, (scsi_volume *)buffer, false);
		case B_SCSI_SET_VOLUME:
			// TODO: we pass a user buffer here!
			return get_set_volume(info, (scsi_volume *)buffer, true);

		case B_SCSI_PLAY_TRACK:
		{
			scsi_play_track track;
			if (user_memcpy(&track, buffer, sizeof(scsi_play_track)) != B_OK)
				return B_BAD_ADDRESS;

			return play_track_index(info, &track);
		}
		case B_SCSI_PLAY_POSITION:
		{
			scsi_play_position position;
			if (user_memcpy(&position, buffer, sizeof(scsi_play_position))
					!= B_OK)
				return B_BAD_ADDRESS;

			return play_msf(info, &position);
		}

		case B_SCSI_STOP_AUDIO:
			return stop_audio(info);
		case B_SCSI_PAUSE_AUDIO:
			return pause_resume(info, false);
		case B_SCSI_RESUME_AUDIO:
			return pause_resume(info, true);

		case B_SCSI_SCAN:
		{
			scsi_scan scanBuffer;
			if (user_memcpy(&scanBuffer, buffer, sizeof(scsi_scan)) != B_OK)
				return B_BAD_ADDRESS;

			return scan(info, &scanBuffer);
		}
		case B_SCSI_READ_CD:
			// TODO: we pass a user buffer here!
			return read_cd(info, (scsi_read_cd *)buffer);

		default:
			return sSCSIPeripheral->ioctl(handle->scsi_periph_handle, op,
				buffer, length);
	}
}
Ejemplo n.º 8
0
static status_t
das_ioctl(void* cookie, uint32 op, void* buffer, size_t length)
{
    das_handle* handle = (das_handle*)cookie;
    das_driver_info* info = handle->info;

    TRACE("ioctl(op = %d)\n", op);

    switch (op) {
    case B_GET_DEVICE_SIZE:
    {
        status_t status = update_capacity(info);
        if (status != B_OK)
            return status;

        size_t size = info->capacity * info->block_size;
        return user_memcpy(buffer, &size, sizeof(size_t));
    }

    case B_GET_GEOMETRY:
    {
        if (buffer == NULL /*|| length != sizeof(device_geometry)*/)
            return B_BAD_VALUE;

        device_geometry geometry;
        status_t status = get_geometry(handle, &geometry);
        if (status != B_OK)
            return status;

        return user_memcpy(buffer, &geometry, sizeof(device_geometry));
    }

    case B_GET_ICON_NAME:
        // TODO: take device type into account!
        return user_strlcpy((char*)buffer, info->removable
                            ? "devices/drive-removable-media" : "devices/drive-harddisk",
                            B_FILE_NAME_LENGTH);

    case B_GET_VECTOR_ICON:
    {
        // TODO: take device type into account!
        device_icon iconData;
        if (length != sizeof(device_icon))
            return B_BAD_VALUE;
        if (user_memcpy(&iconData, buffer, sizeof(device_icon)) != B_OK)
            return B_BAD_ADDRESS;

        if (iconData.icon_size >= (int32)sizeof(kDriveIcon)) {
            if (user_memcpy(iconData.icon_data, kDriveIcon,
                            sizeof(kDriveIcon)) != B_OK)
                return B_BAD_ADDRESS;
        }

        iconData.icon_size = sizeof(kDriveIcon);
        return user_memcpy(buffer, &iconData, sizeof(device_icon));
    }

    case B_EJECT_DEVICE:
    case B_SCSI_EJECT:
        return load_eject(info, false);

    case B_LOAD_MEDIA:
        return load_eject(info, true);

    case B_FLUSH_DRIVE_CACHE:
        return synchronize_cache(info);

    default:
        return sSCSIPeripheral->ioctl(handle->scsi_periph_handle, op,
                                      buffer, length);
    }
}