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(); }
/* * Scan SCSI busses to detect any devices * that we want to supply to the Amgia. * * Based on code from cdrecord */ static int scanscsi (SCSI *scgp) { int bus; int tgt; int lun = 0; int initiator; int have_tgt; int n; scgp->silent++; for (bus = 0; bus < 16; bus++) { scg_settarget (scgp, bus, 0, 0); if (!scg_havebus (scgp, bus)) continue; initiator = scg_initiator_id (scgp); write_log ("scsibus%d:\n", bus); for (tgt = 0; tgt < 16; tgt++) { n = bus * 100 + tgt; scg_settarget (scgp, bus, tgt, lun); have_tgt = unit_ready (scgp) || scgp->scmd->error != SCG_FATAL; if (!have_tgt && tgt > 7) { if (scgp->scmd->ux_errno == EINVAL) break; continue; } write_log (" %d,%d,%d %d ", bus, tgt, lun, n); if (tgt == initiator) { write_log ("HOST ADAPTOR\n"); continue; } if (!have_tgt) { /* Hack: fd -> -2 means no access */ write_log ( "%c\n", scgp->fd == -2 ? '?':'*'); continue; } if ((scgp->scmd->error < SCG_FATAL) || (scgp->scmd->scb.chk && scgp->scmd->sense_count > 0)) { struct scsi_inquiry *inq = scgp->inq; inquiry (scgp, inq, sizeof (*inq)); print_product (inq); /* Just CD/DVD drives for now */ if (inq->type == INQ_ROMD) add_drive (scgp); } write_log ("\n"); } } scgp->silent--; return 0; }