1177633Sdfr/*- 2177633Sdfr * Copyright (c) 2008 Isilon Inc http://www.isilon.com/ 3177633Sdfr * Authors: Doug Rabson <dfr@rabson.org> 4177633Sdfr * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org> 5177633Sdfr * 6177633Sdfr * Redistribution and use in source and binary forms, with or without 7177633Sdfr * modification, are permitted provided that the following conditions 8177633Sdfr * are met: 9177633Sdfr * 1. Redistributions of source code must retain the above copyright 10177633Sdfr * notice, this list of conditions and the following disclaimer. 11177633Sdfr * 2. Redistributions in binary form must reproduce the above copyright 12177633Sdfr * notice, this list of conditions and the following disclaimer in the 13177633Sdfr * documentation and/or other materials provided with the distribution. 14177633Sdfr * 15177633Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16177633Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17177633Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18177633Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19177633Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20177633Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21177633Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22177633Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23177633Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24177633Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25177633Sdfr * SUCH DAMAGE. 26177633Sdfr */ 27177633Sdfr 28177633Sdfr#include <sys/cdefs.h> 29177633Sdfr__FBSDID("$FreeBSD$"); 30177633Sdfr 31177633Sdfr#include <stdio.h> 32177633Sdfr#include <stdlib.h> 33177633Sdfr#include <unistd.h> 34177633Sdfr 35177633Sdfr#include <rpc/rpc.h> 36177633Sdfr#include <rpcsvc/nlm_prot.h> 37177633Sdfr 38177633Sdfrint 39177633Sdfrmain(int argc, char **argv) 40177633Sdfr{ 41177633Sdfr enum clnt_stat stat; 42177633Sdfr char *hostname; 43177633Sdfr nlm4_notify notify; 44177633Sdfr 45177633Sdfr if (argc != 2) { 46177633Sdfr fprintf(stderr, "Usage: clear_locks <hostname>\n"); 47177633Sdfr exit(1); 48177633Sdfr } 49177633Sdfr hostname = argv[1]; 50177633Sdfr 51177633Sdfr if (geteuid() != 0) { 52177633Sdfr fprintf(stderr, "clear_locks: must be root\n"); 53177633Sdfr exit(1); 54177633Sdfr } 55177633Sdfr 56177633Sdfr notify.name = hostname; 57177633Sdfr notify.state = 0; 58177633Sdfr stat = rpc_call("localhost", NLM_PROG, NLM_VERS4, NLM4_FREE_ALL, 59177633Sdfr (xdrproc_t) xdr_nlm4_notify, (void *) ¬ify, 60177633Sdfr (xdrproc_t) xdr_void, NULL, NULL); 61177633Sdfr 62177633Sdfr if (stat != RPC_SUCCESS) { 63177633Sdfr clnt_perrno(stat); 64177633Sdfr exit(1); 65177633Sdfr } 66177633Sdfr fprintf(stderr, "clear_locks: cleared locks for hostname %s\n", 67177633Sdfr hostname); 68177633Sdfr 69177633Sdfr return (0); 70177633Sdfr} 71