]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/stat.c
NFS man page: update nfs(5) with details about IPv6 support
[nfs-utils.git] / utils / statd / stat.c
1 /*
2  * Copyright (C) 1995, 1997, 1999 Jeffrey A. Uphoff
3  * Modified by Olaf Kirch, 1996.
4  *
5  * NSM for Linux.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #include <netdb.h>
13 #include "statd.h"
14
15 /* 
16  * Services SM_STAT requests.
17  *
18  * According the the X/Open spec's on this procedure: "Implementations
19  * should not rely on this procedure being operative.  In many current
20  * implementations of the NSM it will always return a 'STAT_FAIL'
21  * status."  My implementation is operative; it returns 'STAT_SUCC'
22  * whenever it can resolve the hostname that it's being asked to
23  * monitor, and returns 'STAT_FAIL' otherwise.
24  *
25  * sm_inter.x says the 'state' returned should be
26  *   "state number of site sm_name".  It is not clear how to get this.
27  * X/Open says:
28  *   STAT_SUCC
29  *      The NSM will monitor the given host. "sm_stat_res.state" contains
30  *      the state of the NSM.
31  * Which implies that 'state' is the state number of the *local* NSM.
32  * href=http://www.opengroup.org/onlinepubs/9629799/SM_STAT.htm
33  *
34  * We return the *local* state as
35  *   1/ We have easy access to it.
36  *   2/ It might be useful to a remote client who needs it and has no
37  *      other way to get it.
38  *   3/ That's what we always did in the past.
39  */
40 struct sm_stat_res * 
41 sm_stat_1_svc (struct sm_name *argp, struct svc_req *rqstp)
42 {
43   static sm_stat_res result;
44
45   xlog(D_CALL, "Received SM_STAT from %s", argp->mon_name);
46
47   if (gethostbyname (argp->mon_name) == NULL) {
48     xlog_warn ("gethostbyname error for %s", argp->mon_name);
49     result.res_stat = STAT_FAIL;
50     xlog (D_GENERAL, "STAT_FAIL for %s", argp->mon_name);
51   } else {
52     result.res_stat = STAT_SUCC;
53     xlog (D_GENERAL, "STAT_SUCC for %s", argp->mon_name);
54   }
55   result.state = MY_STATE;
56   return(&result);
57 }