From cb29ce869fd3c1a1fb8703e8324cb7895a3d9b84 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 7 Jul 2017 15:47:02 -0700 Subject: [PATCH] bdev/gpt: dump partition name Change-Id: I1899a47fa9d9821c16ea648bbe3290f6306d0e3d Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/368626 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- include/spdk/gpt_spec.h | 2 +- lib/bdev/gpt/vbdev_gpt.c | 17 +++++++++++++++++ test/lib/bdev/blockdev.sh | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/spdk/gpt_spec.h b/include/spdk/gpt_spec.h index 90f6aaded..c67eb572e 100644 --- a/include/spdk/gpt_spec.h +++ b/include/spdk/gpt_spec.h @@ -135,7 +135,7 @@ struct spdk_gpt_partition_entry { uint64_t reserved_uefi : 45; uint64_t guid_specific : 16; } attr; - uint8_t partition_name[72]; + uint16_t partition_name[36]; }; SPDK_STATIC_ASSERT(sizeof(struct spdk_gpt_partition_entry) == 128, "size incorrect"); diff --git a/lib/bdev/gpt/vbdev_gpt.c b/lib/bdev/gpt/vbdev_gpt.c index f37f971d4..d8812a2d8 100644 --- a/lib/bdev/gpt/vbdev_gpt.c +++ b/lib/bdev/gpt/vbdev_gpt.c @@ -44,6 +44,7 @@ #include "spdk/io_channel.h" #include "spdk/env.h" #include "spdk/string.h" +#include "spdk/util.h" #include "spdk_internal/bdev.h" #include "spdk_internal/log.h" @@ -293,6 +294,19 @@ write_guid(struct spdk_json_write_ctx *w, const struct spdk_gpt_guid *guid) from_be32(&guid->raw[12])); } +static void +write_string_utf16le(struct spdk_json_write_ctx *w, const uint16_t *str, size_t max_len) +{ + size_t len; + const uint16_t *p; + + for (len = 0, p = str; len < max_len && *p; p++) { + len++; + } + + spdk_json_write_string_utf16le_raw(w, str, len); +} + static int vbdev_gpt_dump_config_json(void *ctx, struct spdk_json_write_ctx *w) { @@ -315,6 +329,9 @@ vbdev_gpt_dump_config_json(void *ctx, struct spdk_json_write_ctx *w) spdk_json_write_name(w, "unique_partition_guid"); write_guid(w, &gpt_entry->unique_partition_guid); + spdk_json_write_name(w, "partition_name"); + write_string_utf16le(w, gpt_entry->partition_name, SPDK_COUNTOF(gpt_entry->partition_name)); + spdk_json_write_object_end(w); return 0; diff --git a/test/lib/bdev/blockdev.sh b/test/lib/bdev/blockdev.sh index 7ffef3de9..2d37f5b1b 100755 --- a/test/lib/bdev/blockdev.sh +++ b/test/lib/bdev/blockdev.sh @@ -31,7 +31,7 @@ if [ $(uname -s) = Linux ] && [ -f /usr/sbin/sgdisk ]; then waitforbdev Nvme0n1 $rootdir/scripts/rpc.py if [ -e /dev/nbd0 ]; then - parted -s /dev/nbd0 mklabel gpt mkpart primary '0%' '50%' mkpart primary '50%' '100%' + parted -s /dev/nbd0 mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%' # change the partition type GUID to SPDK GUID value /usr/sbin/sgdisk -t 1:$SPDK_GPT_GUID /dev/nbd0 /usr/sbin/sgdisk -t 2:$SPDK_GPT_GUID /dev/nbd0