2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2017 Rick Macklem
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
38 #include <arpa/inet.h>
39 #include <netinet/in.h>
40 #include <nfs/nfssvc.h>
42 #include <fs/nfs/nfsproto.h>
43 #include <fs/nfs/nfskpiport.h>
44 #include <fs/nfs/nfs.h>
46 static void usage(void);
48 static struct option longopts[] = {
49 { "force", no_argument, NULL, 'f' },
54 * This program disables use of a DS mirror. The "dspath" command line
55 * argument must be an exact match for the mounted-on path of the DS.
56 * It should be done before any forced dismount is performed on the path
57 * and should work even when the mount point is hung.
60 main(int argc, char *argv[])
62 struct nfsd_pnfsd_args pnfsdarg;
66 errx(1, "Must be run as root/su");
68 while ((ch = getopt_long(argc, argv, "f", longopts, NULL)) != -1) {
83 pnfsdarg.op = PNFSDOP_FORCEDELDS;
85 pnfsdarg.op = PNFSDOP_DELDSSERVER;
86 pnfsdarg.dspath = *argv;
87 if (nfssvc(NFSSVC_PNFSDS, &pnfsdarg) < 0)
88 err(1, "Can't kill %s", *argv);
95 fprintf(stderr, "pnfsdsfile [-f] mounted-on-DS-dir\n");