Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/label/g_label_ufs.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <geom/geom.h> | #include <geom/geom.h> | ||||
#include <geom/geom_dbg.h> | #include <geom/geom_dbg.h> | ||||
#include <geom/label/g_label.h> | #include <geom/label/g_label.h> | ||||
#define G_LABEL_UFS_VOLUME 0 | #define G_LABEL_UFS_VOLUME 0 | ||||
#define G_LABEL_UFS_ID 1 | #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 | |||||
/* | |||||
* For MBR and EBR we 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). | |||||
*/ | |||||
static bool | |||||
g_label_ufs_ignore_possible_bsdlabel_slice(struct g_provider *pp, | |||||
struct fs *fs) | |||||
{ | |||||
const char *provider_name = pp->geom->class->name; | |||||
if (strcmp(provider_name, "MBR") == 0 || | |||||
strcmp(provider_name, "EBR") == 0) | |||||
cy: Testing, the above strcmp for MBR and EBR don't work. BSD and BSD64 don't work either.
Without… | |||||
Done Inline ActionsHm, if you just printf the providers coming through what do you see? jrtc27: Hm, if you just printf the providers coming through what do you see? | |||||
return (!G_LABEL_UFS_CMP(pp, fs, fs_old_size) && | |||||
Not Done Inline ActionsShould this be the 64-bit fs_size? cy: Should this be the 64-bit fs_size? | |||||
Done Inline ActionsAh, yes, it should be for UFS2, I failed to spot that difference between the two in the original code jrtc27: Ah, yes, it should be for UFS2, I failed to spot that difference between the two in the… | |||||
!G_LABEL_UFS_CMP(pp, fs, fs_providersize)); | |||||
return (true); | |||||
} | |||||
/* | |||||
* Try to find a superblock on the provider. If successful, look for a volume | * Try to find a superblock on the provider. If successful, look for a volume | ||||
* label and create an appropriate provider based on that. | * label and create an appropriate provider based on that. | ||||
*/ | */ | ||||
static void | static void | ||||
g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int what) | g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int what) | ||||
{ | { | ||||
struct g_provider *pp; | struct g_provider *pp; | ||||
struct fs *fs; | struct fs *fs; | ||||
Show All 13 Lines | g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int what) | ||||
/* Check for magic. */ | /* Check for magic. */ | ||||
if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_fsize > 0) { | if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_fsize > 0) { | ||||
/* Valid UFS1. */ | /* Valid UFS1. */ | ||||
} else if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_fsize > 0) { | } else if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_fsize > 0) { | ||||
/* Valid UFS2. */ | /* Valid UFS2. */ | ||||
} else { | } else { | ||||
goto out; | goto out; | ||||
} | } | ||||
/* Check if this should be ignored for compatibility. */ | |||||
if (g_label_ufs_ignore_possible_bsdlabel_slice(pp, fs)) | |||||
goto out; | |||||
G_LABEL_DEBUG(1, "%s file system detected on %s.", | G_LABEL_DEBUG(1, "%s file system detected on %s.", | ||||
fs->fs_magic == FS_UFS1_MAGIC ? "UFS1" : "UFS2", pp->name); | fs->fs_magic == FS_UFS1_MAGIC ? "UFS1" : "UFS2", pp->name); | ||||
switch (what) { | switch (what) { | ||||
case G_LABEL_UFS_VOLUME: | case G_LABEL_UFS_VOLUME: | ||||
/* Check for volume label */ | /* Check for volume label */ | ||||
if (fs->fs_volname[0] != '\0') | if (fs->fs_volname[0] != '\0') | ||||
strlcpy(label, fs->fs_volname, size); | strlcpy(label, fs->fs_volname, size); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
Testing, the above strcmp for MBR and EBR don't work. BSD and BSD64 don't work either.
Without the above tests, there is no regression.