return fs;
}
+/*
+ ***************************************************************************
+ * Find number of fibre channel hosts in /sys/class/fc_host/.
+ *
+ * RETURNS:
+ * Number of FC hosts.
+ * Return -1 if directory doesn't exist in sysfs.
+ ***************************************************************************
+ */
+int get_fchost_nr(void)
+{
+ DIR *dir;
+ struct dirent *drd;
+ int fc = 0;
+
+ if ((dir = opendir(SYSFS_FCHOST)) == NULL) {
+ /* Directory non-existent */
+ return -1;
+ }
+
+ while ((drd = readdir(dir)) != NULL) {
+
+ if (!strncmp(drd->d_name, "host", 4)) {
+ fc++;
+ }
+ }
+
+ /* Close directory */
+ closedir(dir);
+
+ return fc;
+}
+
/*------------------ END: FUNCTIONS USED BY SADC ONLY ---------------------*/
#endif /* SOURCE_SADC */
get_usb_nr(void);
extern int
get_filesystem_nr(void);
+extern int
+ get_fchost_nr(void);
#endif /* _COUNT_H */
sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + i * a->msize);
+ if (!sfcc->fchost_name[0])
+ /* We are at the end of the list */
+ break;
+
if (sep)
printf(",\n");
sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + i * a->msize);
+ if (!sfcc->fchost_name[0])
+ /* We are at the end of the list */
+ break;
+
printf("%-11s %9.2f %9.2f %9.2f %9.2f %s\n", timestamp[curr],
S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
#define NR_FREQ_PREALLOC (0 * @PREALLOC_FACTOR@)
#define NR_USB_PREALLOC (5 * @PREALLOC_FACTOR@)
#define NR_FILESYSTEM_PREALLOC (3 * @PREALLOC_FACTOR@)
+#define NR_FCHOST_PREALLOC (1 * @PREALLOC_FACTOR@)
#endif /* _PREALLOC_H */
sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + i * a->msize);
+ if (!sfcc->fchost_name[0])
+ /* We are at the end of the list */
+ break;
+
render(isdb, pre, PT_NOFLAG ,
"%s\tfch_rxf/s",
"%s",
/*
***************************************************************************
- * Get number of FC hosts
+ * Get number of FC hosts.
*
* IN:
* @a Activity structure.
*/
__nr_t wrap_get_fchost_nr(struct activity *a)
{
- DIR *dir;
- struct dirent *drd;
__nr_t n = 0;
- if ((dir = opendir(SYSFS_FCHOST)) == NULL) {
- return 0;
- }
-
- while ((drd = readdir(dir)) != NULL)
- if (strncmp(drd->d_name,"host",4)==0)
- n++;
-
- closedir(dir);
+ if ((n = get_fchost_nr()) >= 0)
+ /* Return a positive number even if no FC hosts have been found */
+ return n + NR_FCHOST_PREALLOC;
- return n;
+ return 0;
}
sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + i * a->msize);
+ if (!sfcc->fchost_name[0])
+ /* We are at the end of the list */
+ break;
+
xprintf(tab, "<fchost name=\"%s\" "
"rxframes=\"%.2f\" "
"txframes=\"%.2f\" "