1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

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.
This commit is contained in:
Warner Losh 2014-11-18 17:06:40 +00:00
parent c2384debfc
commit 73f49e9eef
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=274661
5 changed files with 78 additions and 4 deletions

View File

@ -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

View File

@ -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 char *indent, struct g_geom *gp,
}
}
/*-
* 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)
{

View File

@ -83,6 +83,8 @@ static const char *g_part_bsd_type(struct g_part_table *, struct g_part_entry *,
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 *basetable, struct g_part_entry *baseentry,
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)
{

View File

@ -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;

View File

@ -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