--- /dev/null
+/* The "vos listaddrs" command
+ *
+ * Copyright (C) 2020 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#include <fmt/core.h>
+#include "kafs.H"
+#include "vlservice.H"
+#include "arg_parse.H"
+#include "display.H"
+#include "afs_xg.H"
+
+using rxrpc::ref;
+
+static void vos_listaddrs_one(kafs::Context *ctx,
+ bool a_printuuid,
+ kafs::FS_site *site)
+{
+ char buf[1024];
+ unsigned int i;
+
+ if (a_printuuid) {
+ uuid_unparse(site->uuid.uuid, buf);
+ fmt::print("UUID: {}\n", buf);
+ }
+
+ for (i = 0; i < site->vs_addrs.size(); i++)
+ fmt::print("{}\n", kafs::sprint_address(ctx, site->vs_addrs[i]));
+
+ if (a_printuuid)
+ fmt::print("\n");
+}
+
+static void vos_listaddrs_all(kafs::Context *ctx,
+ kafs::VL_service *vlservice,
+ bool a_printuuid)
+{
+ kafs::afs::VL_Callback vl_callback;
+ std::vector<uint32_t> blkaddr;
+ int32_t nentries;
+ unsigned int i;
+ int found;
+
+ kafs::afs::VL::GetAddrs(&vlservice->vl_params, 0, 0, vl_callback, nentries, blkaddr);
+
+ found = nentries;
+ for (i = 1; i < 65536; i++) {
+ ref<kafs::FS_site> site;
+
+ try {
+ site = vlservice->look_up_fileserver_by_index(i);
+ } catch (const kafs::afs::VL::AbortVL_NOENT &) {
+ continue;
+ } catch (const kafs::afs::VL::AbortVL_INDEXERANGE &) {
+ return;
+ }
+
+ vos_listaddrs_one(ctx, a_printuuid, site);
+ found--;
+ if (found <= 0)
+ break;
+ }
+}
+
+/***
+ * COMMAND: vos listaddrs - List all of the file server registrations.
+ * ARG: "[-uuid <uuid of server>]"
+ * ARG: "[-host <address of host>]"
+ * ARG: "[-printuuid]"
+ * ARG: "[-cell <cell name>]"
+ * ARG: "[-noauth]" - Auth
+ * ARG: "[-localauth]" - Auth
+ * ARG: "[-verbose]"
+ * ARG: "[-encrypt]" - Auth
+ * ARG: "[-noresolve]"
+ * NOCOMBINE: uuid, host
+ *
+ * Display a list of registered volume servers.
+ */
+void COMMAND_vos_listaddrs(
+ kafs::Context *ctx,
+ kafs::Uuid_spec &a_uuid,
+ kafs::Fileserver_spec &a_host,
+ bool a_printuuid,
+ bool a_quiet,
+ bool a_nosort,
+ bool a_verbose,
+ bool a_noresolve)
+{
+ ref<kafs::FS_site> server, spec;
+
+ _enter("");
+
+ ctx->no_resolve = a_noresolve;
+
+ ref<kafs::VL_service> vlservice = new kafs::VL_service(ctx);
+
+ if (!a_uuid.specified && !a_host.specified)
+ return vos_listaddrs_all(ctx, vlservice, a_printuuid);
+
+ if (a_uuid.specified) {
+ server = vlservice->look_up_fileserver_by_uuid(a_uuid.uuid);
+ } else {
+ spec = kafs::resolve_server_spec(ctx, a_host);
+ server = vlservice->look_up_fileserver_by_addr(spec->fs_addrs[0]);
+ }
+
+ if (server)
+ vos_listaddrs_one(ctx, a_printuuid, server);
+}
+
+/***
+ * ALIAS: vos listfs - listaddrs
+ */