geom_label: Remove an old sysinstall(8) workaround

We removed sysinstall(8) back in 2011, so this workaround should be long
since unnecessary. This workaround can end up breaking cases that are
hit in the real world, such as dd'ing a small pre-built disk image to a
large partition that you intend to grow on first boot and uses a UFS
disk label for / in its /etc/fstab (as the only reliable thing a raw UFS
image can reference).

Reviewed by:	imp, mckusick
Differential Revision:	https://reviews.freebsd.org/D30825
This commit is contained in:
Jessica Clarke 2021-07-05 16:15:32 +01:00
parent 55c57a7811
commit af433832f7

View File

@ -49,19 +49,8 @@ __FBSDID("$FreeBSD$");
#define G_LABEL_UFS_ID 1
/*
* G_LABEL_UFS_CMP returns true if difference between provider mediasize
* and filesystem size is less than G_LABEL_UFS_MAXDIFF sectors
*/
#define G_LABEL_UFS_CMP(prov, fsys, size) \
( abs( ((fsys)->size) - ( (prov)->mediasize / (fsys)->fs_fsize )) \
< G_LABEL_UFS_MAXDIFF )
#define G_LABEL_UFS_MAXDIFF 0x100
/*
* Try to find a superblock on the provider. If successful, then
* check that the size in the superblock corresponds to the size
* of the underlying provider. Finally, look for a volume label
* and create an appropriate provider based on that.
* Try to find a superblock on the provider. If successful, look for a volume
* label and create an appropriate provider based on that.
*/
static void
g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int what)
@ -81,24 +70,10 @@ g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int wh
return;
}
/*
* Check for magic. We also need to check if file system size
* is almost equal to providers size, because sysinstall(8)
* used to bogusly put first partition at offset 0
* instead of 16, and glabel/ufs would find file system on slice
* instead of partition.
*
* In addition, media size can be a bit bigger than file system
* size. For instance, mkuzip can append bytes to align data
* to large sector size (it improves compression rates).
*/
if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_fsize > 0 &&
( G_LABEL_UFS_CMP(pp, fs, fs_old_size)
|| G_LABEL_UFS_CMP(pp, fs, fs_providersize))) {
/* Check for magic. */
if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_fsize > 0) {
/* Valid UFS1. */
} else if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_fsize > 0 &&
( G_LABEL_UFS_CMP(pp, fs, fs_size)
|| G_LABEL_UFS_CMP(pp, fs, fs_providersize))) {
} else if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_fsize > 0) {
/* Valid UFS2. */
} else {
goto out;