mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-30 08:19:09 +00:00
For removable devices without media we set a zero mediasize but a non-zero
sectorsize in order to avoid a lot of checks around various divisions etc. Enforce the sectorsize being > 0 with a KASSERT on successful open. Fix scsi_cd.c to return 2k sectors when no media inserted.
This commit is contained in:
parent
f46a6aac29
commit
5ae652c0ed
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134824
@ -2723,7 +2723,7 @@ cdcheckmedia(struct cam_periph *periph)
|
||||
|
||||
cdprevent(periph, PR_PREVENT);
|
||||
softc->disk->d_maxsize = DFLTPHYS;
|
||||
softc->disk->d_sectorsize = 0;
|
||||
softc->disk->d_sectorsize = 2048;
|
||||
softc->disk->d_mediasize = 0;
|
||||
|
||||
/*
|
||||
|
@ -706,6 +706,9 @@ g_access(struct g_consumer *cp, int dcr, int dcw, int dce)
|
||||
cp->acr += dcr;
|
||||
cp->acw += dcw;
|
||||
cp->ace += dce;
|
||||
if (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)
|
||||
KASSERT(pp->sectorsize > 0,
|
||||
("Provider %s lacks sectorsize", pp->name));
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -138,3 +138,13 @@ application | | | | X | X |
|
||||
geom_slice.h is special in that it documents a "library" for implementing
|
||||
a specific kind of class, and consequently does not appear in the above
|
||||
matrix.
|
||||
-----------------------------------------------------------------------
|
||||
Removable media.
|
||||
|
||||
In general, the theory is that a drive creates the provider when it has
|
||||
a media and destroys it when the media disappears.
|
||||
|
||||
In a more realistic world, we will allow a provider to be opened medialess
|
||||
(set any sectorsize and a mediasize==0) in order to allow operations like
|
||||
open/close tray etc.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user