/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
+#include <roken.h>
-
-#include <string.h>
-
-#include <fsprobe.h> /*Interface for this module */
#include <lwp.h> /*Lightweight process package */
#include <afs/cellconfig.h>
#include <afs/afsint.h>
#include <afs/afsutil.h>
-
+#include <afs/volser.h>
+#include <afs/volser_prototypes.h>
#define FSINT_COMMON_XG
#include <afs/afscbint.h>
+#include "fsprobe.h" /*Interface for this module */
+
#define LWP_STACK_SIZE (16 * 1024)
/*
static int fsprobe_statsBytes; /*Num bytes in stats block */
static int fsprobe_probeOKBytes; /*Num bytes in probeOK block */
-/*
- * We have to pass a port to Rx to start up our callback listener
- * service, but 7001 is already taken up by the Cache Manager. So,
- * we make up our own.
- */
-#define FSPROBE_CBPORT 7101
-
-
/*------------------------------------------------------------------------
* [private] fsprobe_CleanupInit
*
{ /*fsprobe_LWP */
static char rn[] = "fsprobe_LWP"; /*Routine name */
- register afs_int32 code; /*Results of calls */
+ afs_int32 code; /*Results of calls */
struct timeval tv; /*Time structure */
int conn_idx; /*Connection index */
struct fsprobe_ConnectionInfo *curr_conn; /*Current connection */
struct ProbeViceStatistics *curr_stats; /*Current stats region */
int *curr_probeOK; /*Current probeOK field */
ViceStatistics64 stats64; /*Current stats region */
- stats64.ViceStatistics64_val = (afs_uint64 *)malloc(STATS64_VERSION *
- sizeof(afs_uint64));
+ stats64.ViceStatistics64_val = malloc(STATS64_VERSION *
+ sizeof(afs_uint64));
while (1) { /*Service loop */
/*
* Iterate through the server connections, gathering data.
char pname[10];
struct diskPartition partition;
struct diskPartition64 *partition64p =
- (struct diskPartition64 *)malloc(sizeof(struct diskPartition64));
+ malloc(sizeof(struct diskPartition64));
if (fsprobe_debug)
fprintf(stderr,
strcpy(curr_stats->Disk[i].Name, pname);
}
if (code == RXGEN_OPCODE) {
- code =
- AFSVolPartitionInfo(curr_conn->rxVolconn,
+ code =
+ AFSVolPartitionInfo(curr_conn->rxVolconn,
pname, &partition);
if (!code) {
curr_stats->Disk[i].BlocksAvailable =
if (code)
fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn, code);
} /*Service loop */
- free(stats64.ViceStatistics64_val);
-
- return NULL;
+ AFS_UNREACHED(free(stats64.ViceStatistics64_val));
+ AFS_UNREACHED(return(NULL));
} /*fsprobe_LWP */
/*list all the partitions on <aserver> */
{
struct pIDs partIds;
struct partEntries partEnts;
- register int i, j = 0, code;
+ int i, j = 0, code;
*cntp = 0;
if (newvolserver == 1) {
*------------------------------------------------------------------------*/
int
-fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
+fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
int a_ProbeFreqInSecs, int (*a_ProbeHandler)(void),
int a_debug)
{ /*fsprobe_Init */
static char rn[] = "fsprobe_Init"; /*Routine name */
- register afs_int32 code; /*Return value */
+ afs_int32 code; /*Return value */
static struct rx_securityClass *CBsecobj; /*Callback security object */
struct rx_securityClass *secobj; /*Client security object */
struct rx_service *rxsrv_afsserver; /*Server for AFS */
struct fsprobe_ConnectionInfo *curr_conn; /*Ptr to current conn */
char *hostNameFound; /*Ptr to returned host name */
int conn_err; /*Connection error? */
- int PortToUse; /*Callback port to use */
/*
* If we've already been called, snicker at the bozo, gently
malloc(a_numServers * sizeof(struct fsprobe_ConnectionInfo));
if (fsprobe_ConnInfo == (struct fsprobe_ConnectionInfo *)0) {
fprintf(stderr,
- "[%s] Can't allocate %d connection info structs (%lu bytes)\n",
+ "[%s] Can't allocate %d connection info structs (%"AFS_SIZET_FMT" bytes)\n",
rn, a_numServers,
(a_numServers * sizeof(struct fsprobe_ConnectionInfo)));
return (-1); /*No cleanup needs to be done yet */
rn, fsprobe_statsBytes);
fsprobe_probeOKBytes = a_numServers * sizeof(int);
- fsprobe_Results.probeOK = (int *)malloc(fsprobe_probeOKBytes);
+ fsprobe_Results.probeOK = malloc(fsprobe_probeOKBytes);
if (fsprobe_Results.probeOK == (int *)0) {
fprintf(stderr,
"[%s] Can't allocate %d probeOK array entries (%d bytes)\n",
*/
if (fsprobe_debug)
fprintf(stderr, "[%s] Initializing Rx\n", rn);
- PortToUse = FSPROBE_CBPORT;
- do {
- code = rx_Init(htons(PortToUse));
- if (code) {
- if (code == RX_ADDRINUSE) {
- if (fsprobe_debug)
- fprintf(stderr,
- "[%s] Callback port %d in use, advancing\n", rn,
- PortToUse);
- PortToUse++;
- } else {
- fprintf(stderr, "[%s] Fatal error in rx_Init()\n", rn);
- return (-1);
- }
- }
- } while (code);
+ code = rx_Init(0);
+ if (code) {
+ fprintf(stderr, "[%s] Fatal error in rx_Init()\n", rn);
+ return (-1);
+ }
if (fsprobe_debug)
- fprintf(stderr, "[%s] Rx initialized on port %d\n", rn, PortToUse);
+ fprintf(stderr, "[%s] Rx initialized.\n", rn);
/*
* Create a null Rx server security object, to be used by the
return (0);
} /*fsprobe_ForceProbeNow */
+
+/*------------------------------------------------------------------------
+ * [exported] fsprobe_Wait
+ *
+ * Description:
+ * Wait for the collection to complete.
+ *
+ * Arguments:
+ * int sleep_secs : time to wait in seconds. 0 means sleep forever.
+ *
+ * Returns:
+ * 0 on success,
+ * Error value otherwise.
+ *
+ * Environment:
+ * The module must have been initialized.
+ *
+ * Side Effects:
+ * As advertised.
+ *------------------------------------------------------------------------*/
+int
+fsprobe_Wait(int sleep_secs)
+{
+ int code;
+ struct timeval tv;
+
+ if (sleep_secs == 0) {
+ while (1) {
+ tv.tv_sec = 30;
+ tv.tv_usec = 0;
+ code = IOMGR_Select(0, 0, 0, 0, &tv);
+ if (code != 0)
+ break;
+ }
+ } else {
+ tv.tv_sec = sleep_secs;
+ tv.tv_usec = 0;
+ code = IOMGR_Select(0, 0, 0, 0, &tv);
+ }
+ return code;
+}