From c744828b0782557eb8db313cbac45fb110c3bba9 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 13 Aug 2020 14:19:52 +0100 Subject: [PATCH] Implement "vos listpart" Signed-off-by: David Howells --- kafs/Makefile | 1 + kafs/vos_listpart.C | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 kafs/vos_listpart.C diff --git a/kafs/Makefile b/kafs/Makefile index 6c0d392..9bbd49e 100644 --- a/kafs/Makefile +++ b/kafs/Makefile @@ -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 index 0000000..43e0c6d --- /dev/null +++ b/kafs/vos_listpart.C @@ -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 +#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 " + * ARG: "[-cell ]" + * 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 server; + ref 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); +} -- 2.50.1