[Midnightbsd-cvs] src [9972] trunk/sys/geom/label: sync with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat May 26 11:26:33 EDT 2018
Revision: 9972
http://svnweb.midnightbsd.org/src/?rev=9972
Author: laffer1
Date: 2018-05-26 11:26:32 -0400 (Sat, 26 May 2018)
Log Message:
-----------
sync with freebsd
Modified Paths:
--------------
trunk/sys/geom/label/g_label.c
trunk/sys/geom/label/g_label.h
trunk/sys/geom/label/g_label_ext2fs.c
trunk/sys/geom/label/g_label_gpt.c
trunk/sys/geom/label/g_label_iso9660.c
trunk/sys/geom/label/g_label_msdosfs.c
trunk/sys/geom/label/g_label_msdosfs.h
trunk/sys/geom/label/g_label_ntfs.c
trunk/sys/geom/label/g_label_reiserfs.c
trunk/sys/geom/label/g_label_ufs.c
Added Paths:
-----------
trunk/sys/geom/label/g_label_disk_ident.c
Modified: trunk/sys/geom/label/g_label.c
===================================================================
--- trunk/sys/geom/label/g_label.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/label/g_label.c,v 1.21.2.5 2011/05/18 16:28:28 ae Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label.c 286193 2015-08-02 10:08:57Z trasz $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -35,8 +35,11 @@
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/bio.h>
+#include <sys/ctype.h>
#include <sys/malloc.h>
#include <sys/libkern.h>
+#include <sys/sbuf.h>
+#include <sys/stddef.h>
#include <sys/sysctl.h>
#include <geom/geom.h>
#include <geom/geom_slice.h>
@@ -88,10 +91,25 @@
&g_label_ntfs,
&g_label_gpt,
&g_label_gpt_uuid,
+ &g_label_disk_ident,
NULL
};
+void
+g_label_rtrim(char *label, size_t size)
+{
+ ptrdiff_t i;
+ for (i = size - 1; i >= 0; i--) {
+ if (label[i] == '\0')
+ continue;
+ else if (label[i] == ' ')
+ label[i] = '\0';
+ else
+ break;
+ }
+}
+
static int
g_label_destroy_geom(struct gctl_req *req __unused, struct g_class *mp,
struct g_geom *gp __unused)
@@ -122,6 +140,17 @@
g_slice_spoiled(cp);
}
+static void
+g_label_resize(struct g_consumer *cp)
+{
+
+ G_LABEL_DEBUG(1, "Label %s resized.",
+ LIST_FIRST(&cp->geom->provider)->name);
+
+ g_slice_config(cp->geom, 0, G_SLICE_CONFIG_FORCE, (off_t)0,
+ cp->provider->mediasize, cp->provider->sectorsize, "notused");
+}
+
static int
g_label_is_name_ok(const char *label)
{
@@ -139,6 +168,26 @@
return (1);
}
+static void
+g_label_mangle_name(char *label, size_t size)
+{
+ struct sbuf *sb;
+ const u_char *c;
+
+ sb = sbuf_new(NULL, NULL, size, SBUF_FIXEDLEN);
+ for (c = label; *c != '\0'; c++) {
+ if (!isprint(*c) || isspace(*c) || *c =='"' || *c == '%')
+ sbuf_printf(sb, "%%%02X", *c);
+ else
+ sbuf_putc(sb, *c);
+ }
+ if (sbuf_finish(sb) != 0)
+ label[0] = '\0';
+ else
+ strlcpy(label, sbuf_data(sb), size);
+ sbuf_delete(sb);
+}
+
static struct g_geom *
g_label_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
const char *label, const char *dir, off_t mediasize)
@@ -186,6 +235,7 @@
}
gp->orphan = g_label_orphan;
gp->spoiled = g_label_spoiled;
+ gp->resize = g_label_resize;
g_access(cp, -1, 0, 0);
g_slice_config(gp, 0, G_SLICE_CONFIG_SET, (off_t)0, mediasize,
pp->sectorsize, "%s", name);
@@ -318,12 +368,13 @@
pp->mediasize - pp->sectorsize);
} while (0);
for (i = 0; g_labels[i] != NULL; i++) {
- char label[64];
+ char label[128];
if (g_labels[i]->ld_enabled == 0)
continue;
g_topology_unlock();
g_labels[i]->ld_taste(cp, label, sizeof(label));
+ g_label_mangle_name(label, sizeof(label));
g_topology_lock();
if (label[0] == '\0')
continue;
Modified: trunk/sys/geom/label/g_label.h
===================================================================
--- trunk/sys/geom/label/g_label.h 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label.h 2018-05-26 15:26:32 UTC (rev 9972)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/geom/label/g_label.h,v 1.5 2011/12/10 15:46:15 laffer1 Exp $ */
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
* All rights reserved.
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/geom/label/g_label.h,v 1.7.2.1 2009/04/07 19:18:02 ivoras Exp $
+ * $FreeBSD: stable/10/sys/geom/label/g_label.h 286193 2015-08-02 10:08:57Z trasz $
*/
#ifndef _G_LABEL_H_
@@ -88,6 +88,9 @@
extern struct g_label_desc g_label_ntfs;
extern struct g_label_desc g_label_gpt;
extern struct g_label_desc g_label_gpt_uuid;
+extern struct g_label_desc g_label_disk_ident;
+
+extern void g_label_rtrim(char *label, size_t size);
#endif /* _KERNEL */
struct g_label_metadata {
Added: trunk/sys/geom/label/g_label_disk_ident.c
===================================================================
--- trunk/sys/geom/label/g_label_disk_ident.c (rev 0)
+++ trunk/sys/geom/label/g_label_disk_ident.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -0,0 +1,89 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2012 Ivan Voras <ivoras at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_disk_ident.c 249571 2013-04-16 22:42:40Z ivoras $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+
+#include <geom/geom.h>
+#include <geom/geom_disk.h>
+#include <geom/label/g_label.h>
+#include <geom/multipath/g_multipath.h>
+
+
+#define G_LABEL_DISK_IDENT_DIR "diskid"
+
+static char* classes_pass[] = { G_DISK_CLASS_NAME, G_MULTIPATH_CLASS_NAME,
+ NULL };
+
+static void
+g_label_disk_ident_taste(struct g_consumer *cp, char *label, size_t size)
+{
+ struct g_class *cls;
+ char ident[100];
+ int ident_len, found, i;
+
+ g_topology_assert_not();
+ label[0] = '\0';
+
+ cls = cp->provider->geom->class;
+
+ /*
+ * Get the GEOM::ident string, and construct a label in the format
+ * "CLASS_NAME-ident"
+ */
+ ident_len = sizeof(ident);
+ if (g_io_getattr("GEOM::ident", cp, &ident_len, ident) == 0) {
+ if (ident_len == 0 || ident[0] == '\0')
+ return;
+ for (i = 0, found = 0; classes_pass[i] != NULL; i++)
+ if (strcmp(classes_pass[i], cls->name) == 0) {
+ found = 1;
+ break;
+ }
+ if (!found)
+ return;
+ /*
+ * We can safely ignore the result of snprintf(): the label
+ * will simply be truncated, which at most is only annoying.
+ */
+ (void)snprintf(label, size, "%s-%s", cls->name, ident);
+ }
+}
+
+struct g_label_desc g_label_disk_ident = {
+ .ld_taste = g_label_disk_ident_taste,
+ .ld_dir = G_LABEL_DISK_IDENT_DIR,
+ .ld_enabled = 1
+};
+
+G_LABEL_INIT(disk_ident, g_label_disk_ident, "Create device nodes for drives "
+ "which export a disk identification string");
Property changes on: trunk/sys/geom/label/g_label_disk_ident.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/geom/label/g_label_ext2fs.c
===================================================================
--- trunk/sys/geom/label/g_label_ext2fs.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_ext2fs.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/geom/label/g_label_ext2fs.c,v 1.3 2008/12/03 00:25:48 laffer1 Exp $ */
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 Stanislav Sedov
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/label/g_label_ext2fs.c,v 1.2 2005/08/23 18:55:38 pjd Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_ext2fs.c 219400 2011-03-08 17:00:31Z sobomax $");
#include <sys/param.h>
#include <sys/systm.h>
Modified: trunk/sys/geom/label/g_label_gpt.c
===================================================================
--- trunk/sys/geom/label/g_label_gpt.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_gpt.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Marius Nuennerich
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_gpt.c 223921 2011-07-11 05:22:31Z ae $");
#include <sys/param.h>
#include <sys/systm.h>
Modified: trunk/sys/geom/label/g_label_iso9660.c
===================================================================
--- trunk/sys/geom/label/g_label_iso9660.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_iso9660.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/geom/label/g_label_iso9660.c,v 1.4 2008/12/03 00:25:49 laffer1 Exp $ */
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Pawel Jakub Dawidek <pjd at FreeBSD.org>
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/label/g_label_iso9660.c,v 1.5 2006/02/01 12:06:00 pjd Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_iso9660.c 286193 2015-08-02 10:08:57Z trasz $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -48,7 +48,6 @@
{
struct g_provider *pp;
char *sector, *volume;
- int i;
g_topology_assert_not();
pp = cp->provider;
@@ -69,14 +68,7 @@
bzero(label, size);
strlcpy(label, volume, MIN(size, VOLUME_LEN));
g_free(sector);
- for (i = size - 1; i > 0; i--) {
- if (label[i] == '\0')
- continue;
- else if (label[i] == ' ')
- label[i] = '\0';
- else
- break;
- }
+ g_label_rtrim(label, size);
}
struct g_label_desc g_label_iso9660 = {
Modified: trunk/sys/geom/label/g_label_msdosfs.c
===================================================================
--- trunk/sys/geom/label/g_label_msdosfs.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_msdosfs.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/geom/label/g_label_msdosfs.c,v 1.5 2011/12/10 15:46:15 laffer1 Exp $ */
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Pawel Jakub Dawidek <pjd at FreeBSD.org>
* Copyright (c) 2006 Tobias Reifenberger
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/label/g_label_msdosfs.c,v 1.6.2.1 2009/02/13 19:49:35 lulf Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_msdosfs.c 286193 2015-08-02 10:08:57Z trasz $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -49,7 +49,6 @@
FAT32_BSBPB *pfat32_bsbpb;
FAT_DES *pfat_entry;
uint8_t *sector0, *sector;
- uint32_t i;
g_topology_assert_not();
pp = cp->provider;
@@ -201,14 +200,7 @@
}
endofchecks:
- for (i = size - 1; i > 0; i--) {
- if (label[i] == '\0')
- continue;
- else if (label[i] == ' ')
- label[i] = '\0';
- else
- break;
- }
+ g_label_rtrim(label, size);
error:
if (sector0 != NULL)
Modified: trunk/sys/geom/label/g_label_msdosfs.h
===================================================================
--- trunk/sys/geom/label/g_label_msdosfs.h 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_msdosfs.h 2018-05-26 15:26:32 UTC (rev 9972)
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/geom/label/g_label_msdosfs.h,v 1.2 2006/09/30 08:16:49 pjd Exp $
+ * $FreeBSD: stable/10/sys/geom/label/g_label_msdosfs.h 162834 2006-09-30 08:16:49Z pjd $
*/
#include <sys/types.h>
Modified: trunk/sys/geom/label/g_label_ntfs.c
===================================================================
--- trunk/sys/geom/label/g_label_ntfs.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_ntfs.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/geom/label/g_label_ntfs.c,v 1.3 2008/12/03 00:25:49 laffer1 Exp $ */
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 Takanori Watanabe
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/label/g_label_ntfs.c,v 1.6 2006/01/18 11:03:20 pjd Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_ntfs.c 250264 2013-05-05 08:00:16Z stas $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -33,24 +33,76 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
-#include <fs/ntfs/ntfs.h>
-
#include <geom/geom.h>
#include <geom/label/g_label.h>
+#define NTFS_A_VOLUMENAME 0x60
+#define NTFS_FILEMAGIC ((uint32_t)(0x454C4946))
+#define NTFS_VOLUMEINO 3
+
#define G_LABEL_NTFS_DIR "ntfs"
+struct ntfs_attr {
+ uint32_t a_type;
+ uint32_t reclen;
+ uint8_t a_flag;
+ uint8_t a_namelen;
+ uint8_t a_nameoff;
+ uint8_t reserved1;
+ uint8_t a_compression;
+ uint8_t reserved2;
+ uint16_t a_index;
+ uint16_t a_datalen;
+ uint16_t reserved3;
+ uint16_t a_dataoff;
+ uint16_t a_indexed;
+} __packed;
+struct ntfs_filerec {
+ uint32_t fr_hdrmagic;
+ uint16_t fr_hdrfoff;
+ uint16_t fr_hdrfnum;
+ uint8_t reserved[8];
+ uint16_t fr_seqnum;
+ uint16_t fr_nlink;
+ uint16_t fr_attroff;
+ uint16_t fr_flags;
+ uint32_t fr_size;
+ uint32_t fr_allocated;
+ uint64_t fr_mainrec;
+ uint16_t fr_attrnum;
+} __packed;
+
+struct ntfs_bootfile {
+ uint8_t reserved1[3];
+ uint8_t bf_sysid[8];
+ uint16_t bf_bps;
+ uint8_t bf_spc;
+ uint8_t reserved2[7];
+ uint8_t bf_media;
+ uint8_t reserved3[2];
+ uint16_t bf_spt;
+ uint16_t bf_heads;
+ uint8_t reserver4[12];
+ uint64_t bf_spv;
+ uint64_t bf_mftcn;
+ uint64_t bf_mftmirrcn;
+ int8_t bf_mftrecsz;
+ uint32_t bf_ibsz;
+ uint32_t bf_volsn;
+} __packed;
+
static void
g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size)
{
struct g_provider *pp;
- struct bootfile *bf;
- struct filerec *fr;
- struct attr *atr;
+ struct ntfs_bootfile *bf;
+ struct ntfs_filerec *fr;
+ struct ntfs_attr *atr;
off_t voloff;
char *filerecp, *ap;
- char mftrecsz, vnchar;
+ int8_t mftrecsz;
+ char vnchar;
int recsize, j;
g_topology_assert_not();
@@ -59,13 +111,13 @@
pp = cp->provider;
filerecp = NULL;
- bf = (struct bootfile *)g_read_data(cp, 0, pp->sectorsize, NULL);
+ bf = (struct ntfs_bootfile *)g_read_data(cp, 0, pp->sectorsize, NULL);
if (bf == NULL || strncmp(bf->bf_sysid, "NTFS ", 8) != 0)
goto done;
- mftrecsz = (char)bf->bf_mftrecsz;
+ mftrecsz = bf->bf_mftrecsz;
recsize = (mftrecsz > 0) ? (mftrecsz * bf->bf_bps * bf->bf_spc) : (1 << -mftrecsz);
- if (recsize % pp->sectorsize != 0)
+ if (recsize == 0 || recsize % pp->sectorsize != 0)
goto done;
voloff = bf->bf_mftcn * bf->bf_spc * bf->bf_bps +
@@ -76,16 +128,16 @@
filerecp = g_read_data(cp, voloff, recsize, NULL);
if (filerecp == NULL)
goto done;
- fr = (struct filerec *)filerecp;
+ fr = (struct ntfs_filerec *)filerecp;
- if (fr->fr_fixup.fh_magic != NTFS_FILEMAGIC)
+ if (fr->fr_hdrmagic != NTFS_FILEMAGIC)
goto done;
for (ap = filerecp + fr->fr_attroff;
- atr = (struct attr *)ap, atr->a_hdr.a_type != -1;
- ap += atr->a_hdr.reclen) {
- if (atr->a_hdr.a_type == NTFS_A_VOLUMENAME) {
- if(atr->a_r.a_datalen >= size *2){
+ atr = (struct ntfs_attr *)ap, atr->a_type != -1;
+ ap += atr->reclen) {
+ if (atr->a_type == NTFS_A_VOLUMENAME) {
+ if(atr->a_datalen >= size *2){
label[0] = 0;
goto done;
}
@@ -93,8 +145,8 @@
*UNICODE to ASCII.
* Should we need to use iconv(9)?
*/
- for (j = 0; j < atr->a_r.a_datalen; j++) {
- vnchar = *(ap + atr->a_r.a_dataoff + j);
+ for (j = 0; j < atr->a_datalen; j++) {
+ vnchar = *(ap + atr->a_dataoff + j);
if (j & 1) {
if (vnchar) {
label[0] = 0;
Modified: trunk/sys/geom/label/g_label_reiserfs.c
===================================================================
--- trunk/sys/geom/label/g_label_reiserfs.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_reiserfs.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/geom/label/g_label_reiserfs.c,v 1.3 2008/12/03 00:25:49 laffer1 Exp $ */
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 Stanislav Sedov
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/label/g_label_reiserfs.c,v 1.2 2005/08/23 18:55:38 pjd Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_reiserfs.c 199875 2009-11-28 11:57:43Z trasz $");
#include <sys/param.h>
#include <sys/systm.h>
Modified: trunk/sys/geom/label/g_label_ufs.c
===================================================================
--- trunk/sys/geom/label/g_label_ufs.c 2018-05-26 15:25:32 UTC (rev 9971)
+++ trunk/sys/geom/label/g_label_ufs.c 2018-05-26 15:26:32 UTC (rev 9972)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/label/g_label_ufs.c,v 1.11.2.1 2009/04/07 19:18:02 ivoras Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/label/g_label_ufs.c 242379 2012-10-30 21:32:10Z trasz $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,7 +82,11 @@
fs = (struct fs *)g_read_data(cp, superblock, SBLOCKSIZE, NULL);
if (fs == NULL)
continue;
- /* Check for magic and make sure things are the right size */
+ /* Check for magic. We also need to check if file system size is 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.
+ */
if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_fsize > 0 &&
pp->mediasize / fs->fs_fsize == fs->fs_old_size) {
/* Valid UFS1. */
More information about the Midnightbsd-cvs
mailing list