78 lines
2.8 KiB
Diff
78 lines
2.8 KiB
Diff
diff --git a/bindings.c b/bindings.c
|
|
--- a/bindings.c
|
|
+++ b/bindings.c
|
|
@@ -4099,7 +4099,7 @@ struct devinfo* container_dev_read(pid_t pid) {
|
|
goto child_out;
|
|
}
|
|
while ((ptr = readdir(dir)) != NULL) {
|
|
- if (ptr->d_type != DT_BLK && ptr->d_type != DT_CHR) {
|
|
+ if (ptr->d_type != DT_BLK) {
|
|
continue;
|
|
}
|
|
memset(fpath, 0, sizeof(fpath));
|
|
@@ -4167,10 +4167,20 @@ void free_devinfo_list(struct devinfo *ptr)
|
|
}
|
|
}
|
|
|
|
+static bool need_record_diskstats(unsigned int major, unsigned int minor)
|
|
+{
|
|
+ //only support device which major is 253.
|
|
+ if (major == 253) {
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
|
struct fuse_file_info *fi)
|
|
{
|
|
char dev_name[72];
|
|
+ char tmp_dev_name[72];
|
|
struct fuse_context *fc = fuse_get_context();
|
|
struct file_info *d = (struct file_info *)fi->fh;
|
|
struct devinfo *container_devinfo = NULL, *ptr;
|
|
@@ -4233,6 +4243,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
|
while (getline(&line, &linelen, f) != -1) {
|
|
ssize_t l;
|
|
char lbuf[256];
|
|
+ bool match = false;
|
|
|
|
memset(dev_name, 0, sizeof(dev_name));
|
|
i = sscanf(line, "%u %u %71s", &major, &minor, dev_name);
|
|
@@ -4240,11 +4251,16 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
|
continue;
|
|
for (ptr = container_devinfo; ptr != NULL; ptr = ptr->next) {
|
|
if (major == ptr->major && minor == ptr->minor) {
|
|
- strncpy(dev_name, ptr->name, 71);
|
|
+ snprintf(dev_name, sizeof(dev_name), "%s", ptr->name);
|
|
dev_name[71] = '\0';
|
|
+ match = true;
|
|
}
|
|
}
|
|
|
|
+ if (!match) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
get_blkio_io_value(io_serviced_str, major, minor, "Read", &read);
|
|
get_blkio_io_value(io_serviced_str, major, minor, "Write", &write);
|
|
get_blkio_io_value(io_merged_str, major, minor, "Read", &read_merged);
|
|
@@ -4274,8 +4290,16 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
|
snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
|
|
major, minor, dev_name, read, read_merged, read_sectors, read_ticks,
|
|
write, write_merged, write_sectors, write_ticks, ios_pgr, tot_ticks, rq_ticks);
|
|
- else
|
|
+ else if (need_record_diskstats(major, minor)) {
|
|
+ sscanf(line, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
|
|
+ &major, &minor, tmp_dev_name, &read, &read_merged, &read_sectors, &read_ticks,
|
|
+ &write, &write_merged, &write_sectors, &write_ticks, &ios_pgr, &tot_ticks, &rq_ticks);
|
|
+ snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
|
|
+ major, minor, dev_name, read, read_merged, read_sectors, read_ticks,
|
|
+ write, write_merged, write_sectors, write_ticks, ios_pgr, tot_ticks, rq_ticks);
|
|
+ } else {
|
|
continue;
|
|
+ }
|
|
|
|
l = snprintf(cache, cache_size, "%s", lbuf);
|
|
if (l < 0) {
|