From: Karel Zak Date: Tue, 15 Sep 2009 20:53:25 +0000 (+0200) Subject: libblkid: allow to change dimension of probing area X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f319b5cadd9f7f9b5d9f807faf645768aa8ecccc;p=util-linux libblkid: allow to change dimension of probing area Signed-off-by: Karel Zak --- diff --git a/shlibs/blkid/src/blkidP.h b/shlibs/blkid/src/blkidP.h index de26ab13..b6fa5634 100644 --- a/shlibs/blkid/src/blkidP.h +++ b/shlibs/blkid/src/blkidP.h @@ -371,6 +371,12 @@ extern void blkid_free_dev(blkid_dev dev); unsigned char *blkid_probe_get_buffer(blkid_probe pr, blkid_loff_t off, blkid_loff_t len); +extern int blkid_probe_get_dimension(blkid_probe pr, + blkid_loff_t *off, blkid_loff_t *size); + +extern int blkid_probe_set_dimension(blkid_probe pr, + blkid_loff_t off, blkid_loff_t size); + /* returns superblok according to 'struct blkid_idmag' */ #define blkid_probe_get_sb(_pr, _mag, type) \ ((type *) blkid_probe_get_buffer((_pr),\ diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index a3d08114..d3da7165 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -509,6 +509,39 @@ int blkid_probe_set_device(blkid_probe pr, int fd, return 0; } +int blkid_probe_get_dimension(blkid_probe pr, + blkid_loff_t *off, blkid_loff_t *size) +{ + if (!pr) + return -1; + + *off = pr->off; + *size = pr->size; + return 0; +} + +int blkid_probe_set_dimension(blkid_probe pr, + blkid_loff_t off, blkid_loff_t size) +{ + if (!pr) + return -1; + + DBG(DEBUG_LOWPROBE, printf( + "changing probing area: size=%llu, off=%llu " + "-to-> size=%llu, off=%llu\n", + (unsigned long long) pr->size, + (unsigned long long) pr->off, + (unsigned long long) size, + (unsigned long long) off)); + + pr->off = off; + pr->size = size; + + blkid_probe_reset_buffer(pr); + + return 0; +} + /** * blkid_do_probe: * @pr: prober