• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/fstools/libblkid-tiny/ubi.c

  1 /*
  2  * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
  3  *
  4  * This file may be redistributed under the terms of the
  5  * GNU Lesser General Public License.
  6  */
  7 #include <stdio.h>
  8 #include <stdlib.h>
  9 #include <unistd.h>
 10 #include <string.h>
 11 #include <stdint.h>
 12 
 13 #include "superblocks.h"
 14 
 15 struct ubi_ec_hdr {
 16         uint32_t        magic;
 17         uint8_t         version;
 18         uint8_t         padding1[3];
 19         uint64_t        ec;
 20         uint32_t        vid_hdr_offset;
 21         uint32_t        data_offset;
 22         uint32_t        image_seq;
 23         uint8_t         padding2[32];
 24         uint32_t        hdr_crc;
 25 } __attribute__((packed));
 26 
 27 static int probe_ubi(blkid_probe pr, const struct blkid_idmag *mag)
 28 {
 29         struct ubi_ec_hdr *hdr;
 30 
 31         hdr = blkid_probe_get_sb(pr, mag, struct ubi_ec_hdr);
 32         if (!hdr)
 33                 return -1;
 34 
 35         blkid_probe_sprintf_version(pr, "%u", hdr->version);
 36         blkid_probe_sprintf_uuid(pr, (unsigned char *)&hdr->image_seq, 4, "%u",
 37                                  be32_to_cpu(hdr->image_seq));
 38         return 0;
 39 }
 40 
 41 const struct blkid_idinfo ubi_idinfo =
 42 {
 43         .name           = "ubi",
 44         .usage          = BLKID_USAGE_RAID,
 45         .probefunc      = probe_ubi,
 46         .magics         =
 47         {
 48                 { .magic = "UBI#", .len = 4 },
 49                 { NULL }
 50         }
 51 };
 52 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt