#include <afs/param.h>
#include <roken.h>
+#include <opr/softsig.h>
#undef IN
#include <afs/gtxwindows.h> /*Generic window package */
curr_disk->prev = i - 1;
curr_disk->next = i + 1;
curr_disk->active = 0;
- curr_disk->name = '\0';
+ curr_disk->name = "";
/*
* Bump up to the next disk structure.
{ /*mini_PrintDiskStats */
static char rn[] = "mini_PrintDiskStats"; /*Routine name */
- int code; /*Return code */
char s[128]; /*String buffer */
struct onode *curr_disklight; /*Ptr to current disk light */
struct onode *srvname_light; /*Ptr to server name light */
used_disk_idx, diskdata->label);
fflush(scout_debugfd);
}
- code = mini_justify(" ", /*Src buffer */
- diskdata->label, /*Dest buffer */
- scout_col_width[COL_DISK], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
- code = gator_light_set(curr_disklight, 0);
+ mini_justify(" ", /*Src buffer */
+ diskdata->label, /*Dest buffer */
+ scout_col_width[COL_DISK], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ gator_light_set(curr_disklight, 0);
if (a_fix_line_num) {
curr_disklight->o_y += a_delta_line_num;
disk_strparams = (struct gwin_strparams *)(diskdata->llrock);
* mark all used disk objects for this server as inactive and fix
* their line numbers if needed.
*/
- sc_disk = a_srvline->disks;
used_disk_idx = a_srvline->used_head;
while (used_disk_idx != SCOUT_NIL) {
if (scout_debug) {
rn, s, found_idx, diskdata->label);
fflush(scout_debugfd);
}
- code = mini_justify(s, /*Src buffer */
- diskdata->label, /*Dest buffer */
- scout_col_width[COL_DISK], /*Dest's width */
- SCOUT_LEFT_JUSTIFY, /*Left-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_IS_LDISK); /*Labeled disk */
+ mini_justify(s, /*Src buffer */
+ diskdata->label, /*Dest buffer */
+ scout_col_width[COL_DISK], /*Dest's width */
+ SCOUT_LEFT_JUSTIFY, /*Left-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_IS_LDISK); /*Labeled disk */
- code = gator_light_set(sc_disk->disk_lp, pastthreshold);
+ gator_light_set(sc_disk->disk_lp, pastthreshold);
} /*Found disk record */
}
curr_probeOK = fsprobe_Results.probeOK;
curr_line_num = curr_line->base_line;
- setting = 0;
for (curr_srvidx = 0; curr_srvidx < scout_screen.numServers;
curr_srvidx++) {
/*
sprintf(sp, "%d", curr_stats->CurrentConnections);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_CONN], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_CONN], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_conn != SCOUT_ATTN_NOTUSED
&& curr_stats->CurrentConnections >= scout_attn_conn)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->currConns_lp, setting);
+ gator_light_set(curr_line->currConns_lp, setting);
lightdata = (struct gator_lightobj *)(curr_line->fetches_lp->o_data);
if (*curr_probeOK == 0) {
sprintf(sp, "%u", curr_stats->TotalFetchs);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_FETCH], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_FETCH], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_fetch != SCOUT_ATTN_NOTUSED
&& curr_stats->TotalFetchs >= scout_attn_fetch)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->fetches_lp, setting);
+ gator_light_set(curr_line->fetches_lp, setting);
lightdata = (struct gator_lightobj *)(curr_line->stores_lp->o_data);
if (*curr_probeOK == 0) {
sprintf(sp, "%u", curr_stats->TotalStores);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_STORE], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_STORE], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_store != SCOUT_ATTN_NOTUSED
&& curr_stats->TotalStores >= scout_attn_store)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->stores_lp, setting);
+ gator_light_set(curr_line->stores_lp, setting);
lightdata =
(struct gator_lightobj *)(curr_line->workstations_lp->o_data);
sprintf(sp, "%d", curr_stats->WorkStations);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_WK], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_WK], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_workstations != SCOUT_ATTN_NOTUSED
&& curr_stats->WorkStations >= scout_attn_workstations)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->workstations_lp, setting);
+ gator_light_set(curr_line->workstations_lp, setting);
/*
* We turn the server light on if there was an error in the
* (Don't forget to fix the light's line if it needs it).
*/
setting = (*curr_probeOK) ? 1 : 0;
- code = gator_light_set(curr_line->srvName_lp, setting);
+ gator_light_set(curr_line->srvName_lp, setting);
/*
* Print out the disk statistics. The value returned is the
"[%s] Can't center server name inside of light object\n", rn);
return (code);
}
- curr_x += scout_col_width[COL_SRVNAME] + 1;
if (scout_initDiskLightObjects(a_line, scout_frame->window)) {
fprintf(stderr, "[%s:%s] Can't create disk light objects\n", pn, rn);
struct mini_line *curr_line; /*Ptr to current line */
int i; /*Generic loop variable */
int mini_line_bytes; /*Num bytes in mini_lines */
- struct timeval tv; /*Time structure */
int linenum; /*Current mini-line number */
-#if 0
- PROCESS pid; /*Main LWP process ID */
- PROCESS gxlistener_ID; /*Input Server LWP process ID */
-#endif /* 0 */
struct gator_lightobj *lightdata; /*Private light data */
if (scout_debug) {
}
/*
- * We have to initialize LWP support before we start up any of
+ * We have to initialize thread support before we start up any of
* our packages.
*/
-#if 0
- code = LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
- if (code) {
- fprintf(stderr, "[%s:%s] Can't initialize LWP\n", pn, rn);
- scout_CleanExit(code);
- }
-#endif /* 0 */
+ opr_softsig_Init();
/*
* Initialize the gtx package.
* watching.
*/
sktbytes = a_numservers * sizeof(struct sockaddr_in);
- FSSktArray = (struct sockaddr_in *)malloc(sktbytes);
+ FSSktArray = calloc(1, sktbytes);
if (FSSktArray == (struct sockaddr_in *)0) {
fprintf(stderr,
"[%s] Can't malloc() %d sockaddrs (%d bytes) for the given servers\n",
rn, a_numservers, sktbytes);
scout_CleanExit(-1);
}
- memset(FSSktArray, 0, sktbytes);
/*
* Sweep through the server names provided, filling in the socket
* Create the set of mini-lines, one per server.
*/
mini_line_bytes = a_numservers * sizeof(struct mini_line);
- mini_lines = (struct mini_line *)malloc(mini_line_bytes);
+ mini_lines = calloc(1, mini_line_bytes);
if (mini_lines == (struct mini_line *)0) {
fprintf(stderr, "[%s] Can't malloc() %d bytes for %d screen lines\n",
rn, mini_line_bytes, a_numservers);
return (-1);
}
- memset(mini_lines, 0, mini_line_bytes);
/*
* Set up each line in the mini_lines, creating and initializing
scout_gwin); /*Window */
if (scout_banner0_lp != NULL) {
lightdata = (struct gator_lightobj *)(scout_banner0_lp->o_data);
- code =
- mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
- SCOUT_CENTER, SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
- code = gator_light_set(scout_banner0_lp, 1);
- code = gtxframe_AddToList(scout_frame, scout_banner0_lp);
+ mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
+ SCOUT_CENTER, SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
+ gator_light_set(scout_banner0_lp, 1);
+ gtxframe_AddToList(scout_frame, scout_banner0_lp);
/*Debugging */
if (scout_debug)
snprintf(attn_label, sizeof(attn_label), "%s: < %d blocks free",
scout_label[5], scout_attn_disk_minfree);
}
- snprintf(scout_Banner, sizeof(scout_Banner),
- "%*s %*s %*s %*s %*s %s",
- scout_col_width[0], scout_label[0],
- scout_col_width[1], scout_label[1],
- scout_col_width[2], scout_label[2],
- scout_col_width[3], scout_label[3],
- scout_col_width[4], scout_label[4],
- attn_label);
+ code = snprintf(scout_Banner, sizeof(scout_Banner),
+ "%*s %*s %*s %*s %*s %s",
+ scout_col_width[0], scout_label[0],
+ scout_col_width[1], scout_label[1],
+ scout_col_width[2], scout_label[2],
+ scout_col_width[3], scout_label[3],
+ scout_col_width[4], scout_label[4],
+ attn_label);
+ if (code < 0 || code >= sizeof(scout_Banner)) {
+ fprintf(stderr, "[%s] Truncation while generating banner\n", rn);
+ return -1;
+ }
lightdata = (struct gator_lightobj *)(scout_banner1_lp->o_data);
- code =
- mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
- SCOUT_LEFT_JUSTIFY, SCOUT_RIGHT_TRUNC,
- SCOUT_ISNT_LDISK);
+ mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
+ SCOUT_LEFT_JUSTIFY, SCOUT_RIGHT_TRUNC,
+ SCOUT_ISNT_LDISK);
- code = gtxframe_AddToList(scout_frame, scout_banner1_lp);
+ gtxframe_AddToList(scout_frame, scout_banner1_lp);
}
scout_banner2_lp = mini_initLightObject("Banner 2", /*Light name */
scout_underline[5]);
lightdata = (struct gator_lightobj *)(scout_banner2_lp->o_data);
- code =
- mini_justify(scout_Banner, lightdata->label,
- scout_frameDims.maxx, SCOUT_LEFT_JUSTIFY,
- SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
- code = gtxframe_AddToList(scout_frame, scout_banner2_lp);
+ mini_justify(scout_Banner, lightdata->label,
+ scout_frameDims.maxx, SCOUT_LEFT_JUSTIFY,
+ SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
+ gtxframe_AddToList(scout_frame, scout_banner2_lp);
}
for (i = 0; i < a_numservers; i++) {
return (-1);
}
-
- /*
- * Start up the input server LWP for our window.
- */
-#if 0
- code = LWP_CreateProcess(gtx_InputServer, /*Fcn to start up */
- 8192, /*Stack size in bytes */
- LWP_NORMAL_PRIORITY, /*Priority */
- (void *)scout_gwin, /*Params: Ptr to window */
- "gx-listener", /*Name to use */
- &gxlistener_ID); /*Returned LWP process ID */
-#endif /* 0 */
-
code = (int)(intptr_t)gtx_InputServer(scout_gwin);
if (code) {
fprintf(stderr,
scout_CleanExit(code);
}
- /*
- * We fall into a loop, sleeping forever.
- */
- while (1) {
- tv.tv_sec = 60 * 60; /*Sleep for an hour at a time */
- tv.tv_usec = 0;
- code = select(0, /*Num fds */
- 0, /*Descriptors ready for reading */
- 0, /*Descriptors ready for writing */
- 0, /*Descriptors with exceptional conditions */
- &tv); /*Timeout structure */
- } /*Sleep forever */
-
-#if 0
- /*
- * How did we get here? Oh, well, clean up our windows and
- * return sweetness and light anyway.
- */
- WOP_CLEANUP(&scout_gwin);
- return (0);
-#endif /* 0 */
-
+ fsprobe_Wait(0); /* sleep forever */
+ return 0;
} /*execute_scout */
/*------------------------------------------------------------------------
/*
* Set up the commands we understand.
*/
- ts = cmd_CreateSyntax("initcmd", scoutInit, NULL, "initialize the program");
+ ts = cmd_CreateSyntax("initcmd", scoutInit, NULL, 0, "initialize the program");
cmd_AddParm(ts, "-server", CMD_LIST, CMD_REQUIRED,
"FileServer name(s) to monitor");
cmd_AddParm(ts, "-basename", CMD_SINGLE, CMD_OPTIONAL,