]> err.no Git - util-linux/commitdiff
blkid: add blkid_probe_get_sb() macro
authorKarel Zak <kzak@redhat.com>
Thu, 18 Sep 2008 11:15:21 +0000 (13:15 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:21:45 +0000 (23:21 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/src/blkidP.h
libs/blkid/src/probers/cramfs.c
libs/blkid/src/probers/jfs.c

index 56e569f3e3519b8a449e7e2202a617f823d088dd..e32d7dcded86e03e789861c4bb2f05ebad138ec1 100644 (file)
@@ -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,
index 33b6566feb9edae4a1213676f0d8fb9eaf8f769d..caf13881fb9e27b533b89cd93d1ab5a0e4bb5a34 100644 (file)
@@ -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));
index d463f03c2249fad72523e3e1a8f3228886e663ce..6e61d94fc287e12e62e95e8d573078db1b71b5a3 100644 (file)
@@ -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;