mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +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:
parent
2fa72ea7d4
commit
06a519dfc9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72094
@ -1542,6 +1542,12 @@ ata_get_lun(u_int32_t *map)
|
|||||||
return lun;
|
return lun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ata_test_lun(u_int32_t *map, int lun)
|
||||||
|
{
|
||||||
|
return (*map & ~(1 << lun));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ata_free_lun(u_int32_t *map, int lun)
|
ata_free_lun(u_int32_t *map, int lun)
|
||||||
{
|
{
|
||||||
|
@ -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_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_printf(struct ata_softc *, int, const char *, ...) __printflike(3, 4);
|
||||||
int ata_get_lun(u_int32_t *);
|
int ata_get_lun(u_int32_t *);
|
||||||
|
int ata_test_lun(u_int32_t *, int);
|
||||||
void ata_free_lun(u_int32_t *, int);
|
void ata_free_lun(u_int32_t *, int);
|
||||||
char *ata_mode2str(int);
|
char *ata_mode2str(int);
|
||||||
int ata_pio2mode(int);
|
int ata_pio2mode(int);
|
||||||
|
@ -279,7 +279,8 @@ acd_clone(void *arg, char *name, int namelen, dev_t *dev)
|
|||||||
int unit, track = 0;
|
int unit, track = 0;
|
||||||
|
|
||||||
if (*dev != NODEV ||
|
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;
|
return;
|
||||||
while (isdigit(*namep)) {
|
while (isdigit(*namep)) {
|
||||||
track *= 10;
|
track *= 10;
|
||||||
@ -287,7 +288,7 @@ acd_clone(void *arg, char *name, int namelen, dev_t *dev)
|
|||||||
}
|
}
|
||||||
if (*namep)
|
if (*namep)
|
||||||
return;
|
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
|
static void
|
||||||
@ -373,8 +374,11 @@ acd_describe(struct acd_softc *cdp)
|
|||||||
if (cdp->cap.write_dvdram) {
|
if (cdp->cap.write_dvdram) {
|
||||||
printf("%s DVD-RAM", comma ? "," : ""); comma = 1;
|
printf("%s DVD-RAM", comma ? "," : ""); comma = 1;
|
||||||
}
|
}
|
||||||
if (cdp->cap.test_write)
|
if (cdp->cap.test_write) {
|
||||||
printf("%s test write", comma ? "," : "");
|
printf("%s test write", comma ? "," : ""); comma = 1;
|
||||||
|
}
|
||||||
|
if (cdp->cap.burnproof)
|
||||||
|
printf("%s burnproof", comma ? "," : "");
|
||||||
}
|
}
|
||||||
if (cdp->cap.audio_play) {
|
if (cdp->cap.audio_play) {
|
||||||
printf("\nacd%d: Audio: ", cdp->lun);
|
printf("\nacd%d: Audio: ", cdp->lun);
|
||||||
@ -505,10 +509,10 @@ static int
|
|||||||
acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
acdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||||
{
|
{
|
||||||
struct acd_softc *cdp;
|
struct acd_softc *cdp;
|
||||||
int track = (dev->si_udev & 0x00ff0000) >> 16;
|
int track = (dev->si_udev & 0x001f0000) >> 16;
|
||||||
|
|
||||||
if (track) {
|
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)
|
if (track <= ((struct acd_softc*)(dev1->si_drv1))->toc.hdr.ending_track)
|
||||||
dev->si_drv1 = dev1->si_drv1;
|
dev->si_drv1 = dev1->si_drv1;
|
||||||
|
Loading…
Reference in New Issue
Block a user