Date: Mon, 9 Jul 2018 00:47:36 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336117 - projects/pnfs-planb-server/usr.bin/pnfsdskill Message-ID: <201807090047.w690laLX020028@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Mon Jul 9 00:47:36 2018 New Revision: 336117 URL: https://svnweb.freebsd.org/changeset/base/336117 Log: Add a -f/--force option to pnfsdskill, so that it disable a DS even if there is no valid mirror for it. This should only be used to facilitate shutting down of the nfsd when DSs have failed. Modified: projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c Modified: projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c ============================================================================== --- projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c Mon Jul 9 00:38:39 2018 (r336116) +++ projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c Mon Jul 9 00:47:36 2018 (r336117) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include <err.h> +#include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -44,6 +45,11 @@ __FBSDID("$FreeBSD$"); static void usage(void); +static struct option longopts[] = { + { "force", no_argument, NULL, 'f' }, + { NULL, 0, NULL, 0 } +}; + /* * This program disables use of a DS mirror. The "dspath" command line * argument must be an exact match for the mounted-on path of the DS. @@ -54,23 +60,39 @@ int main(int argc, char *argv[]) { struct nfsd_pnfsd_args pnfsdarg; + int ch, force; - if (argc != 2) - usage(); if (geteuid() != 0) errx(1, "Must be run as root/su"); + force = 0; + while ((ch = getopt_long(argc, argv, "f", longopts, NULL)) != -1) { + switch (ch) { + case 'f': + force = 1; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + if (argc != 1) + usage(); - pnfsdarg.op = PNFSDOP_DELDSSERVER; - pnfsdarg.dspath = argv[1]; + if (force != 0) + pnfsdarg.op = PNFSDOP_FORCEDELDS; + else + pnfsdarg.op = PNFSDOP_DELDSSERVER; + pnfsdarg.dspath = *argv; if (nfssvc(NFSSVC_PNFSDS, &pnfsdarg) < 0) - err(1, "Can't kill %s", argv[1]); + err(1, "Can't kill %s", *argv); } static void usage(void) { - fprintf(stderr, "pnfsdsfile [filepath]\n"); + fprintf(stderr, "pnfsdsfile [-f] mounted-on-DS-dir\n"); exit(1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807090047.w690laLX020028>