Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -42,5 +42,5 @@
 #include <vfs/vfs.h>
 #include <str.h>
-#include <cap.h>
+#include <capa.h>
 
 #include "ls.h"
@@ -106,10 +106,10 @@
 		}
 
-		cap_spec_t cap;
-		cap_from_blocks(de->s.size, 1, &cap);
-		cap_simplify(&cap);
+		capa_spec_t capa;
+		capa_from_blocks(de->s.size, 1, &capa);
+		capa_simplify(&capa);
 
 		char *rptr;
-		errno_t rc = cap_format(&cap, &rptr);
+		errno_t rc = capa_format(&capa, &rptr);
 		if (rc != EOK) {
 			return rc;
Index: uspace/app/df/df.c
===================================================================
--- uspace/app/df/df.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/app/df/df.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -35,5 +35,5 @@
  */
 
-#include <cap.h>
+#include <capa.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -124,9 +124,9 @@
 static errno_t size_to_human_readable(uint64_t nblocks, size_t block_size, char **rptr)
 {
-	cap_spec_t cap;
-
-	cap_from_blocks(nblocks, block_size, &cap);
-	cap_simplify(&cap);
-	return cap_format(&cap, rptr);
+	capa_spec_t capa;
+
+	capa_from_blocks(nblocks, block_size, &capa);
+	capa_simplify(&capa);
+	return capa_format(&capa, rptr);
 }
 
Index: uspace/app/fdisk/fdisk.c
===================================================================
--- uspace/app/fdisk/fdisk.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/app/fdisk/fdisk.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -34,5 +34,5 @@
  */
 
-#include <cap.h>
+#include <capa.h>
 #include <errno.h>
 #include <fdisk.h>
@@ -136,7 +136,7 @@
 	nchoice_t *choice = NULL;
 	char *svcname = NULL;
-	cap_spec_t cap;
+	capa_spec_t capa;
 	fdisk_dev_info_t *sdev;
-	char *scap = NULL;
+	char *scapa = NULL;
 	char *dtext = NULL;
 	service_id_t svcid;
@@ -177,5 +177,5 @@
 		}
 
-		rc = fdisk_dev_info_capacity(info, &cap);
+		rc = fdisk_dev_info_capacity(info, &capa);
 		if (rc != EOK) {
 			printf("Error getting device capacity "
@@ -185,7 +185,7 @@
 		}
 
-		cap_simplify(&cap);
-
-		rc = cap_format(&cap, &scap);
+		capa_simplify(&capa);
+
+		rc = capa_format(&capa, &scapa);
 		if (rc != EOK) {
 			assert(rc == ENOMEM);
@@ -194,5 +194,5 @@
 		}
 
-		int ret = asprintf(&dtext, "%s (%s)", svcname, scap);
+		int ret = asprintf(&dtext, "%s (%s)", svcname, scapa);
 		if (ret < 0) {
 			rc = ENOMEM;
@@ -203,6 +203,6 @@
 		free(svcname);
 		svcname = NULL;
-		free(scap);
-		scap = NULL;
+		free(scapa);
+		scapa = NULL;
 
 		rc = nchoice_add(choice, dtext, info, 0);
@@ -261,5 +261,5 @@
 	free(dtext);
 	free(svcname);
-	free(scap);
+	free(scapa);
 	return rc;
 }
@@ -432,12 +432,12 @@
 	errno_t rc;
 	fdisk_part_spec_t pspec;
-	cap_spec_t cap;
-	cap_spec_t mcap;
+	capa_spec_t capa;
+	capa_spec_t mcapa;
 	vol_label_supp_t vlsupp;
 	vol_fstype_t fstype = 0;
 	tinput_t *tinput = NULL;
 	fdisk_spc_t spc;
-	char *scap;
-	char *smcap = NULL;
+	char *scapa;
+	char *smcapa = NULL;
 	char *label = NULL;
 	char *mountp = NULL;
@@ -448,5 +448,5 @@
 		spc = spc_pri;
 
-	rc = fdisk_part_get_max_avail(dev, spc, &mcap);
+	rc = fdisk_part_get_max_avail(dev, spc, &mcapa);
 	if (rc != EOK) {
 		rc = EIO;
@@ -454,7 +454,7 @@
 	}
 
-	cap_simplify(&mcap);
-
-	rc = cap_format(&mcap, &smcap);
+	capa_simplify(&mcapa);
+
+	rc = capa_format(&mcapa, &smcapa);
 	if (rc != EOK) {
 		rc = ENOMEM;
@@ -474,9 +474,9 @@
 	while (true) {
 		printf("Enter capacity of new partition.\n");
-		rc = tinput_read_i(tinput, smcap, &scap);
+		rc = tinput_read_i(tinput, smcapa, &scapa);
 		if (rc != EOK)
 			goto error;
 
-		rc = cap_parse(scap, &cap);
+		rc = capa_parse(scapa, &capa);
 		if (rc == EOK)
 			break;
@@ -485,6 +485,6 @@
 	tinput_destroy(tinput);
 	tinput = NULL;
-	free(smcap);
-	smcap = NULL;
+	free(smcapa);
+	smcapa = NULL;
 
 	if (pkind != lpk_extended) {
@@ -545,5 +545,5 @@
 
 	fdisk_pspec_init(&pspec);
-	pspec.capacity = cap;
+	pspec.capacity = capa;
 	pspec.pkind = pkind;
 	pspec.fstype = fstype;
@@ -561,5 +561,5 @@
 	return EOK;
 error:
-	free(smcap);
+	free(smcapa);
 	free(label);
 	free(mountp);
@@ -581,5 +581,5 @@
 	fdisk_part_t *part;
 	fdisk_part_info_t pinfo;
-	char *scap = NULL;
+	char *scapa = NULL;
 	char *spkind = NULL;
 	char *sfstype = NULL;
@@ -596,7 +596,7 @@
 		}
 
-		cap_simplify(&pinfo.capacity);
-
-		rc = cap_format(&pinfo.capacity, &scap);
+		capa_simplify(&pinfo.capacity);
+
+		rc = capa_format(&pinfo.capacity, &scapa);
 		if (rc != EOK) {
 			printf("Out of memory.\n");
@@ -623,5 +623,5 @@
 
 			int ret = asprintf(&sdesc, "%s %s, %s, %s", label,
-			    scap, spkind, sfstype);
+			    scapa, spkind, sfstype);
 			if (ret < 0) {
 				rc = ENOMEM;
@@ -630,5 +630,5 @@
 
 		} else {
-			int ret = asprintf(&sdesc, "%s, %s", scap, spkind);
+			int ret = asprintf(&sdesc, "%s, %s", scapa, spkind);
 			if (ret < 0) {
 				rc = ENOMEM;
@@ -644,6 +644,6 @@
 		}
 
-		free(scap);
-		scap = NULL;
+		free(scapa);
+		scapa = NULL;
 		free(spkind);
 		spkind = NULL;
@@ -658,5 +658,5 @@
 	return EOK;
 error:
-	free(scap);
+	free(scapa);
 	free(spkind);
 	free(sfstype);
@@ -907,11 +907,11 @@
 	fdisk_part_t *part;
 	fdisk_part_info_t pinfo;
-	cap_spec_t cap;
-	cap_spec_t mcap;
+	capa_spec_t capa;
+	capa_spec_t mcapa;
 	fdisk_dev_flags_t dflags;
 	char *sltype = NULL;
-	char *sdcap = NULL;
-	char *scap = NULL;
-	char *smcap = NULL;
+	char *sdcapa = NULL;
+	char *scapa = NULL;
+	char *smcapa = NULL;
 	char *sfstype = NULL;
 	char *svcname = NULL;
@@ -936,5 +936,5 @@
 	}
 
-	rc = fdisk_dev_capacity(dev, &cap);
+	rc = fdisk_dev_capacity(dev, &capa);
 	if (rc != EOK) {
 		printf("Error getting device capacity.\n");
@@ -942,7 +942,7 @@
 	}
 
-	cap_simplify(&cap);
-
-	rc = cap_format(&cap, &sdcap);
+	capa_simplify(&capa);
+
+	rc = capa_format(&capa, &sdcapa);
 	if (rc != EOK) {
 		printf("Out of memory.\n");
@@ -958,7 +958,7 @@
 	fdisk_dev_get_flags(dev, &dflags);
 
-	printf("Device: %s (%s)\n", svcname, sdcap);
-	free(sdcap);
-	sdcap = NULL;
+	printf("Device: %s (%s)\n", svcname, sdcapa);
+	free(sdcapa);
+	sdcapa = NULL;
 
 	rc = fdisk_label_get_info(dev, &linfo);
@@ -996,7 +996,7 @@
 		}
 
-		cap_simplify(&pinfo.capacity);
-
-		rc = cap_format(&pinfo.capacity, &scap);
+		capa_simplify(&pinfo.capacity);
+
+		rc = capa_format(&pinfo.capacity, &scapa);
 		if (rc != EOK) {
 			printf("Out of memory.\n");
@@ -1016,7 +1016,7 @@
 
 		if (linfo.ltype == lt_none)
-			printf("Entire disk: %s %s", label, scap);
+			printf("Entire disk: %s %s", label, scapa);
 		else
-			printf("Partition %d: %s %s", npart, label, scap);
+			printf("Partition %d: %s %s", npart, label, scapa);
 
 		if ((linfo.flags & lf_ext_supp) != 0) {
@@ -1037,6 +1037,6 @@
 		printf("\n");
 
-		free(scap);
-		scap = NULL;
+		free(scapa);
+		scapa = NULL;
 		free(sfstype);
 		sfstype = NULL;
@@ -1047,5 +1047,5 @@
 	/* Display available space */
 	if ((linfo.flags & lf_can_create_pri) != 0) {
-		rc = fdisk_part_get_max_avail(dev, spc_pri, &mcap);
+		rc = fdisk_part_get_max_avail(dev, spc_pri, &mcapa);
 		if (rc != EOK) {
 			rc = EIO;
@@ -1053,7 +1053,7 @@
 		}
 
-		cap_simplify(&mcap);
-
-		rc = cap_format(&mcap, &smcap);
+		capa_simplify(&mcapa);
+
+		rc = capa_format(&mcapa, &smcapa);
 		if (rc != EOK) {
 			rc = ENOMEM;
@@ -1062,12 +1062,12 @@
 
 		if ((linfo.flags & lf_ext_supp) != 0)
-			printf("Maximum free primary block: %s\n", smcap);
+			printf("Maximum free primary block: %s\n", smcapa);
 		else
-			printf("Maximum free block: %s\n", smcap);
-
-		free(smcap);
-		smcap = NULL;
-
-		rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcap);
+			printf("Maximum free block: %s\n", smcapa);
+
+		free(smcapa);
+		smcapa = NULL;
+
+		rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcapa);
 		if (rc != EOK) {
 			rc = EIO;
@@ -1075,7 +1075,7 @@
 		}
 
-		cap_simplify(&mcap);
-
-		rc = cap_format(&mcap, &smcap);
+		capa_simplify(&mcapa);
+
+		rc = capa_format(&mcapa, &smcapa);
 		if (rc != EOK) {
 			rc = ENOMEM;
@@ -1084,15 +1084,15 @@
 
 		if ((linfo.flags & lf_ext_supp) != 0)
-			printf("Total free primary space: %s\n", smcap);
+			printf("Total free primary space: %s\n", smcapa);
 		else
-			printf("Total free space: %s\n", smcap);
-
-		free(smcap);
-		smcap = NULL;
+			printf("Total free space: %s\n", smcapa);
+
+		free(smcapa);
+		smcapa = NULL;
 	}
 
 	/* Display available space */
 	if ((linfo.flags & lf_can_create_log) != 0) {
-		rc = fdisk_part_get_max_avail(dev, spc_log, &mcap);
+		rc = fdisk_part_get_max_avail(dev, spc_log, &mcapa);
 		if (rc != EOK) {
 			rc = EIO;
@@ -1100,7 +1100,7 @@
 		}
 
-		cap_simplify(&mcap);
-
-		rc = cap_format(&mcap, &smcap);
+		capa_simplify(&mcapa);
+
+		rc = capa_format(&mcapa, &smcapa);
 		if (rc != EOK) {
 			rc = ENOMEM;
@@ -1108,9 +1108,9 @@
 		}
 
-		printf("Maximum free logical block: %s\n", smcap);
-		free(smcap);
-		smcap = NULL;
-
-		rc = fdisk_part_get_tot_avail(dev, spc_log, &mcap);
+		printf("Maximum free logical block: %s\n", smcapa);
+		free(smcapa);
+		smcapa = NULL;
+
+		rc = fdisk_part_get_tot_avail(dev, spc_log, &mcapa);
 		if (rc != EOK) {
 			rc = EIO;
@@ -1118,7 +1118,7 @@
 		}
 
-		cap_simplify(&mcap);
-
-		rc = cap_format(&mcap, &smcap);
+		capa_simplify(&mcapa);
+
+		rc = capa_format(&mcapa, &smcapa);
 		if (rc != EOK) {
 			rc = ENOMEM;
@@ -1126,7 +1126,7 @@
 		}
 
-		printf("Total free logical space: %s\n", smcap);
-		free(smcap);
-		smcap = NULL;
+		printf("Total free logical space: %s\n", smcapa);
+		free(smcapa);
+		smcapa = NULL;
 	}
 
@@ -1279,7 +1279,7 @@
 	return EOK;
 error:
-	free(sdcap);
-	free(scap);
-	free(smcap);
+	free(sdcapa);
+	free(scapa);
+	free(smcapa);
 	free(sfstype);
 	free(svcname);
Index: uspace/app/sysinst/sysinst.c
===================================================================
--- uspace/app/sysinst/sysinst.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/app/sysinst/sysinst.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -38,5 +38,5 @@
 #include <block.h>
 #include <byteorder.h>
-#include <cap.h>
+#include <capa.h>
 #include <errno.h>
 #include <fdisk.h>
@@ -98,5 +98,5 @@
 	fdisk_part_spec_t pspec;
 	fdisk_part_info_t pinfo;
-	cap_spec_t cap;
+	capa_spec_t capa;
 	service_id_t sid;
 	errno_t rc;
@@ -137,5 +137,5 @@
 	printf("sysinst_label_dev(): create partition\n");
 
-	rc = fdisk_part_get_max_avail(fdev, spc_pri, &cap);
+	rc = fdisk_part_get_max_avail(fdev, spc_pri, &capa);
 	if (rc != EOK) {
 		printf("Error getting available capacity: %s.\n", str_error(rc));
@@ -144,5 +144,5 @@
 
 	fdisk_pspec_init(&pspec);
-	pspec.capacity = cap;
+	pspec.capacity = capa;
 	pspec.pkind = lpk_primary;
 	pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */
Index: uspace/lib/c/generic/cap.c
===================================================================
--- uspace/lib/c/generic/cap.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ 	(revision )
@@ -1,307 +1,0 @@
-/*
- * Copyright (c) 2015 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/**
- * @file Storage capacity specification.
- */
-
-#include <cap.h>
-#include <errno.h>
-#include <imath.h>
-#include <stdio.h>
-#include <str.h>
-
-/** Simplified capacity parameters */
-enum {
-	/** Simplified capacity maximum integer digits */
-	scap_max_idig = 3,
-	/** Simplified capacity maximum significant digits */
-	scap_max_sdig = 4
-};
-
-static const char *cu_str[] = {
-	[cu_byte] = "B",
-	[cu_kbyte] = "kB",
-	[cu_mbyte] = "MB",
-	[cu_gbyte] = "GB",
-	[cu_tbyte] = "TB",
-	[cu_pbyte] = "PB",
-	[cu_ebyte] = "EB",
-	[cu_zbyte] = "ZB",
-	[cu_ybyte] = "YB"
-};
-
-void cap_from_blocks(uint64_t nblocks, size_t block_size, cap_spec_t *cap)
-{
-	uint64_t tsize;
-
-	tsize = nblocks * block_size;
-	cap->m = tsize;
-	cap->dp = 0;
-	cap->cunit = cu_byte;
-}
-
-/** Convert capacity to blocks.
- *
- * If the value of bytes is not integer, it is properly rounded. If the number
- * of bytes is not divisible by the number of blocks, it is rounded
- * up to an integer number of blocks.
- *
- * A capacity value entails precision, i.e. it corresponds to a range
- * of values. @a cvsel selects the value to return. @c cv_nom gives
- * the nominal (middle) value, @c cv_min gives the minimum value
- * and @c cv_max gives the maximum value.
- */
-errno_t cap_to_blocks(cap_spec_t *cap, cap_vsel_t cvsel, size_t block_size,
-    uint64_t *rblocks)
-{
-	int exp;
-	uint64_t bytes;
-	uint64_t f;
-	uint64_t adj;
-	uint64_t blocks;
-	uint64_t rem;
-	errno_t rc;
-
-	exp = cap->cunit * 3 - cap->dp;
-	if (exp < 0) {
-		rc = ipow10_u64(-exp, &f);
-		if (rc != EOK)
-			return ERANGE;
-		bytes = (cap->m + (f / 2)) / f;
-		if (bytes * f - (f / 2) != cap->m)
-			return ERANGE;
-	} else {
-		rc = ipow10_u64(exp, &f);
-		if (rc != EOK)
-			return ERANGE;
-
-		adj = 0;
-		switch (cvsel) {
-		case cv_nom:
-			adj = 0;
-			break;
-		case cv_min:
-			adj = -(f / 2);
-			break;
-		case cv_max:
-			adj = f / 2 - 1;
-			break;
-		}
-
-		bytes = cap->m * f + adj;
-		if ((bytes - adj) / f != cap->m)
-			return ERANGE;
-	}
-
-	rem = bytes % block_size;
-	if ((bytes + rem) < bytes)
-		return ERANGE;
-
-	blocks = (bytes + rem) / block_size;
-
-	*rblocks = blocks;
-	return EOK;
-}
-
-/** Simplify and round capacity to a human-friendly form.
- *
- * Change unit and round the number so that we have at most three integer
- * digits and at most two fractional digits, e.g abc.xy <unit>.
- */
-void cap_simplify(cap_spec_t *cap)
-{
-	uint64_t div;
-	uint64_t maxv;
-	unsigned sdig;
-	unsigned rdig;
-	errno_t rc;
-
-	/* Change units so that we have at most @c scap_max_idig integer digits */
-	rc = ipow10_u64(scap_max_idig, &maxv);
-	assert(rc == EOK);
-
-	rc = ipow10_u64(cap->dp, &div);
-	assert(rc == EOK);
-
-	while (cap->m / div >= maxv) {
-		++cap->cunit;
-		cap->dp += 3;
-		div = div * 1000;
-	}
-
-	/* Round the number so that we have at most @c scap_max_sdig significant digits */
-	sdig = 1 + ilog10_u64(cap->m); /* number of significant digits */
-	if (sdig > scap_max_sdig) {
-		/* Number of digits to remove */
-		rdig = sdig - scap_max_sdig;
-		if (rdig > cap->dp)
-			rdig = cap->dp;
-
-		rc = ipow10_u64(rdig, &div);
-		assert(rc == EOK);
-
-		cap->m = (cap->m + (div / 2)) / div;
-		cap->dp -= rdig;
-	}
-}
-
-errno_t cap_format(cap_spec_t *cap, char **rstr)
-{
-	errno_t rc;
-	int ret;
-	const char *sunit;
-	uint64_t ipart;
-	uint64_t fpart;
-	uint64_t div;
-
-	sunit = NULL;
-
-	assert(cap->cunit < CU_LIMIT);
-
-	rc = ipow10_u64(cap->dp, &div);
-	if (rc != EOK)
-		return rc;
-
-	ipart = cap->m / div;
-	fpart = cap->m % div;
-
-	sunit = cu_str[cap->cunit];
-	if (cap->dp > 0) {
-		ret = asprintf(rstr, "%" PRIu64 ".%0*" PRIu64 " %s", ipart,
-		    (int)cap->dp, fpart, sunit);
-	} else {
-		ret = asprintf(rstr, "%" PRIu64 " %s", ipart, sunit);
-	}
-	if (ret < 0)
-		return ENOMEM;
-
-	return EOK;
-}
-
-static errno_t cap_digit_val(char c, int *val)
-{
-	switch (c) {
-	case '0':
-		*val = 0;
-		break;
-	case '1':
-		*val = 1;
-		break;
-	case '2':
-		*val = 2;
-		break;
-	case '3':
-		*val = 3;
-		break;
-	case '4':
-		*val = 4;
-		break;
-	case '5':
-		*val = 5;
-		break;
-	case '6':
-		*val = 6;
-		break;
-	case '7':
-		*val = 7;
-		break;
-	case '8':
-		*val = 8;
-		break;
-	case '9':
-		*val = 9;
-		break;
-	default:
-		return EINVAL;
-	}
-
-	return EOK;
-}
-
-errno_t cap_parse(const char *str, cap_spec_t *cap)
-{
-	const char *eptr;
-	const char *p;
-	int d;
-	int dp;
-	unsigned long m;
-	int i;
-
-	m = 0;
-
-	eptr = str;
-	while (cap_digit_val(*eptr, &d) == EOK) {
-		m = m * 10 + d;
-		++eptr;
-	}
-
-	if (*eptr == '.') {
-		++eptr;
-		dp = 0;
-		while (cap_digit_val(*eptr, &d) == EOK) {
-			m = m * 10 + d;
-			++dp;
-			++eptr;
-		}
-	} else {
-		dp = 0;
-	}
-
-	while (*eptr == ' ')
-		++eptr;
-
-	if (*eptr == '\0') {
-		cap->cunit = cu_byte;
-	} else {
-		for (i = 0; i < CU_LIMIT; i++) {
-			if (str_lcasecmp(eptr, cu_str[i],
-			    str_length(cu_str[i])) == 0) {
-				p = eptr + str_size(cu_str[i]);
-				while (*p == ' ')
-					++p;
-				if (*p == '\0')
-					goto found;
-			}
-		}
-
-		return EINVAL;
-	found:
-		cap->cunit = i;
-	}
-
-	cap->m = m;
-	cap->dp = dp;
-	return EOK;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/capa.c
===================================================================
--- uspace/lib/c/generic/capa.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
+++ uspace/lib/c/generic/capa.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 2015 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/**
+ * @file Storage capacity specification.
+ */
+
+#include <capa.h>
+#include <errno.h>
+#include <imath.h>
+#include <stdio.h>
+#include <str.h>
+
+/** Simplified capacity parameters */
+enum {
+	/** Simplified capacity maximum integer digits */
+	scapa_max_idig = 3,
+	/** Simplified capacity maximum significant digits */
+	scapa_max_sdig = 4
+};
+
+static const char *cu_str[] = {
+	[cu_byte] = "B",
+	[cu_kbyte] = "kB",
+	[cu_mbyte] = "MB",
+	[cu_gbyte] = "GB",
+	[cu_tbyte] = "TB",
+	[cu_pbyte] = "PB",
+	[cu_ebyte] = "EB",
+	[cu_zbyte] = "ZB",
+	[cu_ybyte] = "YB"
+};
+
+void capa_from_blocks(uint64_t nblocks, size_t block_size, capa_spec_t *capa)
+{
+	uint64_t tsize;
+
+	tsize = nblocks * block_size;
+	capa->m = tsize;
+	capa->dp = 0;
+	capa->cunit = cu_byte;
+}
+
+/** Convert capacity to blocks.
+ *
+ * If the value of bytes is not integer, it is properly rounded. If the number
+ * of bytes is not divisible by the number of blocks, it is rounded
+ * up to an integer number of blocks.
+ *
+ * A capacity value entails precision, i.e. it corresponds to a range
+ * of values. @a cvsel selects the value to return. @c cv_nom gives
+ * the nominal (middle) value, @c cv_min gives the minimum value
+ * and @c cv_max gives the maximum value.
+ */
+errno_t capa_to_blocks(capa_spec_t *capa, capa_vsel_t cvsel, size_t block_size,
+    uint64_t *rblocks)
+{
+	int exp;
+	uint64_t bytes;
+	uint64_t f;
+	uint64_t adj;
+	uint64_t blocks;
+	uint64_t rem;
+	errno_t rc;
+
+	exp = capa->cunit * 3 - capa->dp;
+	if (exp < 0) {
+		rc = ipow10_u64(-exp, &f);
+		if (rc != EOK)
+			return ERANGE;
+		bytes = (capa->m + (f / 2)) / f;
+		if (bytes * f - (f / 2) != capa->m)
+			return ERANGE;
+	} else {
+		rc = ipow10_u64(exp, &f);
+		if (rc != EOK)
+			return ERANGE;
+
+		adj = 0;
+		switch (cvsel) {
+		case cv_nom:
+			adj = 0;
+			break;
+		case cv_min:
+			adj = -(f / 2);
+			break;
+		case cv_max:
+			adj = f / 2 - 1;
+			break;
+		}
+
+		bytes = capa->m * f + adj;
+		if ((bytes - adj) / f != capa->m)
+			return ERANGE;
+	}
+
+	rem = bytes % block_size;
+	if ((bytes + rem) < bytes)
+		return ERANGE;
+
+	blocks = (bytes + rem) / block_size;
+
+	*rblocks = blocks;
+	return EOK;
+}
+
+/** Simplify and round capacity to a human-friendly form.
+ *
+ * Change unit and round the number so that we have at most three integer
+ * digits and at most two fractional digits, e.g abc.xy <unit>.
+ */
+void capa_simplify(capa_spec_t *capa)
+{
+	uint64_t div;
+	uint64_t maxv;
+	unsigned sdig;
+	unsigned rdig;
+	errno_t rc;
+
+	/* Change units so that we have at most @c scapa_max_idig integer digits */
+	rc = ipow10_u64(scapa_max_idig, &maxv);
+	assert(rc == EOK);
+
+	rc = ipow10_u64(capa->dp, &div);
+	assert(rc == EOK);
+
+	while (capa->m / div >= maxv) {
+		++capa->cunit;
+		capa->dp += 3;
+		div = div * 1000;
+	}
+
+	/* Round the number so that we have at most @c scapa_max_sdig significant digits */
+	sdig = 1 + ilog10_u64(capa->m); /* number of significant digits */
+	if (sdig > scapa_max_sdig) {
+		/* Number of digits to remove */
+		rdig = sdig - scapa_max_sdig;
+		if (rdig > capa->dp)
+			rdig = capa->dp;
+
+		rc = ipow10_u64(rdig, &div);
+		assert(rc == EOK);
+
+		capa->m = (capa->m + (div / 2)) / div;
+		capa->dp -= rdig;
+	}
+}
+
+errno_t capa_format(capa_spec_t *capa, char **rstr)
+{
+	errno_t rc;
+	int ret;
+	const char *sunit;
+	uint64_t ipart;
+	uint64_t fpart;
+	uint64_t div;
+
+	sunit = NULL;
+
+	assert(capa->cunit < CU_LIMIT);
+
+	rc = ipow10_u64(capa->dp, &div);
+	if (rc != EOK)
+		return rc;
+
+	ipart = capa->m / div;
+	fpart = capa->m % div;
+
+	sunit = cu_str[capa->cunit];
+	if (capa->dp > 0) {
+		ret = asprintf(rstr, "%" PRIu64 ".%0*" PRIu64 " %s", ipart,
+		    (int)capa->dp, fpart, sunit);
+	} else {
+		ret = asprintf(rstr, "%" PRIu64 " %s", ipart, sunit);
+	}
+	if (ret < 0)
+		return ENOMEM;
+
+	return EOK;
+}
+
+static errno_t capa_digit_val(char c, int *val)
+{
+	switch (c) {
+	case '0':
+		*val = 0;
+		break;
+	case '1':
+		*val = 1;
+		break;
+	case '2':
+		*val = 2;
+		break;
+	case '3':
+		*val = 3;
+		break;
+	case '4':
+		*val = 4;
+		break;
+	case '5':
+		*val = 5;
+		break;
+	case '6':
+		*val = 6;
+		break;
+	case '7':
+		*val = 7;
+		break;
+	case '8':
+		*val = 8;
+		break;
+	case '9':
+		*val = 9;
+		break;
+	default:
+		return EINVAL;
+	}
+
+	return EOK;
+}
+
+errno_t capa_parse(const char *str, capa_spec_t *capa)
+{
+	const char *eptr;
+	const char *p;
+	int d;
+	int dp;
+	unsigned long m;
+	int i;
+
+	m = 0;
+
+	eptr = str;
+	while (capa_digit_val(*eptr, &d) == EOK) {
+		m = m * 10 + d;
+		++eptr;
+	}
+
+	if (*eptr == '.') {
+		++eptr;
+		dp = 0;
+		while (capa_digit_val(*eptr, &d) == EOK) {
+			m = m * 10 + d;
+			++dp;
+			++eptr;
+		}
+	} else {
+		dp = 0;
+	}
+
+	while (*eptr == ' ')
+		++eptr;
+
+	if (*eptr == '\0') {
+		capa->cunit = cu_byte;
+	} else {
+		for (i = 0; i < CU_LIMIT; i++) {
+			if (str_lcasecmp(eptr, cu_str[i],
+			    str_length(cu_str[i])) == 0) {
+				p = eptr + str_size(cu_str[i]);
+				while (*p == ' ')
+					++p;
+				if (*p == '\0')
+					goto found;
+			}
+		}
+
+		return EINVAL;
+	found:
+		capa->cunit = i;
+	}
+
+	capa->m = m;
+	capa->dp = dp;
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/c/include/cap.h
===================================================================
--- uspace/lib/c/include/cap.h	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ 	(revision )
@@ -1,101 +1,0 @@
-/*
- * Copyright (c) 2015 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/**
- * @file Storage capacity specification.
- */
-
-#ifndef _LIBC_CAP_H_
-#define _LIBC_CAP_H_
-
-#include <adt/list.h>
-#include <loc.h>
-#include <stdint.h>
-#include <types/label.h>
-#include <types/vol.h>
-#include <vbd.h>
-
-/** Capacity unit */
-typedef enum {
-	cu_byte = 0,
-	cu_kbyte,
-	cu_mbyte,
-	cu_gbyte,
-	cu_tbyte,
-	cu_pbyte,
-	cu_ebyte,
-	cu_zbyte,
-	cu_ybyte
-} cap_unit_t;
-
-/** Which of values within the precision of the capacity */
-typedef enum {
-	/** The nominal (middling) value */
-	cv_nom,
-	/** The minimum value */
-	cv_min,
-	/** The maximum value */
-	cv_max
-} cap_vsel_t;
-
-#define CU_LIMIT (cu_ybyte + 1)
-
-/** Storage capacity.
- *
- * Storage capacity represents both value and precision.
- * It is a decimal floating point value combined with a decimal
- * capacity unit. There is an integer mantisa @c m which in combination
- * with the number of decimal positions @c dp gives a decimal floating-point
- * number. E.g. for m = 1025 and dp = 2 the number is 10.25. If the unit
- * cunit = cu_kbyte, the capacity is 10.25 kByte, i.e. 10 250 bytes.
- *
- * Note that 1.000 kByte is equivalent to 1000 Byte, but 1 kByte is less
- * precise.
- */
-typedef struct {
-	/** Mantisa */
-	uint64_t m;
-	/** Decimal positions */
-	unsigned dp;
-	/** Capacity unit */
-	cap_unit_t cunit;
-} cap_spec_t;
-
-extern errno_t cap_format(cap_spec_t *, char **);
-extern errno_t cap_parse(const char *, cap_spec_t *);
-extern void cap_simplify(cap_spec_t *);
-extern void cap_from_blocks(uint64_t, size_t, cap_spec_t *);
-extern errno_t cap_to_blocks(cap_spec_t *, cap_vsel_t, size_t, uint64_t *);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/capa.h
===================================================================
--- uspace/lib/c/include/capa.h	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
+++ uspace/lib/c/include/capa.h	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2015 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/**
+ * @file Storage capacity specification.
+ */
+
+#ifndef _LIBC_CAP_H_
+#define _LIBC_CAP_H_
+
+#include <adt/list.h>
+#include <loc.h>
+#include <stdint.h>
+#include <types/label.h>
+#include <types/vol.h>
+#include <vbd.h>
+
+/** Capacity unit */
+typedef enum {
+	cu_byte = 0,
+	cu_kbyte,
+	cu_mbyte,
+	cu_gbyte,
+	cu_tbyte,
+	cu_pbyte,
+	cu_ebyte,
+	cu_zbyte,
+	cu_ybyte
+} capa_unit_t;
+
+/** Which of values within the precision of the capacity */
+typedef enum {
+	/** The nominal (middling) value */
+	cv_nom,
+	/** The minimum value */
+	cv_min,
+	/** The maximum value */
+	cv_max
+} capa_vsel_t;
+
+#define CU_LIMIT (cu_ybyte + 1)
+
+/** Storage capacity.
+ *
+ * Storage capacity represents both value and precision.
+ * It is a decimal floating point value combined with a decimal
+ * capacity unit. There is an integer mantisa @c m which in combination
+ * with the number of decimal positions @c dp gives a decimal floating-point
+ * number. E.g. for m = 1025 and dp = 2 the number is 10.25. If the unit
+ * cunit = cu_kbyte, the capacity is 10.25 kByte, i.e. 10 250 bytes.
+ *
+ * Note that 1.000 kByte is equivalent to 1000 Byte, but 1 kByte is less
+ * precise.
+ */
+typedef struct {
+	/** Mantisa */
+	uint64_t m;
+	/** Decimal positions */
+	unsigned dp;
+	/** Capacity unit */
+	capa_unit_t cunit;
+} capa_spec_t;
+
+extern errno_t capa_format(capa_spec_t *, char **);
+extern errno_t capa_parse(const char *, capa_spec_t *);
+extern void capa_simplify(capa_spec_t *);
+extern void capa_from_blocks(uint64_t, size_t, capa_spec_t *);
+extern errno_t capa_to_blocks(capa_spec_t *, capa_vsel_t, size_t, uint64_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/meson.build
===================================================================
--- uspace/lib/c/meson.build	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/lib/c/meson.build	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -65,5 +65,5 @@
 	'generic/bd_srv.c',
 	'generic/perm.c',
-	'generic/cap.c',
+	'generic/capa.c',
 	'generic/clipboard.c',
 	'generic/config.c',
@@ -204,5 +204,5 @@
 	'test/adt/circ_buf.c',
 	'test/adt/odict.c',
-	'test/cap.c',
+	'test/capa.c',
 	'test/casting.c',
 	'test/double_to_str.c',
Index: uspace/lib/c/test/cap.c
===================================================================
--- uspace/lib/c/test/cap.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ 	(revision )
@@ -1,287 +1,0 @@
-/*
- * Copyright (c) 2019 Matthieu Riolo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <pcut/pcut.h>
-#include <cap.h>
-
-PCUT_INIT;
-
-PCUT_TEST_SUITE(cap);
-
-PCUT_TEST(cap_format)
-{
-	int block_size = 4;
-	size_t block[] = {
-		0,
-		1,
-		2,
-		10,
-	};
-
-	int input_size = 5;
-	size_t input[] = {
-		0,
-		10,
-		100,
-		1000,
-		1000000,
-		1000000000,
-	};
-
-	const char *out[] = {
-		"0 B",
-		"0 B",
-		"0 B",
-		"0 B",
-
-		"0 B",
-		"10 B",
-		"20 B",
-		"100 B",
-
-		"0 B",
-		"100 B",
-		"200 B",
-		"1.000 kB",
-
-		"0 B",
-		"1.000 kB",
-		"2.000 kB",
-		"10.00 kB",
-
-		"0 B",
-		"1.000 MB",
-		"2.000 MB",
-		"10.00 MB",
-
-		"0 B",
-		"1.000 GB",
-		"2.000 GB",
-		"10.00 GB",
-	};
-
-	cap_spec_t cap;
-	char *str;
-	errno_t rc;
-
-	int x, i;
-	for (i = 0; i < input_size; i++) {
-		for (x = 0; x < block_size; x++) {
-			cap_from_blocks(input[i], block[x], &cap);
-			cap_simplify(&cap);
-
-			rc = cap_format(&cap, &str);
-
-			PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-			PCUT_ASSERT_STR_EQUALS(out[x + (block_size * i)], str);
-			free(str);
-
-			cap_from_blocks(block[x], input[i], &cap);
-			cap_simplify(&cap);
-
-			rc = cap_format(&cap, &str);
-
-			PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-			PCUT_ASSERT_STR_EQUALS(out[x + (block_size * i)], str);
-			free(str);
-		}
-	}
-}
-
-PCUT_TEST(cap_format_rounding)
-{
-	int input_size = 8;
-	uint64_t input[] = {
-		555,
-		5555,
-		55555,
-		555555555,
-		5555555555,
-		555999999,
-		5999999,
-		999999
-	};
-
-	const char *out[] = {
-		"555 B",
-		"5.555 kB",
-		"55.56 kB",
-		"555.6 MB",
-		"5.556 GB",
-		"556.0 MB",
-		"6.000 MB",
-		"1.000 MB",
-	};
-
-	cap_spec_t cap;
-	char *str;
-	errno_t rc;
-
-	int i;
-	for (i = 0; i < input_size; i++) {
-		cap_from_blocks(input[i], 1, &cap);
-		cap_simplify(&cap);
-
-		rc = cap_format(&cap, &str);
-
-		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-		PCUT_ASSERT_STR_EQUALS(out[i], str);
-		free(str);
-
-		cap_from_blocks(1, input[i], &cap);
-		cap_simplify(&cap);
-
-		rc = cap_format(&cap, &str);
-
-		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-		PCUT_ASSERT_STR_EQUALS(out[i], str);
-		free(str);
-	}
-}
-
-PCUT_TEST(cap_parse)
-{
-	int input_size = 4;
-	const char *input[] = {
-		"0 B",
-		"100 B",
-		"1 kB",
-		"1.555 kB",
-	};
-
-	int out_cunit[] = {
-		cu_byte,
-		cu_byte,
-		cu_kbyte,
-		cu_kbyte,
-	};
-
-	int out_dp[] = {
-		0,
-		0,
-		0,
-		3,
-	};
-
-	int out_m[] = {
-		0,
-		100,
-		1,
-		1555,
-	};
-
-	cap_spec_t cap;
-	errno_t rc;
-	int i;
-
-	for (i = 0; i < input_size; i++) {
-		rc = cap_parse(input[i], &cap);
-
-		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-		PCUT_ASSERT_INT_EQUALS(out_cunit[i], cap.cunit);
-		PCUT_ASSERT_INT_EQUALS(out_dp[i], cap.dp);
-		PCUT_ASSERT_INT_EQUALS(out_m[i], cap.m);
-	}
-}
-
-PCUT_TEST(cap_to_blocks)
-{
-	int input_size = 0;
-	int input_m[] = {
-		0,
-		1,
-		1000,
-		5555,
-		7777,
-	};
-
-	int input_dp[] = {
-		0,
-		0,
-		3,
-		3,
-		2,
-	};
-
-	int block[] = {
-		1,
-		1,
-		1,
-		2,
-		3,
-	};
-
-	int out_nom[] = {
-		0,
-		1000,
-		1000,
-		2778,
-		25923,
-	};
-
-	int out_min[] = {
-		0,
-		1000,
-		1000,
-		2777,
-		25923,
-	};
-
-	int out_max[] = {
-		0,
-		1000,
-		1000,
-		2778,
-		25924,
-	};
-
-	cap_spec_t cap;
-	errno_t rc;
-	int i;
-	uint64_t ret;
-
-	for (i = 0; i < input_size; i++) {
-		cap.m = input_m[i];
-		cap.dp = input_dp[i];
-		cap.cunit = cu_kbyte;
-
-		rc = cap_to_blocks(&cap, cv_nom, block[i], &ret);
-		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-		PCUT_ASSERT_INT_EQUALS(out_nom[i], ret);
-
-		rc = cap_to_blocks(&cap, cv_min, block[i], &ret);
-		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-		PCUT_ASSERT_INT_EQUALS(out_min[i], ret);
-
-		rc = cap_to_blocks(&cap, cv_max, block[i], &ret);
-		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-		PCUT_ASSERT_INT_EQUALS(out_max[i], ret);
-	}
-}
-
-PCUT_EXPORT(cap);
Index: uspace/lib/c/test/capa.c
===================================================================
--- uspace/lib/c/test/capa.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
+++ uspace/lib/c/test/capa.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2019 Matthieu Riolo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <pcut/pcut.h>
+#include <capa.h>
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(capa);
+
+PCUT_TEST(capa_format)
+{
+	int block_size = 4;
+	size_t block[] = {
+		0,
+		1,
+		2,
+		10,
+	};
+
+	int input_size = 5;
+	size_t input[] = {
+		0,
+		10,
+		100,
+		1000,
+		1000000,
+		1000000000,
+	};
+
+	const char *out[] = {
+		"0 B",
+		"0 B",
+		"0 B",
+		"0 B",
+
+		"0 B",
+		"10 B",
+		"20 B",
+		"100 B",
+
+		"0 B",
+		"100 B",
+		"200 B",
+		"1.000 kB",
+
+		"0 B",
+		"1.000 kB",
+		"2.000 kB",
+		"10.00 kB",
+
+		"0 B",
+		"1.000 MB",
+		"2.000 MB",
+		"10.00 MB",
+
+		"0 B",
+		"1.000 GB",
+		"2.000 GB",
+		"10.00 GB",
+	};
+
+	capa_spec_t capa;
+	char *str;
+	errno_t rc;
+
+	int x, i;
+	for (i = 0; i < input_size; i++) {
+		for (x = 0; x < block_size; x++) {
+			capa_from_blocks(input[i], block[x], &capa);
+			capa_simplify(&capa);
+
+			rc = capa_format(&capa, &str);
+
+			PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+			PCUT_ASSERT_STR_EQUALS(out[x + (block_size * i)], str);
+			free(str);
+
+			capa_from_blocks(block[x], input[i], &capa);
+			capa_simplify(&capa);
+
+			rc = capa_format(&capa, &str);
+
+			PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+			PCUT_ASSERT_STR_EQUALS(out[x + (block_size * i)], str);
+			free(str);
+		}
+	}
+}
+
+PCUT_TEST(capa_format_rounding)
+{
+	int input_size = 8;
+	uint64_t input[] = {
+		555,
+		5555,
+		55555,
+		555555555,
+		5555555555,
+		555999999,
+		5999999,
+		999999
+	};
+
+	const char *out[] = {
+		"555 B",
+		"5.555 kB",
+		"55.56 kB",
+		"555.6 MB",
+		"5.556 GB",
+		"556.0 MB",
+		"6.000 MB",
+		"1.000 MB",
+	};
+
+	capa_spec_t capa;
+	char *str;
+	errno_t rc;
+
+	int i;
+	for (i = 0; i < input_size; i++) {
+		capa_from_blocks(input[i], 1, &capa);
+		capa_simplify(&capa);
+
+		rc = capa_format(&capa, &str);
+
+		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+		PCUT_ASSERT_STR_EQUALS(out[i], str);
+		free(str);
+
+		capa_from_blocks(1, input[i], &capa);
+		capa_simplify(&capa);
+
+		rc = capa_format(&capa, &str);
+
+		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+		PCUT_ASSERT_STR_EQUALS(out[i], str);
+		free(str);
+	}
+}
+
+PCUT_TEST(capa_parse)
+{
+	int input_size = 4;
+	const char *input[] = {
+		"0 B",
+		"100 B",
+		"1 kB",
+		"1.555 kB",
+	};
+
+	int out_cunit[] = {
+		cu_byte,
+		cu_byte,
+		cu_kbyte,
+		cu_kbyte,
+	};
+
+	int out_dp[] = {
+		0,
+		0,
+		0,
+		3,
+	};
+
+	int out_m[] = {
+		0,
+		100,
+		1,
+		1555,
+	};
+
+	capa_spec_t capa;
+	errno_t rc;
+	int i;
+
+	for (i = 0; i < input_size; i++) {
+		rc = capa_parse(input[i], &capa);
+
+		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+		PCUT_ASSERT_INT_EQUALS(out_cunit[i], capa.cunit);
+		PCUT_ASSERT_INT_EQUALS(out_dp[i], capa.dp);
+		PCUT_ASSERT_INT_EQUALS(out_m[i], capa.m);
+	}
+}
+
+PCUT_TEST(capa_to_blocks)
+{
+	int input_size = 0;
+	int input_m[] = {
+		0,
+		1,
+		1000,
+		5555,
+		7777,
+	};
+
+	int input_dp[] = {
+		0,
+		0,
+		3,
+		3,
+		2,
+	};
+
+	int block[] = {
+		1,
+		1,
+		1,
+		2,
+		3,
+	};
+
+	int out_nom[] = {
+		0,
+		1000,
+		1000,
+		2778,
+		25923,
+	};
+
+	int out_min[] = {
+		0,
+		1000,
+		1000,
+		2777,
+		25923,
+	};
+
+	int out_max[] = {
+		0,
+		1000,
+		1000,
+		2778,
+		25924,
+	};
+
+	capa_spec_t capa;
+	errno_t rc;
+	int i;
+	uint64_t ret;
+
+	for (i = 0; i < input_size; i++) {
+		capa.m = input_m[i];
+		capa.dp = input_dp[i];
+		capa.cunit = cu_kbyte;
+
+		rc = capa_to_blocks(&capa, cv_nom, block[i], &ret);
+		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+		PCUT_ASSERT_INT_EQUALS(out_nom[i], ret);
+
+		rc = capa_to_blocks(&capa, cv_min, block[i], &ret);
+		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+		PCUT_ASSERT_INT_EQUALS(out_min[i], ret);
+
+		rc = capa_to_blocks(&capa, cv_max, block[i], &ret);
+		PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+		PCUT_ASSERT_INT_EQUALS(out_max[i], ret);
+	}
+}
+
+PCUT_EXPORT(capa);
Index: uspace/lib/c/test/main.c
===================================================================
--- uspace/lib/c/test/main.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/lib/c/test/main.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -32,5 +32,5 @@
 PCUT_INIT;
 
-PCUT_IMPORT(cap);
+PCUT_IMPORT(capa);
 PCUT_IMPORT(casting);
 PCUT_IMPORT(circ_buf);
Index: uspace/lib/fdisk/include/fdisk.h
===================================================================
--- uspace/lib/fdisk/include/fdisk.h	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/lib/fdisk/include/fdisk.h	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -50,5 +50,5 @@
 extern errno_t fdisk_dev_info_get_svcname(fdisk_dev_info_t *, char **);
 extern void fdisk_dev_info_get_svcid(fdisk_dev_info_t *, service_id_t *);
-extern errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *, cap_spec_t *);
+extern errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *, capa_spec_t *);
 
 extern errno_t fdisk_dev_open(fdisk_t *, service_id_t, fdisk_dev_t **);
@@ -57,5 +57,5 @@
 extern void fdisk_dev_get_flags(fdisk_dev_t *, fdisk_dev_flags_t *);
 extern errno_t fdisk_dev_get_svcname(fdisk_dev_t *, char **);
-extern errno_t fdisk_dev_capacity(fdisk_dev_t *, cap_spec_t *);
+extern errno_t fdisk_dev_capacity(fdisk_dev_t *, capa_spec_t *);
 
 extern errno_t fdisk_label_get_info(fdisk_dev_t *, fdisk_label_info_t *);
@@ -66,6 +66,6 @@
 extern fdisk_part_t *fdisk_part_next(fdisk_part_t *);
 extern errno_t fdisk_part_get_info(fdisk_part_t *, fdisk_part_info_t *);
-extern errno_t fdisk_part_get_max_avail(fdisk_dev_t *, fdisk_spc_t, cap_spec_t *);
-extern errno_t fdisk_part_get_tot_avail(fdisk_dev_t *, fdisk_spc_t, cap_spec_t *);
+extern errno_t fdisk_part_get_max_avail(fdisk_dev_t *, fdisk_spc_t, capa_spec_t *);
+extern errno_t fdisk_part_get_tot_avail(fdisk_dev_t *, fdisk_spc_t, capa_spec_t *);
 extern errno_t fdisk_part_create(fdisk_dev_t *, fdisk_part_spec_t *,
     fdisk_part_t **);
Index: uspace/lib/fdisk/include/types/fdisk.h
===================================================================
--- uspace/lib/fdisk/include/types/fdisk.h	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/lib/fdisk/include/types/fdisk.h	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -38,5 +38,5 @@
 
 #include <adt/list.h>
-#include <cap.h>
+#include <capa.h>
 #include <loc.h>
 #include <stdint.h>
@@ -126,5 +126,5 @@
 	link_t llog_ba;
 	/** Capacity */
-	cap_spec_t capacity;
+	capa_spec_t capacity;
 	/** Partition kind */
 	label_pkind_t pkind;
@@ -150,5 +150,5 @@
 typedef struct {
 	/** Desired capacity */
-	cap_spec_t capacity;
+	capa_spec_t capacity;
 	/** Partition kind */
 	label_pkind_t pkind;
@@ -164,5 +164,5 @@
 typedef struct {
 	/** Capacity */
-	cap_spec_t capacity;
+	capa_spec_t capacity;
 	/** Partition kind */
 	label_pkind_t pkind;
Index: uspace/lib/fdisk/src/fdisk.c
===================================================================
--- uspace/lib/fdisk/src/fdisk.c	(revision ef0a337536dea5e67feaaa52cb69f9062971fec0)
+++ uspace/lib/fdisk/src/fdisk.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
@@ -35,5 +35,5 @@
 
 #include <adt/list.h>
-#include <cap.h>
+#include <capa.h>
 #include <errno.h>
 #include <fdisk.h>
@@ -219,5 +219,5 @@
 }
 
-errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *info, cap_spec_t *cap)
+errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *info, capa_spec_t *capa)
 {
 	vbd_disk_info_t vinfo;
@@ -228,5 +228,5 @@
 		return EIO;
 
-	cap_from_blocks(vinfo.nblocks, vinfo.block_size, cap);
+	capa_from_blocks(vinfo.nblocks, vinfo.block_size, capa);
 	return EOK;
 }
@@ -295,5 +295,5 @@
 		dev->ext_part = part;
 
-	cap_from_blocks(part->nblocks, dev->dinfo.block_size,
+	capa_from_blocks(part->nblocks, dev->dinfo.block_size,
 	    &part->capacity);
 	part->part_id = partid;
@@ -536,7 +536,7 @@
 }
 
-errno_t fdisk_dev_capacity(fdisk_dev_t *dev, cap_spec_t *cap)
-{
-	cap_from_blocks(dev->dinfo.nblocks, dev->dinfo.block_size, cap);
+errno_t fdisk_dev_capacity(fdisk_dev_t *dev, capa_spec_t *capa)
+{
+	capa_from_blocks(dev->dinfo.nblocks, dev->dinfo.block_size, capa);
 	return EOK;
 }
@@ -679,5 +679,6 @@
 
 /** Get size of largest free block. */
-errno_t fdisk_part_get_max_avail(fdisk_dev_t *dev, fdisk_spc_t spc, cap_spec_t *cap)
+errno_t fdisk_part_get_max_avail(fdisk_dev_t *dev, fdisk_spc_t spc,
+    capa_spec_t *capa)
 {
 	errno_t rc;
@@ -698,5 +699,5 @@
 	}
 
-	cap_from_blocks(nb, dev->dinfo.block_size, cap);
+	capa_from_blocks(nb, dev->dinfo.block_size, capa);
 	return EOK;
 }
@@ -704,5 +705,5 @@
 /** Get total free space capacity. */
 errno_t fdisk_part_get_tot_avail(fdisk_dev_t *dev, fdisk_spc_t spc,
-    cap_spec_t *cap)
+    capa_spec_t *capa)
 {
 	fdisk_free_range_t fr;
@@ -726,5 +727,5 @@
 	} while (fdisk_free_range_next(&fr));
 
-	cap_from_blocks(totb, dev->dinfo.block_size, cap);
+	capa_from_blocks(totb, dev->dinfo.block_size, capa);
 	return EOK;
 }
@@ -938,15 +939,15 @@
 	errno_t rc;
 
-	rc = cap_to_blocks(&pspec->capacity, cv_nom, dev->dinfo.block_size,
+	rc = capa_to_blocks(&pspec->capacity, cv_nom, dev->dinfo.block_size,
 	    &nom_blocks);
 	if (rc != EOK)
 		return rc;
 
-	rc = cap_to_blocks(&pspec->capacity, cv_min, dev->dinfo.block_size,
+	rc = capa_to_blocks(&pspec->capacity, cv_min, dev->dinfo.block_size,
 	    &min_blocks);
 	if (rc != EOK)
 		return rc;
 
-	rc = cap_to_blocks(&pspec->capacity, cv_max, dev->dinfo.block_size,
+	rc = capa_to_blocks(&pspec->capacity, cv_max, dev->dinfo.block_size,
 	    &max_blocks);
 	if (rc != EOK)
