mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-11-25 17:57:41 +08:00
check minfreespace on newest policy create
This commit is contained in:
parent
bd792757e0
commit
dfa1c1ad6f
|
@ -17,6 +17,7 @@
|
||||||
#include "errno.hpp"
|
#include "errno.hpp"
|
||||||
#include "fs.hpp"
|
#include "fs.hpp"
|
||||||
#include "fs_exists.hpp"
|
#include "fs_exists.hpp"
|
||||||
|
#include "fs_info.hpp"
|
||||||
#include "fs_path.hpp"
|
#include "fs_path.hpp"
|
||||||
#include "policy.hpp"
|
#include "policy.hpp"
|
||||||
#include "policy_error.hpp"
|
#include "policy_error.hpp"
|
||||||
|
@ -36,13 +37,14 @@ namespace newest
|
||||||
int
|
int
|
||||||
create(const Branches &branches_,
|
create(const Branches &branches_,
|
||||||
const char *fusepath,
|
const char *fusepath,
|
||||||
|
const uint64_t minfreespace,
|
||||||
vector<const string*> &paths)
|
vector<const string*> &paths)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
int error;
|
int error;
|
||||||
bool readonly;
|
|
||||||
time_t newest;
|
time_t newest;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
fs::info_t info;
|
||||||
const Branch *branch;
|
const Branch *branch;
|
||||||
const string *newestbasepath;
|
const string *newestbasepath;
|
||||||
|
|
||||||
|
@ -59,11 +61,13 @@ namespace newest
|
||||||
error_and_continue(error,EROFS);
|
error_and_continue(error,EROFS);
|
||||||
if(st.st_mtime < newest)
|
if(st.st_mtime < newest)
|
||||||
continue;
|
continue;
|
||||||
rv = fs::readonly(&branch->path,&readonly);
|
rv = fs::info(&branch->path,&info);
|
||||||
if(rv == -1)
|
if(rv == -1)
|
||||||
error_and_continue(error,ENOENT);
|
error_and_continue(error,ENOENT);
|
||||||
if(readonly)
|
if(info.readonly)
|
||||||
error_and_continue(error,EROFS);
|
error_and_continue(error,EROFS);
|
||||||
|
if(info.spaceavail < minfreespace)
|
||||||
|
error_and_continue(error,ENOSPC);
|
||||||
|
|
||||||
newest = st.st_mtime;
|
newest = st.st_mtime;
|
||||||
newestbasepath = &branch->path;
|
newestbasepath = &branch->path;
|
||||||
|
@ -169,7 +173,7 @@ namespace mergerfs
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Category::Enum::create:
|
case Category::Enum::create:
|
||||||
return newest::create(branches_,fusepath,paths);
|
return newest::create(branches_,fusepath,minfreespace,paths);
|
||||||
case Category::Enum::action:
|
case Category::Enum::action:
|
||||||
return newest::action(branches_,fusepath,paths);
|
return newest::action(branches_,fusepath,paths);
|
||||||
case Category::Enum::search:
|
case Category::Enum::search:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user