int writetao(struct track_head *thp) { u_char modebuf[70], bdlen; struct track_info *tr; int r, track = 0; if ((r = mode_sense_write(modebuf)) != SCCMD_OK) { warnx("mode sense failed: %d", r); return (r); } bdlen = modebuf[7]; modebuf[2+8+bdlen] |= 0x40; /* Buffer Underrun Free Enable */ modebuf[2+8+bdlen] |= 0x01; /* change write type to TAO */ SLIST_FOREACH(tr, thp, track_list) { track++; switch (tr->type) { case 'd': modebuf[3+8+bdlen] = 0x04; /* track mode = data */ modebuf[4+8+bdlen] = 0x08; /* 2048 block track mode */ modebuf[8+8+bdlen] = 0x00; /* turn off XA */ break; case 'a': modebuf[3+8+bdlen] = 0x00; /* track mode = audio */ modebuf[4+8+bdlen] = 0x00; /* 2352 block track mode */ modebuf[8+8+bdlen] = 0x00; /* turn off XA */ break; default: warn("impossible tracktype detected"); break; } while (unit_ready() != SCCMD_OK) continue; if ((r = mode_select_write(modebuf)) != SCCMD_OK) { warnx("mode select failed: %d", r); return (r); } set_speed(tr->speed); writetrack(tr, track); synchronize_cache(); }
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); } }