const unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr, const struct blkid_idmag *mag, size_t size)
{
- uint64_t hint_offset;
+ uint64_t hint_offset, off;
- if (!mag->hoff || blkid_probe_get_hint(pr, mag->hoff, &hint_offset) < 0)
- hint_offset = 0;
+ if (mag->kboff >= 0) {
+ if (!mag->hoff || blkid_probe_get_hint(pr, mag->hoff, &hint_offset) < 0)
+ hint_offset = 0;
+
+ off = hint_offset + (mag->kboff << 10);
+ } else {
+ off = pr->size - (-mag->kboff << 10);
+ }
- return blkid_probe_get_buffer(pr, hint_offset + (mag->kboff << 10), size);
+ return blkid_probe_get_buffer(pr, off, size);
}
/*
/* try to detect by magic string */
while(mag && mag->magic) {
const unsigned char *buf;
- uint64_t kboff;
+ long kboff;
uint64_t hint_offset;
if (!mag->hoff || blkid_probe_get_hint(pr, mag->hoff, &hint_offset) < 0)
else
kboff = ((mag->zonenum * pr->zone_size) >> 10) + mag->kboff_inzone;
- off = hint_offset + ((kboff + (mag->sboff >> 10)) << 10);
+ if (kboff >= 0)
+ off = hint_offset + ((kboff + (mag->sboff >> 10)) << 10);
+ else
+ off = pr->size - (-kboff << 10);
buf = blkid_probe_get_buffer(pr, off, 1024);
if (!buf && errno)
if (buf && !memcmp(mag->magic,
buf + (mag->sboff & 0x3ff), mag->len)) {
- DBG(LOWPROBE, ul_debug("\tmagic sboff=%u, kboff=%" PRIu64,
+ DBG(LOWPROBE, ul_debug("\tmagic sboff=%u, kboff=%ld",
mag->sboff, kboff));
if (offset)
*offset = off + (mag->sboff & 0x3ff);