From: Karel Zak Date: Thu, 18 Sep 2008 11:15:21 +0000 (+0200) Subject: blkid: add blkid_probe_get_sb() macro X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=148e2f9e3e9bded02ad5bdca711c34d0fd0a1a26;p=util-linux blkid: add blkid_probe_get_sb() macro Signed-off-by: Karel Zak --- diff --git a/libs/blkid/src/blkidP.h b/libs/blkid/src/blkidP.h index 56e569f3..e32d7dcd 100644 --- a/libs/blkid/src/blkidP.h +++ b/libs/blkid/src/blkidP.h @@ -95,7 +95,7 @@ struct blkid_struct_probe size_t sbbuf_len; /* size of data in superblock buffer */ unsigned char *buf; /* seek buffer */ - off_t buf_off; /* offset of seek buffer */ + blkid_loff_t buf_off; /* offset of seek buffer */ size_t buf_len; /* size of data in seek buffer */ size_t buf_max; /* allocated size of seek buffer */ @@ -250,6 +250,11 @@ extern void blkid_free_dev(blkid_dev dev); /* probe.c */ unsigned char *blkid_probe_get_buffer(blkid_probe pr, blkid_loff_t off, blkid_loff_t len); + +#define blkid_probe_get_sb(_pr, _mag, type) \ + ((type *) blkid_probe_get_buffer((_pr),\ + (_mag)->kboff << 10, sizeof(type))) + extern int blkid_probe_set_value(blkid_probe pr, const char *name, unsigned char *data, size_t len); extern int blkid_probe_vsprintf_value(blkid_probe pr, const char *name, diff --git a/libs/blkid/src/probers/cramfs.c b/libs/blkid/src/probers/cramfs.c index 33b6566f..caf13881 100644 --- a/libs/blkid/src/probers/cramfs.c +++ b/libs/blkid/src/probers/cramfs.c @@ -44,8 +44,8 @@ static int probe_cramfs(blkid_probe pr, const struct blkid_idmag *mag) { struct cramfs_super *cs; - cs = (struct cramfs_super *) blkid_probe_get_buffer(pr, 0, 0x200); - if (cs == NULL) + cs = blkid_probe_get_sb(pr, mag, struct cramfs_super); + if (!cs) return -1; blkid_probe_set_label(pr, cs->name, sizeof(cs->name)); diff --git a/libs/blkid/src/probers/jfs.c b/libs/blkid/src/probers/jfs.c index d463f03c..6e61d94f 100644 --- a/libs/blkid/src/probers/jfs.c +++ b/libs/blkid/src/probers/jfs.c @@ -46,7 +46,9 @@ static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag) { struct jfs_super_block *js; - js = (struct jfs_super_block *) blkid_probe_get_buffer(pr, 0x8000, 0x200); + js = blkid_probe_get_sb(pr, mag, struct jfs_super_block); + if (!js) + return -1; if (le32_to_cpu(js->js_bsize) != (1 << le16_to_cpu(js->js_l2bsize))) return 1;