From: Milan Broz <mbroz@redhat.com>
To: util-linux@vger.kernel.org
Cc: dm-devel@redhat.com, Milan Broz <mbroz@redhat.com>
Subject: [PATCH] libblkid: update dm-verity scan
Date: Tue, 12 Jun 2012 13:18:02 +0200 [thread overview]
Message-ID: <1339499882-1432-1-git-send-email-mbroz@redhat.com> (raw)
In-Reply-To: <1338550448-13005-1-git-send-email-mbroz@redhat.com>
New superblock now contains UUID. Old version is not going to be used.
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
libblkid/src/superblocks/lvm.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/libblkid/src/superblocks/lvm.c b/libblkid/src/superblocks/lvm.c
index 57d2b6e..0afc773 100644
--- a/libblkid/src/superblocks/lvm.c
+++ b/libblkid/src/superblocks/lvm.c
@@ -143,31 +143,36 @@ static int probe_lvm1(blkid_probe pr, const struct blkid_idmag *mag)
return 0;
}
-#define MAX_SALT_SIZE 384
struct verity_sb {
- uint8_t signature[8];
- uint8_t version;
- uint8_t data_block_bits;
- uint8_t hash_block_bits;
- uint8_t pad1[1];
- uint16_t salt_size;
- uint8_t pad2[2];
- uint32_t data_blocks_hi;
- uint32_t data_blocks_lo;
- uint8_t algorithm[16];
- uint8_t salt[MAX_SALT_SIZE];
- uint8_t pad3[88];
+ uint8_t signature[8]; /* "verity\0\0" */
+ uint32_t version; /* superblock version */
+ uint32_t hash_type; /* 0 - Chrome OS, 1 - normal */
+ uint8_t uuid[16]; /* UUID of hash device */
+ uint8_t algorithm[32];/* hash algorithm name */
+ uint32_t data_block_size; /* data block in bytes */
+ uint32_t hash_block_size; /* hash block in bytes */
+ uint64_t data_blocks; /* number of data blocks */
+ uint16_t salt_size; /* salt size */
+ uint8_t _pad1[6];
+ uint8_t salt[256]; /* salt */
+ uint8_t _pad2[168];
} __attribute__((packed));
static int probe_verity(blkid_probe pr, const struct blkid_idmag *mag)
{
struct verity_sb *sb;
+ unsigned int version;
sb = blkid_probe_get_sb(pr, mag, struct verity_sb);
if (sb == NULL)
return -1;
- blkid_probe_sprintf_version(pr, "%u", sb->version);
+ version = le32_to_cpu(sb->version);
+ if (version != 1)
+ return 1;
+
+ blkid_probe_set_uuid(pr, sb->uuid);
+ blkid_probe_sprintf_version(pr, "%u", version);
return 0;
}
--
1.7.10
next prev parent reply other threads:[~2012-06-12 11:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 11:34 [PATCH] Add dm-verity hash device detection to blkid Milan Broz
2012-06-12 11:18 ` Milan Broz [this message]
2012-06-15 9:53 ` [PATCH] libblkid: update dm-verity scan Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339499882-1432-1-git-send-email-mbroz@redhat.com \
--to=mbroz@redhat.com \
--cc=dm-devel@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).