mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
Don't panic when tasting a disk with sectorsize=0
This can sometimes happen with broken HDDs. MFC after: 2 weeks Sponsored by: Axcient Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D37313
This commit is contained in:
parent
817f1f3064
commit
05d0f4308c
|
@ -394,6 +394,10 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
|
||||||
if (pp->acw > 0)
|
if (pp->acw > 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
|
/* Skip broken disks that don't set their sector size */
|
||||||
|
if (pp->sectorsize == 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
if (strcmp(pp->geom->class->name, mp->name) == 0)
|
if (strcmp(pp->geom->class->name, mp->name) == 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,11 @@ g_label_ext2fs_taste(struct g_consumer *cp, char *label, size_t size)
|
||||||
pp = cp->provider;
|
pp = cp->provider;
|
||||||
label[0] = '\0';
|
label[0] = '\0';
|
||||||
|
|
||||||
if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0)
|
KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||||
return;
|
|
||||||
if (pp->sectorsize < sizeof(*fs))
|
if (pp->sectorsize < sizeof(*fs))
|
||||||
return;
|
return;
|
||||||
|
if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
fs = g_read_data(cp, EXT2FS_SB_OFFSET, pp->sectorsize, NULL);
|
fs = g_read_data(cp, EXT2FS_SB_OFFSET, pp->sectorsize, NULL);
|
||||||
if (fs == NULL)
|
if (fs == NULL)
|
||||||
|
|
|
@ -52,10 +52,11 @@ g_label_iso9660_taste(struct g_consumer *cp, char *label, size_t size)
|
||||||
pp = cp->provider;
|
pp = cp->provider;
|
||||||
label[0] = '\0';
|
label[0] = '\0';
|
||||||
|
|
||||||
if ((ISO9660_OFFSET % pp->sectorsize) != 0)
|
KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||||
return;
|
|
||||||
if (pp->sectorsize < 0x28 + VOLUME_LEN)
|
if (pp->sectorsize < 0x28 + VOLUME_LEN)
|
||||||
return;
|
return;
|
||||||
|
if ((ISO9660_OFFSET % pp->sectorsize) != 0)
|
||||||
|
return;
|
||||||
sector = g_read_data(cp, ISO9660_OFFSET, pp->sectorsize, NULL);
|
sector = g_read_data(cp, ISO9660_OFFSET, pp->sectorsize, NULL);
|
||||||
if (sector == NULL)
|
if (sector == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -59,10 +59,11 @@ g_label_reiserfs_read_super(struct g_consumer *cp, off_t offset)
|
||||||
|
|
||||||
secsize = cp->provider->sectorsize;
|
secsize = cp->provider->sectorsize;
|
||||||
|
|
||||||
if ((offset % secsize) != 0)
|
KASSERT(secsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||||
return (NULL);
|
|
||||||
if (secsize < sizeof(*fs))
|
if (secsize < sizeof(*fs))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
if ((offset % secsize) != 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
fs = g_read_data(cp, offset, secsize, NULL);
|
fs = g_read_data(cp, offset, secsize, NULL);
|
||||||
if (fs == NULL)
|
if (fs == NULL)
|
||||||
|
|
|
@ -139,6 +139,7 @@ g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int wh
|
||||||
label[0] = '\0';
|
label[0] = '\0';
|
||||||
|
|
||||||
fs = NULL;
|
fs = NULL;
|
||||||
|
KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||||
if (SBLOCKSIZE % pp->sectorsize != 0 || ffs_sbget(cp, &fs, UFS_STDSB,
|
if (SBLOCKSIZE % pp->sectorsize != 0 || ffs_sbget(cp, &fs, UFS_STDSB,
|
||||||
UFS_NOHASHFAIL | UFS_NOCSUM | UFS_NOMSG, M_GEOM, g_use_g_read_data)
|
UFS_NOHASHFAIL | UFS_NOCSUM | UFS_NOMSG, M_GEOM, g_use_g_read_data)
|
||||||
!= 0) {
|
!= 0) {
|
||||||
|
|
Loading…
Reference in a new issue