1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

Fix the clone functionality in atapi-cd, it didn't work for

devs other than the first, and allowed to clone a nonexistent
device..
This commit is contained in:
Søren Schmidt 2001-02-06 12:41:53 +00:00
parent 2fa72ea7d4
commit 06a519dfc9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72094
3 changed files with 17 additions and 6 deletions

View File

@ -1542,6 +1542,12 @@ ata_get_lun(u_int32_t *map)
return lun;
}
int
ata_test_lun(u_int32_t *map, int lun)
{
return (*map & ~(1 << lun));
}
void
ata_free_lun(u_int32_t *map, int lun)
{

View File

@ -345,6 +345,7 @@ int ata_wait(struct ata_softc *, int, u_int8_t);
int ata_command(struct ata_softc *, int, u_int8_t, u_int16_t, u_int8_t, u_int8_t, u_int8_t, u_int8_t, int);
int ata_printf(struct ata_softc *, int, const char *, ...) __printflike(3, 4);
int ata_get_lun(u_int32_t *);
int ata_test_lun(u_int32_t *, int);
void ata_free_lun(u_int32_t *, int);
char *ata_mode2str(int);
int ata_pio2mode(int);

View File

@ -279,7 +279,8 @@ acd_clone(void *arg, char *name, int namelen, dev_t *dev)
int unit, track = 0;
if (*dev != NODEV ||
!dev_stdclone(name, &namep, "acd", &unit) || *namep++ != 't')
!dev_stdclone(name, &namep, "acd", &unit) || *namep++ != 't' ||
!ata_test_lun(&acd_lun_map, unit))
return;
while (isdigit(*namep)) {
track *= 10;
@ -287,7 +288,7 @@ acd_clone(void *arg, char *name, int namelen, dev_t *dev)
}
if (*namep)
return;
*dev = make_dev(&acd_cdevsw, unit | (track << 16), 0, 0, 0644, name, NULL);
*dev = make_dev(&acd_cdevsw, (unit<<3)|(track<<16), 0, 0, 0644, name, NULL);
}
static void
@ -373,8 +374,11 @@ acd_describe(struct acd_softc *cdp)
if (cdp->cap.write_dvdram) {
printf("%s DVD-RAM", comma ? "," : ""); comma = 1;
}
if (cdp->cap.test_write)
printf("%s test write", comma ? "," : "");
if (cdp->cap.test_write) {
printf("%s test write", comma ? "," : ""); comma = 1;
}
if (cdp->cap.burnproof)
printf("%s burnproof", comma ? "," : "");
}
if (cdp->cap.audio_play) {
printf("\nacd%d: Audio: ", cdp->lun);
@ -505,10 +509,10 @@ static int
acdopen(dev_t dev, int flags, int fmt, struct proc *p)
{
struct acd_softc *cdp;
int track = (dev->si_udev & 0x00ff0000) >> 16;
int track = (dev->si_udev & 0x001f0000) >> 16;
if (track) {
dev_t dev1 = makedev(major(dev), (dev->si_udev & 0xff0000ff));
dev_t dev1 = makedev(major(dev), (dev->si_udev & 0xffe000ff));
if (track <= ((struct acd_softc*)(dev1->si_drv1))->toc.hdr.ending_track)
dev->si_drv1 = dev1->si_drv1;