return this;
} // end: node_add
+
static void node_classify (
struct dev_node *this)
{
this->type = DISKSTATS_TYPE_DISK;
return;
}
- while((dent = readdir(dirp))) {
+ while ((dent = readdir(dirp))) {
if (strcmp(this->name, dent->d_name) == 0) {
this->type = DISKSTATS_TYPE_DISK;
break;
if (rc != 14) {
if (errno != 0)
return -errno;
- return -EINVAL;
+ return -EIO;
}
node.stamped = info->new_stamp;
if ((rc = node_update(info, &node)))
if (maxstacks < 1)
return NULL;
- vect_size = sizeof(void *) * maxstacks; // size of the addr vectors |
- vect_size += sizeof(void *); // plus NULL addr delimiter |
- head_size = sizeof(struct diskstats_stack); // size of that head struct |
- list_size = sizeof(struct diskstats_result) * this->numitems;// any single results stack |
- blob_size = sizeof(struct stacks_extent); // the extent anchor itself |
- blob_size += vect_size; // plus room for addr vects |
- blob_size += head_size * maxstacks; // plus room for head thing |
- blob_size += list_size * maxstacks; // plus room for our stacks |
-
- /* note: all of our memory is allocated in a single blob, facilitating some later free(). |
- as a minimum, it is important that all those result structs themselves always be |
- contiguous within every stack since they will be accessed via relative position. | */
+ vect_size = sizeof(void *) * maxstacks; // size of the addr vectors |
+ vect_size += sizeof(void *); // plus NULL addr delimiter |
+ head_size = sizeof(struct diskstats_stack); // size of that head struct |
+ list_size = sizeof(struct diskstats_result) * this->numitems; // any single results stack |
+ blob_size = sizeof(struct stacks_extent); // the extent anchor itself |
+ blob_size += vect_size; // plus room for addr vects |
+ blob_size += head_size * maxstacks; // plus room for head thing |
+ blob_size += list_size * maxstacks; // plus room for our stacks |
+
+ /* note: all of our memory is allocated in one single blob, facilitating some later free(). |
+ as a minimum, it's important that all of those result structs themselves always be |
+ contiguous within every stack since they will be accessed via a relative position. | */
if (NULL == (p_blob = calloc(1, blob_size)))
return NULL;
- p_blob->next = this->extents; // push this extent onto... |
- this->extents = p_blob; // ...some existing extents |
- p_vect = (void *)p_blob + sizeof(struct stacks_extent); // prime our vector pointer |
- p_blob->stacks = p_vect; // set actual vectors start |
- v_head = (void *)p_vect + vect_size; // prime head pointer start |
- v_list = v_head + (head_size * maxstacks); // prime our stacks pointer |
+ p_blob->next = this->extents; // push this extent onto... |
+ this->extents = p_blob; // ...some existing extents |
+ p_vect = (void *)p_blob + sizeof(struct stacks_extent); // prime our vector pointer |
+ p_blob->stacks = p_vect; // set actual vectors start |
+ v_head = (void *)p_vect + vect_size; // prime head pointer start |
+ v_list = v_head + (head_size * maxstacks); // prime our stacks pointer |
for (i = 0; i < maxstacks; i++) {
p_head = (struct diskstats_stack *)v_head;
if (p->item == sortitem)
break;
++offset;
- if (p->item == DISKSTATS_logical_end)
+ if (p->item >= DISKSTATS_logical_end)
return NULL;
++p;
}
#define TICv(E) STAT_VAL(E, ull_int, stat_stack)
#define DTICv(E) STAT_VAL(E, sl_int, stat_stack)
#define SYSv(E) STAT_VAL(E, ul_int, stat_stack)
-#define MEMv(E) STAT_VAL(E, ul_int, mem_stack)
+#define MEMv(E) MEMINFO_VAL(E, ul_int, mem_stack)
#define DSYSv(E) STAT_VAL(E, s_int, stat_stack)
const char format[] =
"%2lu %2lu %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u";
int i;
if (procps_diskstats_new(&disk_stat) < 0)
- xerr(EXIT_FAILURE,
- _("Unable to create diskstat structure"));
+ xerrx(EXIT_FAILURE, _("Unable to create diskstat structure"));
if (!(got = procps_diskstats_get(disk_stat, partition_name, DISKSTATS_TYPE)))
xerrx(EXIT_FAILURE, _("Disk/Partition %s not found"), partition_name);
const char wide_format[] = "%-5s %9lu %9lu %11lu %11lu %9lu %9lu %11lu %11lu %7lu %7lu";
if (procps_diskstats_new(&disk_stat) < 0)
- xerr(EXIT_FAILURE,
- _("Unable to create diskstat structure"));
+ xerrx(EXIT_FAILURE, _("Unable to create diskstat structure"));
if (!moreheaders)
diskheader();
for (i=0; infinite_updates || i < num_updates ; i++) {
if (!(reap = procps_diskstats_reap(disk_stat, Disk_items, MAX_disk)))
- xerr(EXIT_FAILURE,
- _("Unable to retrieve disk statistics"));
+ xerrx(EXIT_FAILURE, _("Unable to retrieve disk statistics"));
if (t_option) {
(void) time( &the_time );
tm_ptr = localtime( &the_time );
slab_AOBJS, slab_OBJS, slab_OSIZE, slab_OPS, slab_NAME };
if (procps_slabinfo_new(&slab_info) < 0)
- xerr(EXIT_FAILURE, _("Unable to create slabinfo structure"));
+ xerrx(EXIT_FAILURE, _("Unable to create slabinfo structure"));
if (!moreheaders)
slabheader();
disk_count = part_count = 0;
if (procps_diskstats_new(&disk_stat) < 0)
- xerr(EXIT_FAILURE,
- _("Unable to create diskstat structure"));
+ xerrx(EXIT_FAILURE, _("Unable to create diskstat structure"));
if (!(reap = procps_diskstats_reap(disk_stat, Disk_items, MAX_disk)))
- xerr(EXIT_FAILURE,
- _("Unable to retrieve disk statistics"));
+ xerrx(EXIT_FAILURE, _("Unable to retrieve disk statistics"));
for (j = 0; j < reap->total; j++) {
if (diskVAL(disk_TYPE, s_int) != DISKSTATS_TYPE_DISK) {