From owner-svn-src-stable-7@FreeBSD.ORG Tue Apr 7 19:18:03 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24A901065673; Tue, 7 Apr 2009 19:18:03 +0000 (UTC) (envelope-from ivoras@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1094A8FC1B; Tue, 7 Apr 2009 19:18:03 +0000 (UTC) (envelope-from ivoras@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n37JI2Xc022491; Tue, 7 Apr 2009 19:18:02 GMT (envelope-from ivoras@svn.freebsd.org) Received: (from ivoras@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n37JI2rZ022488; Tue, 7 Apr 2009 19:18:02 GMT (envelope-from ivoras@svn.freebsd.org) Message-Id: <200904071918.n37JI2rZ022488@svn.freebsd.org> From: Ivan Voras Date: Tue, 7 Apr 2009 19:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190816 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb geom/label X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2009 19:18:03 -0000 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 #include -#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 };