create minfreespace option. closes #71

This commit is contained in:
Antonio SJ Musumeci 2015-06-16 22:12:55 -04:00
parent ad7ce487bb
commit ccb22c1fbe
26 changed files with 171 additions and 84 deletions

View file

@ -27,6 +27,7 @@
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
@ -100,6 +101,38 @@ set_default_options(struct fuse_args &args)
set_option(args,"atomic_o_trunc");
}
static
int
parse_and_process_minfreespace(const std::string &value,
size_t &minfreespace)
{
char *endptr;
minfreespace = strtoll(value.c_str(),&endptr,10);
switch(*endptr)
{
case 'k':
case 'K':
minfreespace *= 1024;
break;
case 'm':
case 'M':
minfreespace *= (1024 * 1024);
break;
case 'b':
case 'B':
minfreespace *= (1024 * 1024 * 1024);
break;
default:
return 1;
}
return 0;
}
static
int
parse_and_process_arg(config::Config &config,
@ -121,19 +154,22 @@ parse_and_process_kv_arg(config::Config &config,
const std::string &key,
const std::string &value)
{
int rv;
int rv = -1;
std::vector<std::string> keypart;
str::split(keypart,key,'.');
if(keypart.size() != 2)
return 1;
if(keypart[0] == "func")
rv = config.set_func_policy(keypart[1],value);
else if(keypart[0] == "category")
rv = config.set_category_policy(keypart[1],value);
if(keypart.size() == 2)
{
if(keypart[0] == "func")
rv = config.set_func_policy(keypart[1],value);
else if(keypart[0] == "category")
rv = config.set_category_policy(keypart[1],value);
}
else
rv = -1;
{
if(key == "minfreespace")
rv = parse_and_process_minfreespace(value,config.minfreespace);
}
if(rv == -1)
rv = 1;