Extends struct blkid_idmag with a new member hoff which specify name of the
hint used for blkid_probe_get_hint() function to retrieve offset to kboff.
blkid_probe_get_idmag() will use supplied hint offset in bytes as a start
position from which the final offsets for magic strings are calculated.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
const char *magic; /* magic string */
unsigned int len; /* length of magic */
+ const char *hoff; /* hint which contains byte offset to kboff */
long kboff; /* kilobyte offset of superblock */
unsigned int sboff; /* byte offset within superblock */
};
/* try to detect by magic string */
while(mag && mag->magic) {
unsigned char *buf;
+ uint64_t hint_offset;
- off = (mag->kboff + (mag->sboff >> 10)) << 10;
+ if (!mag->hoff || blkid_probe_get_hint(pr, mag->hoff, &hint_offset) < 0)
+ hint_offset = 0;
+
+ off = hint_offset + ((mag->kboff + (mag->sboff >> 10)) << 10);
buf = blkid_probe_get_buffer(pr, off, 1024);
if (!buf && errno)