From owner-svn-src-head@FreeBSD.ORG Wed Mar 25 20:38:57 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F6DD1065670; Wed, 25 Mar 2009 20:38:57 +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 6D45F8FC2E; Wed, 25 Mar 2009 20:38:57 +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 n2PKcv82087618; Wed, 25 Mar 2009 20:38:57 GMT (envelope-from ivoras@svn.freebsd.org) Received: (from ivoras@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2PKcvee087615; Wed, 25 Mar 2009 20:38:57 GMT (envelope-from ivoras@svn.freebsd.org) Message-Id: <200903252038.n2PKcvee087615@svn.freebsd.org> From: Ivan Voras Date: Wed, 25 Mar 2009 20:38:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190423 - head/sys/geom/label X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2009 20:38:57 -0000 Author: ivoras Date: Wed Mar 25 20:38:57 2009 New Revision: 190423 URL: http://svn.freebsd.org/changeset/base/190423 Log: Create GEOM labels from UFS IDs, e.g. /dev/ufsid/49c97b1faa2adc43. UFS IDs are always present and can be used to identify file systems (useful if hardware devices move often). Actually-by: pjd Approved by: gnn (mentor) Modified: head/sys/geom/label/g_label.c head/sys/geom/label/g_label.h head/sys/geom/label/g_label_ufs.c Modified: head/sys/geom/label/g_label.c ============================================================================== --- head/sys/geom/label/g_label.c Wed Mar 25 20:15:48 2009 (r190422) +++ head/sys/geom/label/g_label.c Wed Mar 25 20:38:57 2009 (r190423) @@ -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: head/sys/geom/label/g_label.h ============================================================================== --- head/sys/geom/label/g_label.h Wed Mar 25 20:15:48 2009 (r190422) +++ head/sys/geom/label/g_label.h Wed Mar 25 20:38:57 2009 (r190423) @@ -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: head/sys/geom/label/g_label_ufs.c ============================================================================== --- head/sys/geom/label/g_label_ufs.c Wed Mar 25 20:15:48 2009 (r190422) +++ head/sys/geom/label/g_label_ufs.c Wed Mar 25 20:38:57 2009 (r190423) @@ -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 };