summaryrefslogtreecommitdiff
path: root/bcache.c
diff options
context:
space:
mode:
authorJacob Malevich <jam@daterainc.com>2015-02-10 16:55:10 -0800
committerJacob Malevich <jam@daterainc.com>2015-02-12 14:05:52 -0800
commiteb1d49d3f1232e352c0013c651f6cc4b43d99403 (patch)
treeefa0aca377f08d7d8bcd604bd755b7ccf7f605df /bcache.c
parentffb068c2b4d50d888e2d0706f7883528f714fae0 (diff)
bcacheadm: fix capacity command
regression from 5730e47b Signed-off-by: Jacob Malevich <jam@daterainc.com> Issue DAT-1977 Change-Id: I598ca9e5623fde441bb842580c2494fd03316f00
Diffstat (limited to 'bcache.c')
-rw-r--r--bcache.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/bcache.c b/bcache.c
index 874fe96..f5609e0 100644
--- a/bcache.c
+++ b/bcache.c
@@ -1405,24 +1405,24 @@ char *bcache_get_capacity(const char *cset_dir, const char *capacity_uuid,
double avail_buckets[MAX_DEVS];
char *dev_names[MAX_DEVS];
int dev_count = 0, i;
- char intbuf[4];
double total_cap = 0, total_free = 0;
int precision = 2;
- snprintf(bucket_size_path, MAX_PATH, "%s/%s/%s/%s", cset_dir,
- capacity_uuid, "cache0", "bucket_size_bytes");
- snprintf(nbuckets_path, MAX_PATH, "%s/%s/%s/%s", cset_dir,
- capacity_uuid, "cache0", "nbuckets");
- snprintf(avail_buckets_path, MAX_PATH, "%s/%s/%s/%s", cset_dir,
- capacity_uuid, "cache0", "available_buckets");
- snprintf(cache_path, MAX_PATH, "%s/%s/%s", cset_dir, capacity_uuid,
- "cache0");
while (true) {
char buf[MAX_PATH];
int len;
DIR *cache_dir;
+ snprintf(bucket_size_path, sizeof(bucket_size_path), "%s/%s/%s%d/%s", cset_dir,
+ capacity_uuid, "cache", dev_count, "bucket_size_bytes");
+ snprintf(nbuckets_path, sizeof(nbuckets_path), "%s/%s/%s%d/%s", cset_dir,
+ capacity_uuid, "cache", dev_count, "nbuckets");
+ snprintf(avail_buckets_path, sizeof(avail_buckets_path), "%s/%s/%s%d/%s", cset_dir,
+ capacity_uuid, "cache", dev_count, "available_buckets");
+ snprintf(cache_path, sizeof(cache_path), "%s/%s/%s%d", cset_dir, capacity_uuid,
+ "cache", dev_count);
+
if((cache_dir = opendir(cache_path)) == NULL)
break;
@@ -1452,20 +1452,7 @@ char *bcache_get_capacity(const char *cset_dir, const char *capacity_uuid,
dev_names[dev_count] = dev_name(buf);
}
- snprintf(intbuf, 4, "%d", dev_count);
-
- /* remove i/stat and append i++/stat */
- bucket_size_path[strlen(cache_path) - strlen(intbuf)] = 0;
- nbuckets_path[strlen(cache_path) - strlen(intbuf)] = 0;
- avail_buckets_path[strlen(cache_path) - strlen(intbuf)] = 0;
- cache_path[strlen(cache_path) - strlen(intbuf)] = 0;
-
dev_count++;
-
- strcat(cache_path, intbuf);
- strcat(bucket_size_path, intbuf);
- strcat(nbuckets_path, intbuf);
- strcat(avail_buckets_path, intbuf);
}
printf("%-15s%-25s%-25s\n", "Device Name", "Capacity (512 Blocks)", "Free (512 Blocks)");