Date: Tue, 7 Apr 2009 19:18:02 +0000 (UTC) From: Ivan Voras <ivoras@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r190816 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb geom/label Message-ID: <200904071918.n37JI2rZ022488@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ivoras Date: Tue Apr 7 19:18:02 2009 New Revision: 190816 URL: http://svn.freebsd.org/changeset/base/190816 Log: Merge r190423: introduce a new UFS-based label called "ufsid" that can be used to reference UFS-carrying devices by the unique file system id. An example of this new label is: /dev/ufsid/48e69c8b5c8e1b43. The benefit of using GEOM labels in general is to avoid problems of device renaming when shifting drives or controllers. Reviewed by: pjd Approved by: re (kib) Approved by: gnn (mentor) (original) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/geom/label/g_label.c stable/7/sys/geom/label/g_label.h stable/7/sys/geom/label/g_label_ufs.c Modified: stable/7/sys/geom/label/g_label.c ============================================================================== --- stable/7/sys/geom/label/g_label.c Tue Apr 7 19:06:51 2009 (r190815) +++ stable/7/sys/geom/label/g_label.c Tue Apr 7 19:18:02 2009 (r190816) @@ -77,7 +77,8 @@ struct g_class g_label_class = { * 6. Add your file system to manual page sbin/geom/class/label/glabel.8. */ const struct g_label_desc *g_labels[] = { - &g_label_ufs, + &g_label_ufs_id, + &g_label_ufs_volume, &g_label_iso9660, &g_label_msdosfs, &g_label_ext2fs, Modified: stable/7/sys/geom/label/g_label.h ============================================================================== --- stable/7/sys/geom/label/g_label.h Tue Apr 7 19:06:51 2009 (r190815) +++ stable/7/sys/geom/label/g_label.h Tue Apr 7 19:18:02 2009 (r190816) @@ -64,7 +64,8 @@ struct g_label_desc { }; /* Supported labels. */ -extern const struct g_label_desc g_label_ufs; +extern const struct g_label_desc g_label_ufs_id; +extern const struct g_label_desc g_label_ufs_volume; extern const struct g_label_desc g_label_iso9660; extern const struct g_label_desc g_label_msdosfs; extern const struct g_label_desc g_label_ext2fs; Modified: stable/7/sys/geom/label/g_label_ufs.c ============================================================================== --- stable/7/sys/geom/label/g_label_ufs.c Tue Apr 7 19:06:51 2009 (r190815) +++ stable/7/sys/geom/label/g_label_ufs.c Tue Apr 7 19:18:02 2009 (r190816) @@ -39,12 +39,16 @@ __FBSDID("$FreeBSD$"); #include <geom/geom.h> #include <geom/label/g_label.h> -#define G_LABEL_UFS_DIR "ufs" +#define G_LABEL_UFS_VOLUME_DIR "ufs" +#define G_LABEL_UFS_ID_DIR "ufsid" + +#define G_LABEL_UFS_VOLUME 0 +#define G_LABEL_UFS_ID 1 static const int superblocks[] = SBLOCKSEARCH; static void -g_label_ufs_taste(struct g_consumer *cp, char *label, size_t size) +g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int what) { struct g_provider *pp; int sb, superblock; @@ -96,18 +100,50 @@ g_label_ufs_taste(struct g_consumer *cp, } G_LABEL_DEBUG(1, "%s file system detected on %s.", fs->fs_magic == FS_UFS1_MAGIC ? "UFS1" : "UFS2", pp->name); - /* Check for volume label */ - if (fs->fs_volname[0] == '\0') { - g_free(fs); - continue; + switch (what) { + case G_LABEL_UFS_VOLUME: + /* Check for volume label */ + if (fs->fs_volname[0] == '\0') { + g_free(fs); + continue; + } + strlcpy(label, fs->fs_volname, size); + break; + case G_LABEL_UFS_ID: + if (fs->fs_id[0] == 0 && fs->fs_id[1] == 0) { + g_free(fs); + continue; + } + snprintf(label, size, "%08x%08x", fs->fs_id[0], + fs->fs_id[1]); + break; } - strlcpy(label, fs->fs_volname, size); g_free(fs); break; } } -const struct g_label_desc g_label_ufs = { - .ld_taste = g_label_ufs_taste, - .ld_dir = G_LABEL_UFS_DIR +static void +g_label_ufs_volume_taste(struct g_consumer *cp, char *label, size_t size) +{ + + g_label_ufs_taste_common(cp, label, size, G_LABEL_UFS_VOLUME); +} + +static void +g_label_ufs_id_taste(struct g_consumer *cp, char *label, size_t size) +{ + + g_label_ufs_taste_common(cp, label, size, G_LABEL_UFS_ID); +} + + +const struct g_label_desc g_label_ufs_volume = { + .ld_taste = g_label_ufs_volume_taste, + .ld_dir = G_LABEL_UFS_VOLUME_DIR +}; + +const struct g_label_desc g_label_ufs_id = { + .ld_taste = g_label_ufs_id_taste, + .ld_dir = G_LABEL_UFS_ID_DIR };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904071918.n37JI2rZ022488>