#define read_unaligned_member(p, m) __extension__ ({ \
size_t offset = offsetof(__typeof__(* p), m); \
- __typeof__(p->m) v; \
+ __typeof__(p->m + 0) v; \
memcpy(&v, ((unsigned char *)p) + offset, sizeof(v)); \
v; })
/* returns superblock according to 'struct blkid_idmag' */
extern const unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr, const struct blkid_idmag *mag, size_t size);
#define blkid_probe_get_sb(_pr, _mag, type) \
- ((type *) blkid_probe_get_sb_buffer((_pr), _mag, sizeof(type)))
+ ((const type *) blkid_probe_get_sb_buffer((_pr), _mag, sizeof(type)))
extern uint64_t blkid_probe_get_idmag_off(blkid_probe pr, const struct blkid_idmag *mag)
__attribute__((nonnull));
static int probe_apfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct apfs_super_block *sb;
+ const struct apfs_super_block *sb;
sb = blkid_probe_get_sb(pr, mag, struct apfs_super_block);
if (!sb)
static int probe_bcache (blkid_probe pr, const struct blkid_idmag *mag)
{
- struct bcache_super_block *bcs;
+ const struct bcache_super_block *bcs;
bcs = blkid_probe_get_sb(pr, mag, struct bcache_super_block);
if (!bcs)
static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct bcachefs_super_block *bcs;
+ const struct bcachefs_super_block *bcs;
const unsigned char *sb, *sb_end;
uint64_t sb_size, blocksize, offset_sectors;
uint16_t version;
static int probe_bluestore(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct bluestore_phdr *header;
+ const struct bluestore_phdr *header;
header = blkid_probe_get_sb(pr, mag, struct bluestore_phdr);
if (header == NULL)
static int probe_btrfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct btrfs_super_block *bfs;
+ const struct btrfs_super_block *bfs;
if (pr->zone_size) {
#ifdef HAVE_LINUX_BLKZONED_H
}
static int cramfs_verify_csum(blkid_probe pr, const struct blkid_idmag *mag,
- struct cramfs_super *cs, int le)
+ const struct cramfs_super *cs, int le)
{
uint32_t crc, expected, csummed_size;
const unsigned char *csummed;
static int probe_cramfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct cramfs_super *cs;
+ const struct cramfs_super *cs;
cs = blkid_probe_get_sb(pr, mag, struct cramfs_super);
if (!cs)
static int probe_cs_fvault2(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct cs_fvault2_sb *sb;
+ const struct cs_fvault2_sb *sb;
sb = blkid_probe_get_sb(pr, mag, struct cs_fvault2_sb);
if (!sb)
static int probe_drbd_84(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct md_on_disk_08 *md;
+ const struct md_on_disk_08 *md;
md = blkid_probe_get_sb(pr, mag, struct md_on_disk_08);
if (!md)
static int probe_drbd_90(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct meta_data_on_disk_9 *md;
+ const struct meta_data_on_disk_9 *md;
md = blkid_probe_get_sb(pr, mag, struct meta_data_on_disk_9);
if (!md)
static int probe_erofs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct erofs_super_block *sb;
+ const struct erofs_super_block *sb;
sb = blkid_probe_get_sb(pr, mag, struct erofs_super_block);
if (!sb)
*/
int blkid_probe_is_exfat(blkid_probe pr)
{
- struct exfat_super_block *sb;
+ const struct exfat_super_block *sb;
const struct blkid_idmag *mag = NULL;
int rc;
static int probe_exfat(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct exfat_super_block *sb;
+ const struct exfat_super_block *sb;
struct exfat_entry_label *label;
sb = blkid_probe_get_sb(pr, mag, struct exfat_super_block);
(s)->sb_agblocks + EXFS_MIN_AG_BLOCKS)
-static void sb_from_disk(struct exfs_super_block *from,
+static void sb_from_disk(const struct exfs_super_block *from,
struct exfs_super_block *to)
{
to->sb_frextents = be64_to_cpu(from->sb_frextents);
}
-static int exfs_verify_sb(struct exfs_super_block *ondisk)
+static int exfs_verify_sb(const struct exfs_super_block *ondisk)
{
struct exfs_super_block sb, *sbp = &sb;
static int probe_exfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct exfs_super_block *xs;
+ const struct exfs_super_block *xs;
xs = blkid_probe_get_sb(pr, mag, struct exfs_super_block);
if (!xs)
static int probe_f2fs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct f2fs_super_block *sb;
+ const struct f2fs_super_block *sb;
uint16_t vermaj, vermin;
sb = blkid_probe_get_sb(pr, mag, struct f2fs_super_block);
static int probe_gfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct gfs2_sb *sbd;
+ const struct gfs2_sb *sbd;
sbd = blkid_probe_get_sb(pr, mag, struct gfs2_sb);
if (!sbd)
static int probe_gfs2(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct gfs2_sb *sbd;
+ const struct gfs2_sb *sbd;
sbd = blkid_probe_get_sb(pr, mag, struct gfs2_sb);
if (!sbd)
static int probe_hfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct hfs_mdb *hfs;
+ const struct hfs_mdb *hfs;
int size;
hfs = blkid_probe_get_sb(pr, mag, struct hfs_mdb);
static int probe_hpfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct hpfs_super_block *hs;
- struct hpfs_spare_super *hss;
- struct hpfs_boot_block *hbb;
+ const struct hpfs_super_block *hs;
+ const struct hpfs_spare_super *hss;
+ const struct hpfs_boot_block *hbb;
uint8_t version;
/* super block */
static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct jfs_super_block *js;
+ const struct jfs_super_block *js;
js = blkid_probe_get_sb(pr, mag, struct jfs_super_block);
if (!js)
static int probe_lvm1(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct lvm1_pv_label_header *label;
+ const struct lvm1_pv_label_header *label;
char uuid[LVM2_ID_LEN + 7];
unsigned int version;
static int probe_verity(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct verity_sb *sb;
+ const struct verity_sb *sb;
unsigned int version;
sb = blkid_probe_get_sb(pr, mag, struct verity_sb);
static int probe_integrity(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct integrity_sb *sb;
+ const struct integrity_sb *sb;
sb = blkid_probe_get_sb(pr, mag, struct integrity_sb);
if (sb == NULL)
static int probe_mpool(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct omf_sb_descriptor *osd;
+ const struct omf_sb_descriptor *osd;
uint32_t sb_crc;
osd = blkid_probe_get_sb(pr, mag, struct omf_sb_descriptor);
static int probe_netware(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct netware_super_block *nw;
+ const struct netware_super_block *nw;
nw = blkid_probe_get_sb(pr, mag, struct netware_super_block);
if (!nw)
static int probe_ocfs2(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct ocfs2_super_block *osb;
+ const struct ocfs2_super_block *osb;
osb = blkid_probe_get_sb(pr, mag, struct ocfs2_super_block);
if (!osb)
static int probe_oracleasm(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct oracle_asm_disk_label *dl;
+ const struct oracle_asm_disk_label *dl;
dl = blkid_probe_get_sb(pr, mag, struct oracle_asm_disk_label);
if (!dl)
static int probe_reiser(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct reiserfs_super_block *rs;
+ const struct reiserfs_super_block *rs;
unsigned int blocksize;
rs = blkid_probe_get_sb(pr, mag, struct reiserfs_super_block);
static int probe_reiser4(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct reiser4_super_block *rs4;
+ const struct reiser4_super_block *rs4;
unsigned int blocksize;
rs4 = blkid_probe_get_sb(pr, mag, struct reiser4_super_block);
static int probe_romfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct romfs_super_block *ros;
+ const struct romfs_super_block *ros;
ros = blkid_probe_get_sb(pr, mag, struct romfs_super_block);
if (!ros)
static int probe_squashfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct sqsh_super_block *sq;
+ const struct sqsh_super_block *sq;
uint16_t vermaj;
uint16_t vermin;
static int probe_squashfs3(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct sqsh_super_block *sq;
+ const struct sqsh_super_block *sq;
uint16_t vermaj;
uint16_t vermin;
enum blkid_endianness endianness;
static int probe_xenix(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct xenix_super_block *sb;
+ const struct xenix_super_block *sb;
sb = blkid_probe_get_sb(pr, mag, struct xenix_super_block);
if (!sb)
static int probe_ubi(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct ubi_ec_hdr *hdr;
+ const struct ubi_ec_hdr *hdr;
hdr = blkid_probe_get_sb(pr, mag, struct ubi_ec_hdr);
if (!hdr)
static int probe_ubifs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct ubifs_sb_node *sb;
+ const struct ubifs_sb_node *sb;
sb = blkid_probe_get_sb(pr, mag, struct ubifs_sb_node);
if (!sb)
static int probe_vdo(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct vdo_super_block *vsb;
+ const struct vdo_super_block *vsb;
vsb = blkid_probe_get_sb(pr, mag, struct vdo_super_block);
if (!vsb)
static int fat_valid_superblock(blkid_probe pr,
const struct blkid_idmag *mag,
- struct msdos_super_block *ms,
- struct vfat_super_block *vs,
+ const struct msdos_super_block *ms,
+ const struct vfat_super_block *vs,
uint32_t *cluster_count, uint32_t *fat_size,
uint32_t *sect_count)
{
*/
int blkid_probe_is_vfat(blkid_probe pr)
{
- struct vfat_super_block *vs;
- struct msdos_super_block *ms;
+ const struct vfat_super_block *vs;
+ const struct msdos_super_block *ms;
const struct blkid_idmag *mag = NULL;
int rc;
* Sievers's volume_id library */
static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct vfat_super_block *vs;
- struct msdos_super_block *ms;
+ const struct vfat_super_block *vs;
+ const struct msdos_super_block *ms;
const unsigned char *vol_label = NULL;
const unsigned char *boot_label = NULL;
- unsigned char *vol_serno = NULL, vol_label_buf[11];
+ const unsigned char *vol_serno = NULL;
+ unsigned char vol_label_buf[11];
uint16_t sector_size = 0, reserved;
uint32_t cluster_count, fat_size, sect_count;
const char *version = NULL;
static int probe_vmfs_fs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct vmfs_fs_info *header;
+ const struct vmfs_fs_info *header;
header = blkid_probe_get_sb(pr, mag, struct vmfs_fs_info);
if (header == NULL)
static int probe_vmfs_volume(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct vmfs_volume_info *header;
+ const struct vmfs_volume_info *header;
const unsigned char *lvm_uuid;
header = blkid_probe_get_sb(pr, mag, struct vmfs_volume_info);
static int probe_vxfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct vxfs_super_block *vxs;
+ const struct vxfs_super_block *vxs;
enum blkid_endianness e = mag->hint;
vxs = blkid_probe_get_sb(pr, mag, struct vxfs_super_block);
#define XFS_SB_VERSION2_CRCBIT 0x00000100
-static void sb_from_disk(struct xfs_super_block *from,
+static void sb_from_disk(const struct xfs_super_block *from,
struct xfs_super_block *to)
{
to->sb_rrmapino = be64_to_cpu(from->sb_rrmapino);
}
-static int xfs_verify_sb(struct xfs_super_block *ondisk, blkid_probe pr,
+static int xfs_verify_sb(const struct xfs_super_block *ondisk, blkid_probe pr,
const struct blkid_idmag *mag)
{
struct xfs_super_block sb, *sbp = &sb;
return 1;
}
-static uint64_t xfs_fssize(struct xfs_super_block *xs)
+static uint64_t xfs_fssize(const struct xfs_super_block *xs)
{
uint32_t lsize = xs->sb_logstart ? xs->sb_logblocks : 0;
uint64_t avail_blocks = be64_to_cpu(xs->sb_dblocks) - be32_to_cpu(lsize);
static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
{
- struct xfs_super_block *xs;
+ const struct xfs_super_block *xs;
xs = blkid_probe_get_sb(pr, mag, struct xfs_super_block);
if (!xs)