|
22 | 22 | #include <gpt/gpt.h>
|
23 | 23 | #include <gpt/guid.h>
|
24 | 24 |
|
| 25 | +#include "src/lib/storage/block_client/cpp/remote_block_device.h" |
| 26 | + |
25 | 27 | using gpt::GptDevice;
|
26 | 28 | using gpt::GuidProperties;
|
27 | 29 | using gpt::KnownGuid;
|
@@ -114,7 +116,7 @@ char* FlagsToCString(char* dst, size_t dst_len, const uint8_t* guid, uint64_t fl
|
114 | 116 | }
|
115 | 117 |
|
116 | 118 | std::unique_ptr<GptDevice> Init(const char* dev) {
|
117 |
| - zx::result block = component::Connect<fuchsia_hardware_block::Block>(dev); |
| 119 | + zx::result block = component::Connect<fuchsia_hardware_block_volume::Volume>(dev); |
118 | 120 | if (block.is_error()) {
|
119 | 121 | fprintf(stderr, "gpt: error opening %s: %s\n", dev, block.status_string());
|
120 | 122 | return nullptr;
|
@@ -144,9 +146,14 @@ std::unique_ptr<GptDevice> Init(const char* dev) {
|
144 | 146 | return nullptr;
|
145 | 147 | }
|
146 | 148 |
|
| 149 | + auto device = block_client::RemoteBlockDevice::Create(std::move(block.value())); |
| 150 | + if (device.is_error()) { |
| 151 | + fprintf(stderr, "Failed to create block client: %s\n", device.status_string()); |
| 152 | + return nullptr; |
| 153 | + } |
147 | 154 | std::unique_ptr<GptDevice> gpt;
|
148 | 155 | if (zx_status_t status =
|
149 |
| - GptDevice::Create(std::move(block.value()), std::move(controller.value()), |
| 156 | + GptDevice::Create(std::move(device.value()), std::move(controller.value()), |
150 | 157 | info.block_size, info.block_count, &gpt);
|
151 | 158 | status != ZX_OK) {
|
152 | 159 | fprintf(stderr, "gpt: error initializing GPT from %s: %s\n", dev, zx_status_get_string(status));
|
@@ -262,10 +269,8 @@ zx_status_t Commit(GptDevice* gpt, const char* dev) {
|
262 | 269 | return status;
|
263 | 270 | }
|
264 | 271 |
|
265 |
| - // TODO(https://fxbug.dev/112484): this relies on multiplexing. |
266 |
| - const fidl::WireResult result = fidl::WireCall(fidl::UnownedClientEnd<fuchsia_device::Controller>( |
267 |
| - gpt->device().channel().borrow())) |
268 |
| - ->Rebind({}); |
| 272 | + fidl::UnownedClientEnd<fuchsia_device::Controller> controller = gpt->device().Controller(); |
| 273 | + const fidl::WireResult result = fidl::WireCall(controller)->Rebind({}); |
269 | 274 | if (!result.ok()) {
|
270 | 275 | fprintf(stderr, "gpt: gpt updated but device %s could not be rebound: %s. Please reboot.\n",
|
271 | 276 | dev, result.FormatDescription().c_str());
|
@@ -313,7 +318,7 @@ zx_status_t AddPartition(const char* dev, uint64_t start, uint64_t end, const ch
|
313 | 318 |
|
314 | 319 | uint8_t type[GPT_GUID_LEN];
|
315 | 320 | memset(type, 0xff, GPT_GUID_LEN);
|
316 |
| - zx_status_t rc = gpt->AddPartition(name, type, guid, start, end - start + 1, 0); |
| 321 | + zx_status_t rc = gpt->AddPartition(name, type, guid, start, end - start + 1, 0).status_value(); |
317 | 322 | if (rc != ZX_OK) {
|
318 | 323 | fprintf(stderr, "Add partition failed: %s\n", zx_status_get_string(rc));
|
319 | 324 | return rc;
|
@@ -719,7 +724,7 @@ zx_status_t Repartition(int argc, char** argv, std::optional<PartitionScheme> sc
|
719 | 724 |
|
720 | 725 | printf("%s: %" PRIu64 " bytes, %" PRIu64 " blocks, %" PRIu64 "-%" PRIu64 "\n", name,
|
721 | 726 | byte_size, nblocks, start, end);
|
722 |
| - ZX_ASSERT(gpt->AddPartition(name, type, guid, start, end - start, 0) == ZX_OK); |
| 727 | + ZX_ASSERT(gpt->AddPartition(name, type, guid, start, end - start, 0).status_value() == ZX_OK); |
723 | 728 |
|
724 | 729 | start = end + 1;
|
725 | 730 | }
|
|
0 commit comments