Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/uzip/g_uzip.c
Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | if (((lvl) <= g_uzip_debug) || \ | ||||
printf a; \ | printf a; \ | ||||
} | } | ||||
#define UZIP_CLASS_NAME "UZIP" | #define UZIP_CLASS_NAME "UZIP" | ||||
/* | /* | ||||
* Maximum allowed valid block size (to prevent foot-shooting) | * Maximum allowed valid block size (to prevent foot-shooting) | ||||
*/ | */ | ||||
#define MAX_BLKSZ (MAXPHYS) | #define MAX_BLKSZ (maxphys) | ||||
static char CLOOP_MAGIC_START[] = "#!/bin/sh\n"; | static char CLOOP_MAGIC_START[] = "#!/bin/sh\n"; | ||||
static void g_uzip_read_done(struct bio *bp); | static void g_uzip_read_done(struct bio *bp); | ||||
static void g_uzip_do(struct g_uzip_softc *, struct bio *bp); | static void g_uzip_do(struct g_uzip_softc *, struct bio *bp); | ||||
static void | static void | ||||
g_uzip_softc_free(struct g_geom *gp) | g_uzip_softc_free(struct g_geom *gp) | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | if (bp2 == NULL) { | ||||
g_io_deliver(bp, ENOMEM); | g_io_deliver(bp, ENOMEM); | ||||
return (1); | return (1); | ||||
} | } | ||||
bp2->bio_done = g_uzip_read_done; | bp2->bio_done = g_uzip_read_done; | ||||
bp2->bio_offset = TOFF_2_BOFF(sc, pp, start_blk); | bp2->bio_offset = TOFF_2_BOFF(sc, pp, start_blk); | ||||
while (1) { | while (1) { | ||||
bp2->bio_length = TLEN_2_BLEN(sc, pp, bp2, end_blk - 1); | bp2->bio_length = TLEN_2_BLEN(sc, pp, bp2, end_blk - 1); | ||||
if (bp2->bio_length <= MAXPHYS) { | if (bp2->bio_length <= maxphys) { | ||||
break; | break; | ||||
} | } | ||||
if (end_blk == (start_blk + 1)) { | if (end_blk == (start_blk + 1)) { | ||||
break; | break; | ||||
} | } | ||||
end_blk--; | end_blk--; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | #endif | ||||
sc->blksz = ntohl(header->blksz); | sc->blksz = ntohl(header->blksz); | ||||
sc->nblocks = ntohl(header->nblocks); | sc->nblocks = ntohl(header->nblocks); | ||||
if (sc->blksz % 512 != 0) { | if (sc->blksz % 512 != 0) { | ||||
printf("%s: block size (%u) should be multiple of 512.\n", | printf("%s: block size (%u) should be multiple of 512.\n", | ||||
gp->name, sc->blksz); | gp->name, sc->blksz); | ||||
goto e4; | goto e4; | ||||
} | } | ||||
if (sc->blksz > MAX_BLKSZ) { | if (sc->blksz > MAX_BLKSZ) { | ||||
printf("%s: block size (%u) should not be larger than %d.\n", | printf("%s: block size (%u) should not be larger than %lu.\n", | ||||
gp->name, sc->blksz, MAX_BLKSZ); | gp->name, sc->blksz, MAX_BLKSZ); | ||||
} | } | ||||
total_offsets = sc->nblocks + 1; | total_offsets = sc->nblocks + 1; | ||||
if (sizeof(struct cloop_header) + | if (sizeof(struct cloop_header) + | ||||
total_offsets * sizeof(uint64_t) > pp->mediasize) { | total_offsets * sizeof(uint64_t) > pp->mediasize) { | ||||
printf("%s: media too small for %u blocks\n", | printf("%s: media too small for %u blocks\n", | ||||
gp->name, sc->nblocks); | gp->name, sc->nblocks); | ||||
goto e4; | goto e4; | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |