--- geom_map.c.orig 2011-04-19 13:06:15.247205115 +0200 +++ geom_map.c 2011-04-19 13:14:31.894205223 +0200 @@ -53,26 +53,18 @@ #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]; + 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_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, - struct thread *td) -{ - /* TODO: add/remove/adjust slices */ - return (ENOIOCTL); -} - -static int g_map_access(struct g_provider *pp, int dread, int dwrite, int dexcl) { - struct g_geom *gp; + struct g_geom *gp; struct g_slicer *gsp; struct g_map_softc *sc; @@ -90,7 +82,7 @@ g_map_start(struct bio *bp) { struct g_provider *pp; - struct g_geom *gp; + struct g_geom *gp; struct g_map_softc *sc; struct g_slicer *gsp; int idx; @@ -157,9 +149,8 @@ ret = sscanf(line, "search:%qi:%qi:%63c", &search_start, &search_step, search_key); - if (ret < 3) { + if (ret < 3) return (1); - } if (bootverbose) { printf("MAP: search key \"%s\" from 0x%llx, step 0x%llx\n", @@ -167,9 +158,8 @@ } /* error if search_key is empty */ - if (strlen(search_key) < 1) { + if (strlen(search_key) < 1) return (1); - } /* sscanf successful, and we start marker search */ for (search_offset = search_start; @@ -186,14 +176,15 @@ strncpy(key, search_key, MAP_MAX_MARKER_LEN); - for (c = 0; c < MAP_MAX_MARKER_LEN && key[c]; c++) - if (key[c] == '.') + for (c = 0; c < MAP_MAX_MARKER_LEN && key[c]; c++) { + if (key[c] == '.') { key[c] = ((char *)(buf + (search_offset % sectorsize)))[c]; + } + } if (buf != NULL && strncmp(buf + search_offset % sectorsize, key, strlen(search_key)) == 0) { - g_free(buf); /* Marker found, so return their offset */ *offset = search_offset; @@ -216,8 +207,7 @@ int readonly, ret; /* hint.map.0.at="cfid0" - bind to cfid0 media */ - ret = resource_string_value("map", i, "at", &value); - if (ret != 0) + if (resource_string_value("map", i, "at", &value) != 0) return (1); /* Check if this correct provider */ @@ -228,11 +218,9 @@ * hint.map.0.name="uboot" - name of partition, will be available * as "/dev/map/uboot" */ - ret = resource_string_value("map", i, "name", &name); - if (ret != 0) { - if (bootverbose) { + if (resource_string_value("map", i, "name", &name) != 0) { + if (bootverbose) printf("MAP: hint.map.%d has no name\n", i); - } return (1); } @@ -242,15 +230,12 @@ * search for text "marker text", begin at 0x10000, step 0x200 * until we found marker or end of media reached */ - ret = resource_string_value("map", i, "start", &value); - if (ret != 0) { - if (bootverbose) { + if (resource_string_value("map", i, "start", &value) != 0) { + if (bootverbose) printf("MAP: \"%s\" has no start value\n", name); - } return (1); } - ret = find_marker(cp, value, &start); - if (ret != 0) { + if (find_marker(cp, value, &start) != 0) { if (bootverbose) { printf("MAP: \"%s\" can't parse/use start value\n", name); @@ -259,15 +244,12 @@ } /* like "start" */ - ret = resource_string_value("map", i, "end", &value); - if (ret != 0) { - if (bootverbose) { + if (resource_string_value("map", i, "end", &value) != 0) { + if (bootverbose) printf("MAP: \"%s\" has no end value\n", name); - } return (1); } - ret = find_marker(cp, value, &end); - if (ret != 0) { + if (find_marker(cp, value, &end) != 0) { if (bootverbose) { printf("MAP: \"%s\" can't parse/use start value\n", name); @@ -276,14 +258,11 @@ } /* variable readonly optional, disable write access */ - resource_int_value("map", i, "readonly", &readonly); - if (ret != 0) { + if (resource_int_value("map", i, "readonly", &readonly) != 0) readonly = 0; - } /* offset of partition data, from partition begin */ - ret = resource_string_value("map", i, "offset", &value); - if (ret == 0) { + if (resource_string_value("map", i, "offset", &value) == 0) { offset = strtouq(value, &op, 0); if (*op != '\0') { if (bootverbose) { @@ -297,8 +276,7 @@ } /* partition data size */ - ret = resource_string_value("map", i, "dsize", &value); - if (ret == 0) { + if (resource_string_value("map", i, "dsize", &value) == 0) { dsize = strtouq(value, &op, 0); if (*op != '\0') { if (bootverbose) { @@ -312,9 +290,8 @@ } size = end - start; - if (dsize == 0) { + if (dsize == 0) dsize = size - offset; - } /* end is 0 or size is 0, No MAP - so next */ if (end < start) { @@ -325,7 +302,7 @@ return (1); } - if ((offset + dsize) > size) { + if (offset + dsize > size) { if (bootverbose) { printf("MAP: \"%s\", \"dsize\" bigger than " "partition - offset\n", name); @@ -335,10 +312,11 @@ ret = g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + offset, dsize, cp->provider->sectorsize, "map/%s", name); - - if (ret != 0 && bootverbose) { - printf("MAP: g_slice_config returns %d for \"%s\"\n", - ret, name); + if (ret != 0) { + if (bootverbose) { + printf("MAP: g_slice_config returns %d for \"%s\"\n", + ret, name); + } return (1); } @@ -358,7 +336,7 @@ } static struct g_geom * -g_map_taste(struct g_class *mp, struct g_provider *pp, int insist) +g_map_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) { struct g_map_softc *sc; struct g_consumer *cp; @@ -372,7 +350,6 @@ gp = g_slice_new(mp, MAP_MAXSLICE, pp, &cp, &sc, sizeof(*sc), g_map_start); - if (gp == NULL) return (NULL); @@ -380,10 +357,8 @@ sc->parent_access = gp->access; gp->access = g_map_access; - for (i = 0; i < MAP_MAXSLICE; i++) { + for (i = 0; i < MAP_MAXSLICE; i++) g_map_parse_part(mp, pp, cp, gp, sc, i); - } - if (i == 0) return (NULL); @@ -398,7 +373,7 @@ static void g_map_config(struct gctl_req *req, struct g_class *mp, const char *verb) { - struct g_geom *gp; + struct g_geom *gp; g_topology_assert(); gp = gctl_get_geom(req, mp, "geom"); @@ -413,6 +388,5 @@ .taste = g_map_taste, .dumpconf = g_map_dumpconf, .ctlreq = g_map_config, - .ioctl = g_map_ioctl, }; DECLARE_GEOM_CLASS(g_map_class, g_map);