]> www.infradead.org Git - users/dhowells/kafs-utils.git/commitdiff
Implement "vos listpart"
authorDavid Howells <dhowells@redhat.com>
Thu, 13 Aug 2020 13:19:52 +0000 (14:19 +0100)
committerDavid Howells <dhowells@redhat.com>
Fri, 5 May 2023 10:53:26 +0000 (11:53 +0100)
Signed-off-by: David Howells <dhowells@redhat.com>
kafs/Makefile
kafs/vos_listpart.C [new file with mode: 0644]

index 6c0d3928e94e436b873a276cf11616557ce012bc..9bbd49ecd5f80c822b8281caee91edf941bda15d 100644 (file)
@@ -35,6 +35,7 @@ VOS_SRCS := \
        vos_examine.C \
        vos_help.C \
        vos_listaddrs.C \
+       vos_listpart.C \
        vos_listvldb.C \
        vos_listvol.C \
        vos_status.C
diff --git a/kafs/vos_listpart.C b/kafs/vos_listpart.C
new file mode 100644 (file)
index 0000000..43e0c6d
--- /dev/null
@@ -0,0 +1,64 @@
+/* The "vos listpart" 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 "volservice.H"
+#include "arg_parse.H"
+#include "display.H"
+#include "afs_xg.H"
+
+using rxrpc::ref;
+
+/***
+ * COMMAND: vos listpart - Display all AFS partitions on a file server machine
+ * ARG: "-server <machine name>"
+ * ARG: "[-cell <cell name>]"
+ * ARG: "[-noauth]"                            - Auth
+ * ARG: "[-localauth]"                         - Auth
+ * ARG: "[-verbose]"
+ * ARG: "[-encrypt]"                           - Auth
+ * ARG: "[-noresolve]"
+ *
+ * Displays all AFS partitions on a file server machine
+ */
+void COMMAND_vos_listpart(
+       kafs::Context                   *ctx,
+       kafs::Volserver_spec            &a_server,
+       bool                            a_verbose,
+       bool                            a_noresolve)
+{
+       kafs::Partition_list partitions;
+       ref<kafs::Volserver> server;
+       ref<kafs::FS_site> site;
+       unsigned int i, n;
+
+       _enter("");
+
+       ctx->no_resolve = a_noresolve;
+
+       site = kafs::resolve_server_spec(ctx, a_server);
+       server = new kafs::Volserver(ctx, site);
+       server->list_partitions(partitions);
+
+       fmt::print("The partitions on the server are:\n");
+
+       n = 0;
+       for (i = 0; i < partitions.size(); i++) {
+               if (partitions[i].id != 0xffffffff) {
+                       fmt::print("    {}", kafs::sprint_partition(partitions[i]));
+                       n++;
+               }
+       }
+
+       fmt::print("\n");
+       fmt::print("Total: {:d}\n", n);
+}