X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffstools.git;a=blobdiff_plain;f=libblkid-tiny%2Fubi.c;fp=libblkid-tiny%2Fubi.c;h=0739c32c6e970aa8c4207a44b1e32af4b8831bde;hp=0000000000000000000000000000000000000000;hb=98fd5b40a70dc18e56134b0b48d224698228943e;hpb=8ab4fda66a136f5b0f1e5dff9d3649961ffc9158 diff --git a/libblkid-tiny/ubi.c b/libblkid-tiny/ubi.c new file mode 100644 index 0000000..0739c32 --- /dev/null +++ b/libblkid-tiny/ubi.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2017 Rafał Miłecki + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ +#include +#include +#include +#include +#include + +#include "superblocks.h" + +struct ubi_ec_hdr { + uint32_t magic; + uint8_t version; + uint8_t padding1[3]; + uint64_t ec; + uint32_t vid_hdr_offset; + uint32_t data_offset; + uint32_t image_seq; + uint8_t padding2[32]; + uint32_t hdr_crc; +} __attribute__((packed)); + +static int probe_ubi(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct ubi_ec_hdr *hdr; + + hdr = blkid_probe_get_sb(pr, mag, struct ubi_ec_hdr); + if (!hdr) + return -1; + + blkid_probe_sprintf_version(pr, "%u", hdr->version); + blkid_probe_sprintf_uuid(pr, (unsigned char *)&hdr->image_seq, 4, "%u", + be32_to_cpu(hdr->image_seq)); + return 0; +} + +const struct blkid_idinfo ubi_idinfo = +{ + .name = "ubi", + .usage = BLKID_USAGE_RAID, + .probefunc = probe_ubi, + .magics = + { + { .magic = "UBI#", .len = 4 }, + { NULL } + } +};