mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
moveonenospc: enhance the feature to allow using a policy
Just like functions you can now set a policy for moveonfreenospc. This allows for more flexibility. For backwards compatibility moveonfreenospc=true is converted to moveonfreenospc=mfs. minfreespace does apply which is slightly different from original behavior.
This commit is contained in:
parent
f2d4fbfdb2
commit
08d267fc61
23 changed files with 483 additions and 148 deletions
|
|
@ -19,13 +19,16 @@
|
|||
#include "errno.hpp"
|
||||
#include "fs_base_open.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
using std::string;
|
||||
|
||||
#define PADLEN 6
|
||||
#define MAX_ATTEMPTS 10
|
||||
|
||||
static
|
||||
string
|
||||
generate_tmp_path(const string &base_)
|
||||
|
|
@ -33,8 +36,10 @@ generate_tmp_path(const string &base_)
|
|||
string tmp;
|
||||
|
||||
tmp = base_;
|
||||
tmp += '_';
|
||||
for(int i = 0; i < 6; i++)
|
||||
if((tmp.size() + PADLEN + 1) > PATH_MAX)
|
||||
tmp.resize(tmp.size() - PADLEN - 1);
|
||||
tmp += '.';
|
||||
for(int i = 0; i < PADLEN; i++)
|
||||
tmp += ('A' + (std::rand() % 26));
|
||||
|
||||
return tmp;
|
||||
|
|
@ -52,7 +57,7 @@ namespace fs
|
|||
string tmppath;
|
||||
|
||||
fd = -1;
|
||||
count = 10;
|
||||
count = MAX_ATTEMPTS;
|
||||
flags = (flags_ | O_EXCL | O_CREAT);
|
||||
while(count-- > 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue