summaryrefslogtreecommitdiffstats
path: root/libblkid/src/superblocks/ubi.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:50 +0000
commit8cb83eee5a58b1fad74c34094ce3afb9e430b5a4 (patch)
treea9b2e7baeca1be40eb734371e3c8b11b02294497 /libblkid/src/superblocks/ubi.c
parentInitial commit. (diff)
downloadutil-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.tar.xz
util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.zip
Adding upstream version 2.33.1.upstream/2.33.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libblkid/src/superblocks/ubi.c')
-rw-r--r--libblkid/src/superblocks/ubi.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/libblkid/src/superblocks/ubi.c b/libblkid/src/superblocks/ubi.c
new file mode 100644
index 0000000..0739c32
--- /dev/null
+++ b/libblkid/src/superblocks/ubi.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdint.h>
+
+#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 }
+ }
+};