extern unsigned int flags;
extern unsigned int dm_major;
-extern struct sa_dlist *st_dev_list;
-extern int dlist_idx;
+extern struct sa_dlist *st_iface_list;
+extern int dlst_iface_idx;
/*
***************************************************************************
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
/* Device not found */
continue;
}
extern int dis;
extern char timestamp[][TIMESTAMP_LEN];
extern unsigned long avg_count;
-extern struct sa_dlist *st_dev_list;
-extern int dlist_idx;
+extern struct sa_dlist *st_iface_list;
+extern int dlst_iface_idx;
/*
***************************************************************************
for (i = 0; i < a->nr[curr]; i++) {
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
/* Device not found */
continue;
}
for (i = 0; i < a->nr[curr]; i++) {
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
/* Device not found */
continue;
}
extern unsigned int flags;
extern unsigned int dm_major;
-extern struct sa_dlist *st_dev_list;
-extern int dlist_idx;
+extern struct sa_dlist *st_iface_list;
+extern int dlst_iface_idx;
/*
***************************************************************************
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
/* Device not found */
continue;
}
extern unsigned int flags;
extern unsigned int dm_major;
-extern struct sa_dlist *st_dev_list;
-extern int dlist_idx;
+extern struct sa_dlist *st_iface_list;
+extern int dlst_iface_idx;
/*
***************************************************************************
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
/* Device not found */
continue;
}
/* List of devices entered on the command line */
struct sa_dlist {
- /* Device type */
- int dev_id __attribute__ ((aligned (4)));
/* Device name */
char dev_name[MAX_NAME_LEN];
};
int next_slice
(unsigned long long, unsigned long long, int, long);
void parse_sa_devices
- (int, char *[], struct sa_dlist **, int *, int *, int, int);
+ (int, char *[], struct sa_dlist **, int *, int *, int);
int parse_sar_opt
(char * [], int *, struct activity * [], unsigned int *, int);
int parse_sar_I_opt
(unsigned int, struct record_header *, struct tm *, struct tm *);
int sa_open_read_magic
(int *, char *, struct file_magic *, int, int *, int);
-void salloc_sa_dlist
- (struct sa_dlist **, int);
int search_sa_dlist
- (struct sa_dlist *, int, char *, int);
+ (struct sa_dlist *, int, char *);
void select_all_activities
(struct activity * []);
void select_default_activity
* Allocate structures for devices entered on the command line.
*
* IN:
- * @list_len Number of arguments on the command line.
+ * @nr_alloc_slots Number of slots to allocate.
+ * @nr_used_slots Number of slots currently used.
*
* OUT:
- * @st_dev_list Address of allocated structures.
+ * @st_list Address of allocated structures.
***************************************************************************
*/
-void salloc_sa_dlist(struct sa_dlist **st_dev_list, int list_len)
+void salloc_sa_dlist(struct sa_dlist **st_list, int nr_alloc_slots, int nr_used_slots)
{
- if ((*st_dev_list = (struct sa_dlist *) malloc(SA_DLIST_SIZE * list_len)) == NULL) {
- perror("malloc");
- exit(4);
+ if (!nr_alloc_slots) {
+ /* Allocate at least one slot */
+ nr_alloc_slots = 1;
}
- memset(*st_dev_list, 0, SA_DLIST_SIZE * list_len);
+
+ SREALLOC(*st_list, struct sa_dlist, sizeof(struct sa_dlist) * (nr_used_slots + nr_alloc_slots));
}
/*
* Look for device in list.
*
* IN:
- * @st_dev_list Structure where devices are saved.
- * @dlist_idx Number of devices in the list.
+ * @st_list Structure where devices are saved.
+ * @dlst_idx Number of devices in the list.
* @d_name Device name to look for.
- * @d_id Device type.
*
* RETURNS:
* 1 if device found in list, 0 otherwise.
***************************************************************************
*/
-int search_sa_dlist(struct sa_dlist *st_dev_list, int dlist_idx, char *d_name, int d_id)
+int search_sa_dlist(struct sa_dlist *st_list, int dlst_idx, char *d_name)
{
int i;
- struct sa_dlist *st_dev_list_i;
+ struct sa_dlist *st_list_i;
- for (i = 0; i < dlist_idx; i++) {
- st_dev_list_i = st_dev_list + i;
- if ((st_dev_list_i->dev_id == d_id) &&
- !strcmp(st_dev_list_i->dev_name, d_name))
+ for (i = 0; i < dlst_idx; i++) {
+ st_list_i = st_list + i;
+ if (!strcmp(st_list_i->dev_name, d_name))
return 1;
}
* IN:
* @argc Number of arguments in the list.
* @argv Arguments list.
- * @st_dev_list Structure where devices will be saved.
- * @dlist_idx Number of devices previously saved in the list.
+ * @st_list Structure where devices will be saved.
+ * @dlst_idx Number of devices previously saved in the list.
* @opt Index in list of arguments.
- * @d_id Type of device.
* @pos Position is string where is located the first device.
*
* OUT:
- * @st_dev_list Structure where devices have been saved.
- * @dlist_idx Total number of devices saved in the list.
+ * @st_list Structure where devices have been saved.
+ * @dlst_idx Total number of devices saved in the list.
* @opt Index on next argument.
***************************************************************************
*/
-void parse_sa_devices(int argc, char *argv[], struct sa_dlist **st_dev_list,
- int *dlist_idx, int *opt, int d_id, int pos)
+void parse_sa_devices(int argc, char *argv[], struct sa_dlist **st_list,
+ int *dlst_idx, int *opt, int pos)
{
char *t;
- struct sa_dlist *st_dev_list_i;
+ struct sa_dlist *st_list_i;
+
+ /* (Re)allocate device list */
+ salloc_sa_dlist(st_list, count_csvalues(argc, argv), *dlst_idx);
- if (*st_dev_list == NULL) {
- /* Allocate device list */
- salloc_sa_dlist(st_dev_list, argc - 1 + count_csvalues(argc, argv));
- }
for (t = strtok(argv[*opt] + pos, ","); t; t = strtok(NULL, ",")) {
- st_dev_list_i = *st_dev_list + (*dlist_idx)++;
- st_dev_list_i->dev_id = d_id;
- strncpy(st_dev_list_i->dev_name, t, MAX_NAME_LEN - 1);
+ st_list_i = *st_list + (*dlst_idx)++;
+ strncpy(st_list_i->dev_name, t, MAX_NAME_LEN - 1);
+ st_list_i->dev_name[MAX_NAME_LEN - 1] = '\0';
}
(*opt)++;
}
char *args[MAX_ARGV_NR];
/* Devices entered on the command line */
-struct sa_dlist *st_dev_list = NULL;
-int dlist_idx = 0;
+struct sa_dlist *st_iface_list = NULL;
+int dlst_iface_idx = 0;
extern struct activity *act[];
extern struct report_format *fmt[];
else if (!strncmp(argv[opt], "--iface=", 8)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argc, argv, &st_dev_list,
- &dlist_idx, &opt, A_NET_DEV, 8);
+ parse_sa_devices(argc, argv, &st_iface_list,
+ &dlst_iface_idx, &opt, 8);
}
else if (!strcmp(argv[opt], "-s")) {
unsigned int id_seq[NR_ACT];
/* Devices entered on the command line */
-struct sa_dlist *st_dev_list = NULL;
-int dlist_idx = 0;
+struct sa_dlist *st_iface_list = NULL;
+int dlst_iface_idx = 0;
struct tm rectime;
else if (!strncmp(argv[opt], "--iface=", 8)) {
/* Parse devices entered on the command line */
- parse_sa_devices(argc, argv, &st_dev_list,
- &dlist_idx, &opt, A_NET_DEV, 8);
+ parse_sa_devices(argc, argv, &st_iface_list,
+ &dlst_iface_idx, &opt, 8);
}
else if (!strcmp(argv[opt], "--help")) {
/* Free stuctures and activity bitmaps */
free_bitmaps(act);
free_structures(act);
- if (st_dev_list) {
- free(st_dev_list);
+ if (st_iface_list) {
+ free(st_iface_list);
}
return 0;
/* Free structures and activity bitmaps */
free_bitmaps(act);
free_structures(act);
- if (st_dev_list) {
- free(st_dev_list);
+ if (st_iface_list) {
+ free(st_iface_list);
}
return 0;
extern unsigned int flags;
extern unsigned int dm_major;
-extern struct sa_dlist *st_dev_list;
-extern int dlist_idx;
+extern struct sa_dlist *st_iface_list;
+extern int dlst_iface_idx;
unsigned int svg_colors[] = {0x00cc00, 0xff00bf, 0x00ffff, 0xff0000,
0xe85f00, 0x0000ff, 0x006020, 0x7030a0,
for (i = 0; i < a->nr[curr]; i++) {
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
/* Device not found */
continue;
}
/* Empty structure: This is the end of the list */
break;
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
/* Device not found */
continue;
}
extern unsigned int flags;
extern unsigned int dm_major;
-extern struct sa_dlist *st_dev_list;
-extern int dlist_idx;
+extern struct sa_dlist *st_iface_list;
+extern int dlst_iface_idx;
/*
***************************************************************************
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, sndc->interface))
/* Device not found */
continue;
}
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
- if (dlist_idx) {
+ if (dlst_iface_idx) {
/* A list of devices has been entered on the command line */
- if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
- A_NET_DEV))
+ if (!search_sa_dlist(st_iface_list, dlst_iface_idx, snedc->interface))
/* Device not found */
continue;
}