mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
geom_map(4): Garbage collect disconnected driver
The last MIPS user has been removed inc09981f12 years ago, the last ARM one in58d5c511even 5.5 years ago. (cherry picked from commit 03e8d25b1f9218dcd52d13819dda14dbbaf622b7)
This commit is contained in:
parent
8595e76a9f
commit
d6ec20a309
6 changed files with 3 additions and 611 deletions
|
|
@ -59,6 +59,9 @@ OLD_FILES+=usr/tests/usr.bin/uniq/d_input.in
|
|||
OLD_FILES+=usr/tests/usr.bin/uniq/d_show_duplicates.out
|
||||
OLD_FILES+=usr/tests/usr.bin/uniq/d_show_uniques.out
|
||||
|
||||
# 20240114: Removal of geom_map(4)
|
||||
OLD_FILES+=usr/share/man/man4/geom_map.4
|
||||
|
||||
# 20240107: new clang import which bumps version from 16 to 17
|
||||
OLD_FILES+=usr/lib/clang/16/include/__clang_cuda_builtin_vars.h
|
||||
OLD_FILES+=usr/lib/clang/16/include/__clang_cuda_cmath.h
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@ MAN= aac.4 \
|
|||
genetlink.4 \
|
||||
geom.4 \
|
||||
geom_linux_lvm.4 \
|
||||
geom_map.4 \
|
||||
geom_uzip.4 \
|
||||
gif.4 \
|
||||
${_gve.4} \
|
||||
|
|
|
|||
|
|
@ -1,209 +0,0 @@
|
|||
.\"
|
||||
.\" Copyright (c) 2011 Aleksandr Rybalko
|
||||
.\" 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 AUTHOR 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 AUTHOR 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.
|
||||
.\"
|
||||
.Dd June 8, 2015
|
||||
.Dt GEOM_MAP 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm geom_map
|
||||
.Nd "GEOM module that maps defined items as separate partitions"
|
||||
.Sh SYNOPSIS
|
||||
To compile this driver into the kernel,
|
||||
place the following line in your
|
||||
kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "options geom_map"
|
||||
.Ed
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
framework provides support for mapping defined parts of the media.
|
||||
Basically it is helpful for embedded devices where in the one continuous
|
||||
flash are loader, kernel and rootfs parts.
|
||||
.Nm
|
||||
allows making them available as separate parts and protects the loader from
|
||||
being overwritten.
|
||||
.Pp
|
||||
At boot time
|
||||
.Nm
|
||||
partitions are listed (only with bootverbose) as:
|
||||
.Bd -literal -offset indent
|
||||
MAP: 0x30000, data=0x30000 "/dev/map/bootloader"
|
||||
MAP: 30000x10000, data=0x10000 "/dev/map/factory"
|
||||
MAP: 40000x7a0000, data=0x7a0000 "/dev/map/upgrade"
|
||||
MAP: search key ".!/bin/sh" from 0x100000, step 0x10000
|
||||
MAP: 40000x110000, data=0x110000 "/dev/map/kernel"
|
||||
MAP: search key ".!/bin/sh" from 0x100000, step 0x10000
|
||||
MAP: 150000x690000, data=0x690000 "/dev/map/rootfs"
|
||||
MAP: 7e0000x20000, data=0x20000 "/dev/map/config"
|
||||
.Ed
|
||||
.Pp
|
||||
The current
|
||||
.Nm
|
||||
configuration can be accessed with the following
|
||||
.Xr sysctl 8
|
||||
nodes:
|
||||
.Va kern.geom.conftxt , kern.geom.confxml ,
|
||||
and
|
||||
.Va kern.geom.confdot
|
||||
or by using
|
||||
.Dq Li "geom map list" .
|
||||
.Bd -literal -offset indent
|
||||
# sysctl -n kern.geom.conftxt
|
||||
0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc
|
||||
0 DISK cfid0 8388608 4 hd 0 sc 0
|
||||
1 MAP map/config 131072 4 i 5 o 8257536 entry 0 dsize 131072
|
||||
1 MAP map/rootfs 6881280 4 i 4 o 1376256 entry 0 dsize 6881280
|
||||
2 UZIP map/rootfs.uzip 18677760 512
|
||||
1 MAP map/kernel 1114112 4 i 3 o 262144 entry 0 dsize 1114112
|
||||
1 MAP map/upgrade 7995392 4 i 2 o 262144 entry 0 dsize 7995392
|
||||
1 MAP map/factory 65536 4 i 1 o 196608 entry 0 dsize 65536
|
||||
1 MAP map/bootloader 196608 4 i 0 o 0 entry 0 dsize 196608
|
||||
.Ed
|
||||
.Pp
|
||||
Driver configuration can be done in
|
||||
.Xr device.hints 5 .
|
||||
List of used parameters:
|
||||
.Bl -tag -width indent
|
||||
.It Va at
|
||||
select media to attach
|
||||
.It Va name
|
||||
name of partition (will create device
|
||||
.Pa /dev/map/ Ns Ar that_name )
|
||||
.It Va start
|
||||
offset from the beginning of the parent media to start of the mapped partition.
|
||||
This field can also have a special value
|
||||
.Qq Li search: Ns Ar searchstart Ns Li : Ns Ar searchstep Ns Li : Ns Ar searchkey ,
|
||||
where:
|
||||
.Bl -tag -width indent
|
||||
.It Ar searchstart
|
||||
offset from the beginning of the parent media where search will be started
|
||||
.It Ar searchstep
|
||||
value of the increment used while searching for the partition boundary markers
|
||||
.It Ar searchkey
|
||||
key which will be used to find partition boundary markers.
|
||||
The wildcard
|
||||
.Ql .\&
|
||||
can be used to match any character on that position
|
||||
.El
|
||||
.It Va end
|
||||
offset from the beginning of the parent media to the end of the mapped partition.
|
||||
This field can also have the special value
|
||||
.Qq Li search: Ns Ar searchstart Ns Li : Ns Ar searchstep Ns Li : Ns Ar searchkey ,
|
||||
as described above.
|
||||
.It Va offset
|
||||
offset where the data of the mapped partition begins
|
||||
.El
|
||||
.Pp
|
||||
Each record contains the start address (in bytes) from the media begin, size
|
||||
(in bytes), offset where the data of mapped partition begins, and the name of
|
||||
new device.
|
||||
.Bd -literal -offset indent
|
||||
MAP: 150000x690000, data=0x690000 "/dev/map/rootfs"
|
||||
.Ed
|
||||
.Bd -literal
|
||||
00150000 - start address
|
||||
00690000 - size
|
||||
00000000 - data begin from zero offset
|
||||
00690000 - data size
|
||||
"map/rootfs" - new media will be accessible via /dev/map/rootfs dev.
|
||||
.Ed
|
||||
.Sh EXAMPLES
|
||||
If we need to implement layout shown above, we need to define the following
|
||||
hints:
|
||||
.Bd -literal -offset indent
|
||||
hint.map.0.at="cfid0"
|
||||
hint.map.0.start=0x00000000
|
||||
hint.map.0.end=0x00030000
|
||||
hint.map.0.name="bootloader"
|
||||
hint.map.0.readonly=1
|
||||
.Ed
|
||||
.Pp
|
||||
This defines
|
||||
.Pa /dev/map/bootloader
|
||||
at disk
|
||||
.Pa cfid0
|
||||
starting at
|
||||
.Li 0x00000000
|
||||
and ending at
|
||||
.Li 0x00030000 ,
|
||||
it is also marked as readonly.
|
||||
.Bd -literal -offset indent
|
||||
hint.map.1.at="cfid0"
|
||||
hint.map.1.start=0x00030000
|
||||
hint.map.1.end=0x00040000
|
||||
hint.map.1.name="factory"
|
||||
|
||||
hint.map.2.at="cfid0"
|
||||
hint.map.2.start=0x00040000
|
||||
hint.map.2.end=0x007e0000
|
||||
hint.map.2.name="upgrade"
|
||||
|
||||
hint.map.3.at="cfid0"
|
||||
hint.map.3.name="kernel"
|
||||
hint.map.3.start=0x00040000
|
||||
hint.map.3.end="search:0x00100000:0x10000:.!/bin/sh"
|
||||
.Ed
|
||||
.Pp
|
||||
This defines
|
||||
.Pa /dev/map/kernel
|
||||
at disk
|
||||
.Pa cfid0
|
||||
starting at
|
||||
.Li 0x00040000 ,
|
||||
but the end position must be searched by finding the key
|
||||
.Dq Li ".!/bin/sh" ,
|
||||
from offset
|
||||
.Li 0x00100000
|
||||
to the end of media with step
|
||||
.Li 0x10000 .
|
||||
The real marker in this case is
|
||||
.Dq Li "#!/bin/sh" ,
|
||||
but
|
||||
.Ql #
|
||||
terminates the line when the hints file is parsed, so we need to use wildcard
|
||||
.Ql .\&
|
||||
instead of
|
||||
.Ql # .
|
||||
.Bd -literal -offset indent
|
||||
hint.map.4.at="cfid0"
|
||||
hint.map.4.name="rootfs"
|
||||
hint.map.4.start="search:0x00100000:0x10000:.!/bin/sh"
|
||||
hint.map.4.end=0x007e0000
|
||||
|
||||
hint.map.5.at="cfid0"
|
||||
hint.map.5.start=0x007e0000
|
||||
hint.map.5.end=0x00800000
|
||||
hint.map.5.name="config"
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr geom 4 ,
|
||||
.Xr geom 8 ,
|
||||
.Xr sysctl 8
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Aleksandr Rybalko Aq Mt ray@ddteam.net .
|
||||
|
|
@ -3618,7 +3618,6 @@ geom/geom_event.c standard
|
|||
geom/geom_flashmap.c optional fdt cfi | fdt mx25l | mmcsd | fdt n25q | fdt at45d
|
||||
geom/geom_io.c standard
|
||||
geom/geom_kern.c standard
|
||||
geom/geom_map.c optional geom_map
|
||||
geom/geom_redboot.c optional geom_redboot
|
||||
geom/geom_slice.c standard
|
||||
geom/geom_subr.c standard
|
||||
|
|
|
|||
|
|
@ -1,393 +0,0 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2010-2011 Aleksandr Rybalko <ray@dlink.ua>
|
||||
* based on geom_redboot.c
|
||||
* Copyright (c) 2009 Sam Leffler, Errno Consulting
|
||||
* 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,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
||||
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
||||
* redistribution must be conditioned upon including a substantially
|
||||
* similar Disclaimer requirement for further binary redistribution.
|
||||
*
|
||||
* NO WARRANTY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/bio.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/sbuf.h>
|
||||
|
||||
#include <geom/geom.h>
|
||||
#include <geom/geom_slice.h>
|
||||
|
||||
#define MAP_CLASS_NAME "MAP"
|
||||
#define MAP_MAXSLICE 64
|
||||
#define MAP_MAX_MARKER_LEN 64
|
||||
|
||||
struct g_map_softc {
|
||||
off_t offset[MAP_MAXSLICE]; /* offset in flash */
|
||||
off_t size[MAP_MAXSLICE]; /* image size in bytes */
|
||||
off_t entry[MAP_MAXSLICE];
|
||||
off_t dsize[MAP_MAXSLICE];
|
||||
uint8_t readonly[MAP_MAXSLICE];
|
||||
g_access_t *parent_access;
|
||||
};
|
||||
|
||||
static int
|
||||
g_map_access(struct g_provider *pp, int dread, int dwrite, int dexcl)
|
||||
{
|
||||
struct g_geom *gp;
|
||||
struct g_slicer *gsp;
|
||||
struct g_map_softc *sc;
|
||||
|
||||
gp = pp->geom;
|
||||
gsp = gp->softc;
|
||||
sc = gsp->softc;
|
||||
|
||||
if (dwrite > 0 && sc->readonly[pp->index])
|
||||
return (EPERM);
|
||||
|
||||
return (sc->parent_access(pp, dread, dwrite, dexcl));
|
||||
}
|
||||
|
||||
static int
|
||||
g_map_start(struct bio *bp)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_geom *gp;
|
||||
struct g_map_softc *sc;
|
||||
struct g_slicer *gsp;
|
||||
int idx;
|
||||
|
||||
pp = bp->bio_to;
|
||||
idx = pp->index;
|
||||
gp = pp->geom;
|
||||
gsp = gp->softc;
|
||||
sc = gsp->softc;
|
||||
|
||||
if (bp->bio_cmd == BIO_GETATTR) {
|
||||
if (g_handleattr_int(bp, MAP_CLASS_NAME "::entry",
|
||||
sc->entry[idx])) {
|
||||
return (1);
|
||||
}
|
||||
if (g_handleattr_int(bp, MAP_CLASS_NAME "::dsize",
|
||||
sc->dsize[idx])) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
g_map_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
|
||||
struct g_consumer *cp __unused, struct g_provider *pp)
|
||||
{
|
||||
struct g_map_softc *sc;
|
||||
struct g_slicer *gsp;
|
||||
|
||||
gsp = gp->softc;
|
||||
sc = gsp->softc;
|
||||
g_slice_dumpconf(sb, indent, gp, cp, pp);
|
||||
if (pp != NULL) {
|
||||
if (indent == NULL) {
|
||||
sbuf_printf(sb, " entry %jd", (intmax_t)sc->entry[pp->index]);
|
||||
sbuf_printf(sb, " dsize %jd", (intmax_t)sc->dsize[pp->index]);
|
||||
} else {
|
||||
sbuf_printf(sb, "%s<entry>%jd</entry>\n", indent,
|
||||
(intmax_t)sc->entry[pp->index]);
|
||||
sbuf_printf(sb, "%s<dsize>%jd</dsize>\n", indent,
|
||||
(intmax_t)sc->dsize[pp->index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
find_marker(struct g_consumer *cp, const char *line, off_t *offset)
|
||||
{
|
||||
off_t search_start, search_offset, search_step;
|
||||
size_t sectorsize;
|
||||
uint8_t *buf;
|
||||
char *op, key[MAP_MAX_MARKER_LEN], search_key[MAP_MAX_MARKER_LEN];
|
||||
int ret, c;
|
||||
|
||||
/* Try convert to numeric first */
|
||||
*offset = strtouq(line, &op, 0);
|
||||
if (*op == '\0')
|
||||
return (0);
|
||||
|
||||
bzero(search_key, MAP_MAX_MARKER_LEN);
|
||||
sectorsize = cp->provider->sectorsize;
|
||||
|
||||
#ifdef __LP64__
|
||||
ret = sscanf(line, "search:%li:%li:%63c",
|
||||
&search_start, &search_step, search_key);
|
||||
#else
|
||||
ret = sscanf(line, "search:%qi:%qi:%63c",
|
||||
&search_start, &search_step, search_key);
|
||||
#endif
|
||||
if (ret < 3)
|
||||
return (1);
|
||||
|
||||
if (bootverbose) {
|
||||
printf("MAP: search %s for key \"%s\" from 0x%jx, step 0x%jx\n",
|
||||
cp->geom->name, search_key, (intmax_t)search_start, (intmax_t)search_step);
|
||||
}
|
||||
|
||||
/* error if search_key is empty */
|
||||
if (strlen(search_key) < 1)
|
||||
return (1);
|
||||
|
||||
/* sscanf successful, and we start marker search */
|
||||
for (search_offset = search_start;
|
||||
search_offset < cp->provider->mediasize;
|
||||
search_offset += search_step) {
|
||||
g_topology_unlock();
|
||||
buf = g_read_data(cp, rounddown(search_offset, sectorsize),
|
||||
roundup(strlen(search_key), sectorsize), NULL);
|
||||
g_topology_lock();
|
||||
|
||||
/*
|
||||
* Don't bother doing the rest if buf==NULL; eg derefencing
|
||||
* to assemble 'key'.
|
||||
*/
|
||||
if (buf == NULL)
|
||||
continue;
|
||||
|
||||
/* Wildcard, replace '.' with byte from data */
|
||||
/* TODO: add support wildcard escape '\.' */
|
||||
|
||||
strncpy(key, search_key, MAP_MAX_MARKER_LEN);
|
||||
|
||||
for (c = 0; c < MAP_MAX_MARKER_LEN && key[c]; c++) {
|
||||
if (key[c] == '.') {
|
||||
key[c] = ((char *)(buf +
|
||||
(search_offset % sectorsize)))[c];
|
||||
}
|
||||
}
|
||||
|
||||
/* Assume buf != NULL here */
|
||||
if (memcmp(buf + search_offset % sectorsize,
|
||||
key, strlen(search_key)) == 0) {
|
||||
g_free(buf);
|
||||
/* Marker found, so return their offset */
|
||||
*offset = search_offset;
|
||||
return (0);
|
||||
}
|
||||
g_free(buf);
|
||||
}
|
||||
|
||||
/* Marker not found */
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
g_map_parse_part(struct g_class *mp, struct g_provider *pp,
|
||||
struct g_consumer *cp, struct g_geom *gp, struct g_map_softc *sc, int i)
|
||||
{
|
||||
const char *value, *name;
|
||||
char *op;
|
||||
off_t start, end, offset, size, dsize;
|
||||
int readonly, ret;
|
||||
|
||||
/* hint.map.0.at="cfid0" - bind to cfid0 media */
|
||||
if (resource_string_value("map", i, "at", &value) != 0)
|
||||
return (1);
|
||||
|
||||
/* Check if this correct provider */
|
||||
if (strcmp(pp->name, value) != 0)
|
||||
return (1);
|
||||
|
||||
/*
|
||||
* hint.map.0.name="uboot" - name of partition, will be available
|
||||
* as "/dev/map/uboot"
|
||||
*/
|
||||
if (resource_string_value("map", i, "name", &name) != 0) {
|
||||
if (bootverbose)
|
||||
printf("MAP: hint.map.%d has no name\n", i);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* hint.map.0.start="0x00010000" - partition start at 0x00010000
|
||||
* or hint.map.0.start="search:0x00010000:0x200:marker text" -
|
||||
* search for text "marker text", begin at 0x10000, step 0x200
|
||||
* until we found marker or end of media reached
|
||||
*/
|
||||
if (resource_string_value("map", i, "start", &value) != 0) {
|
||||
if (bootverbose)
|
||||
printf("MAP: \"%s\" has no start value\n", name);
|
||||
return (1);
|
||||
}
|
||||
if (find_marker(cp, value, &start) != 0) {
|
||||
if (bootverbose) {
|
||||
printf("MAP: \"%s\" can't parse/use start value\n",
|
||||
name);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* like "start" */
|
||||
if (resource_string_value("map", i, "end", &value) != 0) {
|
||||
if (bootverbose)
|
||||
printf("MAP: \"%s\" has no end value\n", name);
|
||||
return (1);
|
||||
}
|
||||
if (find_marker(cp, value, &end) != 0) {
|
||||
if (bootverbose) {
|
||||
printf("MAP: \"%s\" can't parse/use end value\n",
|
||||
name);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* variable readonly optional, disable write access */
|
||||
if (resource_int_value("map", i, "readonly", &readonly) != 0)
|
||||
readonly = 0;
|
||||
|
||||
/* offset of partition data, from partition begin */
|
||||
if (resource_string_value("map", i, "offset", &value) == 0) {
|
||||
offset = strtouq(value, &op, 0);
|
||||
if (*op != '\0') {
|
||||
if (bootverbose) {
|
||||
printf("MAP: \"%s\" can't parse offset\n",
|
||||
name);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
} else {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
/* partition data size */
|
||||
if (resource_string_value("map", i, "dsize", &value) == 0) {
|
||||
dsize = strtouq(value, &op, 0);
|
||||
if (*op != '\0') {
|
||||
if (bootverbose) {
|
||||
printf("MAP: \"%s\" can't parse dsize\n",
|
||||
name);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
} else {
|
||||
dsize = 0;
|
||||
}
|
||||
|
||||
size = end - start;
|
||||
if (dsize == 0)
|
||||
dsize = size - offset;
|
||||
|
||||
/* end is 0 or size is 0, No MAP - so next */
|
||||
if (end < start) {
|
||||
if (bootverbose) {
|
||||
printf("MAP: \"%s\", \"end\" less than "
|
||||
"\"start\"\n", name);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (offset + dsize > size) {
|
||||
if (bootverbose) {
|
||||
printf("MAP: \"%s\", \"dsize\" bigger than "
|
||||
"partition - offset\n", name);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
ret = g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + offset,
|
||||
dsize, cp->provider->sectorsize, "map/%s", name);
|
||||
if (ret != 0) {
|
||||
if (bootverbose) {
|
||||
printf("MAP: g_slice_config returns %d for \"%s\"\n",
|
||||
ret, name);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (bootverbose) {
|
||||
printf("MAP: %s: %jxx%jx, data=%jxx%jx "
|
||||
"\"/dev/map/%s\"\n",
|
||||
cp->geom->name, (intmax_t)start, (intmax_t)size, (intmax_t)offset,
|
||||
(intmax_t)dsize, name);
|
||||
}
|
||||
|
||||
sc->offset[i] = start;
|
||||
sc->size[i] = size;
|
||||
sc->entry[i] = offset;
|
||||
sc->dsize[i] = dsize;
|
||||
sc->readonly[i] = readonly ? 1 : 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct g_geom *
|
||||
g_map_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
|
||||
{
|
||||
struct g_map_softc *sc;
|
||||
struct g_consumer *cp;
|
||||
struct g_geom *gp;
|
||||
int i;
|
||||
|
||||
g_trace(G_T_TOPOLOGY, "map_taste(%s,%s)", mp->name, pp->name);
|
||||
g_topology_assert();
|
||||
if (strcmp(pp->geom->class->name, MAP_CLASS_NAME) == 0)
|
||||
return (NULL);
|
||||
|
||||
gp = g_slice_new(mp, MAP_MAXSLICE, pp, &cp, &sc, sizeof(*sc),
|
||||
g_map_start);
|
||||
if (gp == NULL)
|
||||
return (NULL);
|
||||
|
||||
/* interpose our access method */
|
||||
sc->parent_access = gp->access;
|
||||
gp->access = g_map_access;
|
||||
|
||||
for (i = 0; i < MAP_MAXSLICE; i++)
|
||||
g_map_parse_part(mp, pp, cp, gp, sc, i);
|
||||
|
||||
g_access(cp, -1, 0, 0);
|
||||
if (LIST_EMPTY(&gp->provider)) {
|
||||
if (bootverbose)
|
||||
printf("MAP: No valid partition found at %s\n", pp->name);
|
||||
g_slice_spoiled(cp);
|
||||
return (NULL);
|
||||
}
|
||||
return (gp);
|
||||
}
|
||||
|
||||
static struct g_class g_map_class = {
|
||||
.name = MAP_CLASS_NAME,
|
||||
.version = G_VERSION,
|
||||
.taste = g_map_taste,
|
||||
.dumpconf = g_map_dumpconf,
|
||||
};
|
||||
DECLARE_GEOM_CLASS(g_map_class, g_map);
|
||||
MODULE_VERSION(geom_map, 0);
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
.PATH: ${SRCTOP}/sys/geom
|
||||
|
||||
KMOD= geom_map
|
||||
SRCS= geom_map.c bus_if.h device_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
Loading…
Reference in a new issue