diff options
author | imp <imp@FreeBSD.org> | 2014-11-18 17:06:40 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2014-11-18 17:06:40 +0000 |
commit | 3c75037f3e1c19fb43fc3d662c253fe3c772ba05 (patch) | |
tree | 8dde40502b11a9a0ef847a1c8a7f75b182e47845 /sys/geom | |
parent | f64af8af37042a49bb9d67a03ba65da156be79ae (diff) | |
download | FreeBSD-src-3c75037f3e1c19fb43fc3d662c253fe3c772ba05.zip FreeBSD-src-3c75037f3e1c19fb43fc3d662c253fe3c772ba05.tar.gz |
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.
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/part/g_part.c | 23 | ||||
-rw-r--r-- | sys/geom/part/g_part_bsd.c | 35 | ||||
-rw-r--r-- | sys/geom/part/g_part_if.m | 18 |
3 files changed, 75 insertions, 1 deletions
diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index 9a1730b..5808236 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -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) { diff --git a/sys/geom/part/g_part_bsd.c b/sys/geom/part/g_part_bsd.c index 5a5eabd..e9f09c2 100644 --- a/sys/geom/part/g_part_bsd.c +++ b/sys/geom/part/g_part_bsd.c @@ -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) { diff --git a/sys/geom/part/g_part_if.m b/sys/geom/part/g_part_if.m index 4152e87..31c1d65 100644 --- a/sys/geom/part/g_part_if.m +++ b/sys/geom/part/g_part_if.m @@ -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; |