limit need to explicitly call .c_str()

This commit is contained in:
Antonio SJ Musumeci 2016-12-22 15:53:17 -05:00
parent 7b4e1ea36d
commit e93c946198
8 changed files with 96 additions and 10 deletions

32
src/fs_base_remove.hpp Normal file
View file

@ -0,0 +1,32 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <string>
#include <stdio.h>
namespace fs
{
static
inline
int
remove(const std::string &pathname)
{
return ::remove(pathname.c_str());
}
}

42
src/fs_base_symlink.hpp Normal file
View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <string>
#include <unistd.h>
namespace fs
{
static
inline
int
symlink(const std::string &oldpath,
const std::string &newpath)
{
return ::symlink(oldpath.c_str(),newpath.c_str());
}
static
inline
int
symlink(const char *oldpath,
const std::string &newpath)
{
return ::symlink(oldpath,newpath.c_str());
}
}

View file

@ -23,6 +23,7 @@
#include "fs_base_mkdir.hpp"
#include "fs_base_stat.hpp"
#include "fs_base_utime.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "fs_xattr.hpp"
@ -62,7 +63,7 @@ namespace fs
fs::path::dirname(dirname);
if(!dirname.empty())
{
rv = fs::clonepath(fromsrc,tosrc,dirname.c_str());
rv = fs::clonepath(fromsrc,tosrc,dirname);
if(rv == -1)
return -1;
}
@ -105,4 +106,12 @@ namespace fs
return 0;
}
int
clonepath(const std::string &from,
const std::string &to,
const std::string &relative)
{
return fs::clonepath(from,to,relative.c_str());
}
}

View file

@ -21,4 +21,7 @@ namespace fs
int clonepath(const std::string &from,
const std::string &to,
const char *relative);
int clonepath(const std::string &from,
const std::string &to,
const std::string &relative);
}

View file

@ -72,7 +72,7 @@ namespace fs
fusedir = fusepath;
fs::path::dirname(fusedir);
rv = fs::clonepath(fdin_path,fdout_path,fusedir.c_str());
rv = fs::clonepath(fdin_path,fdout_path,fusedir);
if(rv == -1)
return -1;
@ -91,7 +91,7 @@ namespace fs
{
fs::close(fdin);
fs::close(fdout);
fs::unlink(fdout_path.c_str());
fs::unlink(fdout_path);
return -1;
}

View file

@ -49,7 +49,7 @@ _link_create_path_core(const string &oldbasepath,
if(oldbasepath != newbasepath)
{
const ugid::SetRootGuard ugidGuard;
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath);
if(rv == -1)
return errno;
}

View file

@ -21,6 +21,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_remove.hpp"
#include "fs_base_rename.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
@ -32,7 +33,6 @@
using std::string;
using std::vector;
using std::set;
using mergerfs::Policy;
using namespace mergerfs;
static
@ -54,7 +54,7 @@ void
_remove(const vector<string> &toremove)
{
for(size_t i = 0, ei = toremove.size(); i != ei; i++)
::remove(toremove[i].c_str());
fs::remove(toremove[i]);
}
static
@ -70,7 +70,7 @@ _rename(const std::string &oldbasepath,
if(oldbasepath != newbasepath)
{
const ugid::SetRootGuard guard;
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath);
if(rv == -1)
return -1;
}
@ -173,7 +173,7 @@ _clonepath(Policy::Func::Search searchFunc,
{
const ugid::SetRootGuard ugidGuard;
fs::clonepath(*srcbasepath[0],dstbasepath,fusedirpath.c_str());
fs::clonepath(*srcbasepath[0],dstbasepath,fusedirpath);
}
return POLICY_SUCCESS;

View file

@ -23,6 +23,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_symlink.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
@ -31,7 +32,6 @@
using std::string;
using std::vector;
using mergerfs::Policy;
using namespace mergerfs;
static
@ -56,7 +56,7 @@ _symlink_loop_core(const string &existingpath,
fs::path::make(&newbasepath,newpath,fullnewpath);
rv = ::symlink(oldpath,fullnewpath.c_str());
rv = fs::symlink(oldpath,fullnewpath);
return error::calc(rv,error,errno);
}