branches: add per branch minfreespace w/ original value as default

example: /mnt/disk0=RW,1G:/mnt/disk1=RW,2G
This commit is contained in:
Antonio SJ Musumeci
2020-09-04 21:04:45 -04:00
parent 98c49b8001
commit fc3453932a
68 changed files with 3005 additions and 813 deletions
+33 -1
View File
@@ -14,11 +14,19 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "ef.hpp"
#include <string>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string>
#define KB (1024UL)
#define MB (KB * 1024UL)
#define GB (MB * 1024UL)
#define TB (GB * 1024UL)
namespace num
{
@@ -98,3 +106,27 @@ namespace num
return 0;
}
}
namespace num
{
std::string
humanize(const uint64_t bytes_)
{
char buf[64];
if(bytes_ < KB)
sprintf(buf,"%lu",bytes_);
ef(((bytes_ / TB) * TB) == bytes_)
sprintf(buf,"%luT",bytes_ / TB);
ef(((bytes_ / GB) * GB) == bytes_)
sprintf(buf,"%luG",bytes_ / GB);
ef(((bytes_ / MB) * MB) == bytes_)
sprintf(buf,"%luM",bytes_ / MB);
ef(((bytes_ / KB) * KB) == bytes_)
sprintf(buf,"%luK",bytes_ / KB);
else
sprintf(buf,"%lu",bytes_);
return std::string(buf);
}
}