Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Nov 2014 17:06:40 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r274661 - in head/sys: conf geom/part modules/geom/geom_part/geom_part_bsd
Message-ID:  <201411181706.sAIH6eS9051888@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Tue Nov 18 17:06:40 2014
New Revision: 274661
URL: https://svnweb.freebsd.org/changeset/base/274661

Log:
  Implement the historic DIOCGDINFO ioctl for gpart on BSD
  partitions. Several utilities still use this interface and require
  additional information since gpart was activated than before. This
  allows fsck of a UFS partition without having to specify it is UFS,
  per historic behavior.

Modified:
  head/sys/conf/files
  head/sys/geom/part/g_part.c
  head/sys/geom/part/g_part_bsd.c
  head/sys/geom/part/g_part_if.m
  head/sys/modules/geom/geom_part/geom_part_bsd/Makefile

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Tue Nov 18 16:31:00 2014	(r274660)
+++ head/sys/conf/files	Tue Nov 18 17:06:40 2014	(r274661)
@@ -2773,7 +2773,7 @@ geom/eli/pkcs5v2.c		optional geom_eli
 geom/gate/g_gate.c		optional geom_gate
 geom/geom_aes.c			optional geom_aes
 geom/geom_bsd.c			optional geom_bsd
-geom/geom_bsd_enc.c		optional geom_bsd
+geom/geom_bsd_enc.c		optional geom_bsd | geom_part_bsd
 geom/geom_ccd.c			optional ccd | geom_ccd
 geom/geom_ctl.c			standard
 geom/geom_dev.c			standard

Modified: head/sys/geom/part/g_part.c
==============================================================================
--- head/sys/geom/part/g_part.c	Tue Nov 18 16:31:00 2014	(r274660)
+++ head/sys/geom/part/g_part.c	Tue Nov 18 17:06:40 2014	(r274661)
@@ -143,6 +143,7 @@ static g_orphan_t g_part_orphan;
 static g_spoiled_t g_part_spoiled;
 static g_start_t g_part_start;
 static g_resize_t g_part_resize;
+static g_ioctl_t g_part_ioctl;
 
 static struct g_class g_part_class = {
 	.name = "PART",
@@ -159,7 +160,8 @@ static struct g_class g_part_class = {
 	.orphan = g_part_orphan,
 	.spoiled = g_part_spoiled,
 	.start = g_part_start,
-	.resize = g_part_resize
+	.resize = g_part_resize,
+	.ioctl = g_part_ioctl,
 };
 
 DECLARE_GEOM_CLASS(g_part_class, g_part);
@@ -2059,6 +2061,25 @@ g_part_dumpconf(struct sbuf *sb, const c
 	}
 }
 
+/*-
+ * This start routine is only called for non-trivial requests, all the
+ * trivial ones are handled autonomously by the slice code.
+ * For requests we handle here, we must call the g_io_deliver() on the
+ * bio, and return non-zero to indicate to the slice code that we did so.
+ * This code executes in the "DOWN" I/O path, this means:
+ *    * No sleeping.
+ *    * Don't grab the topology lock.
+ *    * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
+ */
+static int
+g_part_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
+{
+	struct g_part_table *table;
+
+	table = pp->geom->softc;
+	return G_PART_IOCTL(table, pp, cmd, data, fflag, td);
+}
+
 static void
 g_part_resize(struct g_consumer *cp)
 {

Modified: head/sys/geom/part/g_part_bsd.c
==============================================================================
--- head/sys/geom/part/g_part_bsd.c	Tue Nov 18 16:31:00 2014	(r274660)
+++ head/sys/geom/part/g_part_bsd.c	Tue Nov 18 17:06:40 2014	(r274661)
@@ -83,6 +83,8 @@ static const char *g_part_bsd_type(struc
 static int g_part_bsd_write(struct g_part_table *, struct g_consumer *);
 static int g_part_bsd_resize(struct g_part_table *, struct g_part_entry *,
     struct g_part_parms *);
+static int g_part_bsd_ioctl(struct g_part_table *, struct g_provider *,
+    u_long cmd, void *data, int fflag, struct thread *td);
 
 static kobj_method_t g_part_bsd_methods[] = {
 	KOBJMETHOD(g_part_add,		g_part_bsd_add),
@@ -98,6 +100,7 @@ static kobj_method_t g_part_bsd_methods[
 	KOBJMETHOD(g_part_read,		g_part_bsd_read),
 	KOBJMETHOD(g_part_type,		g_part_bsd_type),
 	KOBJMETHOD(g_part_write,	g_part_bsd_write),
+	KOBJMETHOD(g_part_ioctl,	g_part_bsd_ioctl),
 	{ 0, 0 }
 };
 
@@ -494,6 +497,38 @@ g_part_bsd_type(struct g_part_table *bas
 	return (buf);
 }
 
+/*-
+ * This start routine is only called for non-trivial requests, all the
+ * trivial ones are handled autonomously by the slice code.
+ * For requests we handle here, we must call the g_io_deliver() on the
+ * bio, and return non-zero to indicate to the slice code that we did so.
+ * This code executes in the "DOWN" I/O path, this means:
+ *    * No sleeping.
+ *    * Don't grab the topology lock.
+ *    * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
+ */
+static int
+g_part_bsd_ioctl(struct g_part_table *basetable, struct g_provider *pp,
+    u_long cmd, void *data, int fflag, struct thread *td)
+{
+
+	switch (cmd)
+	{
+	case DIOCGDINFO:
+	{
+		struct g_part_bsd_table *table;
+		u_char *p;
+
+		table = (struct g_part_bsd_table *)basetable;
+		p = table->bbarea + pp->sectorsize;
+		return (bsd_disklabel_le_dec(p, data, MAXPARTITIONS));
+	}
+	default:
+		return (ENOIOCTL);
+
+	}
+}
+
 static int
 g_part_bsd_write(struct g_part_table *basetable, struct g_consumer *cp)
 {

Modified: head/sys/geom/part/g_part_if.m
==============================================================================
--- head/sys/geom/part/g_part_if.m	Tue Nov 18 16:31:00 2014	(r274660)
+++ head/sys/geom/part/g_part_if.m	Tue Nov 18 17:06:40 2014	(r274661)
@@ -71,6 +71,14 @@ CODE {
 	{
 		return (ENOSYS);
 	}
+
+	static int
+	default_ioctl(struct g_part_table *table __unused, struct g_provider *pp __unused,
+	    u_long cmd __unused, void *data __unused, int fflag __unused,
+	    struct thread *td __unused)
+	{
+		return (ENOIOCTL);
+	}
 };
 
 # add() - scheme specific processing for the add verb.
@@ -120,6 +128,16 @@ METHOD void fullname {
 	const char *pfx;
 } DEFAULT default_fullname;
 
+# ioctl() - implement historic ioctls, perhaps.
+METHOD int ioctl {
+	struct g_part_table *table;
+	struct g_provider *pp;
+	u_long cmd;
+	void *data;
+	int fflag;
+	struct thread *td;
+} DEFAULT default_ioctl;
+
 # modify() - scheme specific processing for the modify verb.
 METHOD int modify {
 	struct g_part_table *table;

Modified: head/sys/modules/geom/geom_part/geom_part_bsd/Makefile
==============================================================================
--- head/sys/modules/geom/geom_part/geom_part_bsd/Makefile	Tue Nov 18 16:31:00 2014	(r274660)
+++ head/sys/modules/geom/geom_part/geom_part_bsd/Makefile	Tue Nov 18 17:06:40 2014	(r274661)
@@ -1,9 +1,9 @@
 # $FreeBSD$
 
-.PATH: ${.CURDIR}/../../../../geom/part
+.PATH: ${.CURDIR}/../../../../geom/part ${.CURDIR}/../../../../geom
 
 KMOD=	geom_part_bsd
-SRCS=	g_part_bsd.c
+SRCS=	g_part_bsd.c geom_bsd_enc.c
 
 SRCS+=	bus_if.h device_if.h g_part_if.h
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411181706.sAIH6eS9051888>