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)
|
||||
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)
|
||||
return (NULL);
|
||||
|
||||
|
@ -62,10 +62,11 @@ g_label_ext2fs_taste(struct g_consumer *cp, char *label, size_t size)
|
||||
pp = cp->provider;
|
||||
label[0] = '\0';
|
||||
|
||||
if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0)
|
||||
return;
|
||||
KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||
if (pp->sectorsize < sizeof(*fs))
|
||||
return;
|
||||
if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0)
|
||||
return;
|
||||
|
||||
fs = g_read_data(cp, EXT2FS_SB_OFFSET, pp->sectorsize, NULL);
|
||||
if (fs == NULL)
|
||||
|
@ -52,10 +52,11 @@ g_label_iso9660_taste(struct g_consumer *cp, char *label, size_t size)
|
||||
pp = cp->provider;
|
||||
label[0] = '\0';
|
||||
|
||||
if ((ISO9660_OFFSET % pp->sectorsize) != 0)
|
||||
return;
|
||||
KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||
if (pp->sectorsize < 0x28 + VOLUME_LEN)
|
||||
return;
|
||||
if ((ISO9660_OFFSET % pp->sectorsize) != 0)
|
||||
return;
|
||||
sector = g_read_data(cp, ISO9660_OFFSET, pp->sectorsize, NULL);
|
||||
if (sector == NULL)
|
||||
return;
|
||||
|
@ -59,10 +59,11 @@ g_label_reiserfs_read_super(struct g_consumer *cp, off_t offset)
|
||||
|
||||
secsize = cp->provider->sectorsize;
|
||||
|
||||
if ((offset % secsize) != 0)
|
||||
return (NULL);
|
||||
KASSERT(secsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||
if (secsize < sizeof(*fs))
|
||||
return (NULL);
|
||||
if ((offset % secsize) != 0)
|
||||
return (NULL);
|
||||
|
||||
fs = g_read_data(cp, offset, secsize, 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';
|
||||
|
||||
fs = NULL;
|
||||
KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize"));
|
||||
if (SBLOCKSIZE % pp->sectorsize != 0 || ffs_sbget(cp, &fs, UFS_STDSB,
|
||||
UFS_NOHASHFAIL | UFS_NOCSUM | UFS_NOMSG, M_GEOM, g_use_g_read_data)
|
||||
!= 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user