Browse Source

Merge pull request #402 from trapexit/nopath

enable nopath and nullpath_ok
pull/403/head
Antonio SJ Musumeci 8 years ago
committed by GitHub
parent
commit
f95b07f83b
  1. 10
      src/config.hpp
  2. 2
      src/create.cpp
  3. 34
      src/dirinfo.hpp
  4. 2
      src/fgetattr.cpp
  5. 9
      src/fileinfo.hpp
  6. 2
      src/flush.cpp
  7. 4
      src/fs_base_fsync.hpp
  8. 6
      src/fs_base_ioctl.hpp
  9. 7
      src/fsync.cpp
  10. 53
      src/fsyncdir.cpp
  11. 33
      src/fsyncdir.hpp
  12. 3
      src/ftruncate.cpp
  13. 38
      src/ioctl.cpp
  14. 7
      src/mergerfs.cpp
  15. 2
      src/open.cpp
  16. 4
      src/opendir.cpp
  17. 4
      src/read.cpp
  18. 13
      src/readdir.cpp
  19. 5
      src/release.cpp
  20. 15
      src/releasedir.cpp
  21. 10
      src/write.cpp

10
src/config.hpp

@ -77,6 +77,16 @@ namespace mergerfs
const std::string controlfile;
public:
static
const
Config &
get(void)
{
const fuse_context *fc = fuse_get_context();
return get(fc);
}
static
const Config &
get(const fuse_context *fc)

2
src/create.cpp

@ -75,7 +75,7 @@ _create_core(const string &existingpath,
if(rv == -1)
return -errno;
fh = reinterpret_cast<uint64_t>(new FileInfo(rv));
fh = reinterpret_cast<uint64_t>(new FileInfo(rv,fusepath));
return 0;
}

34
src/dirinfo.hpp

@ -0,0 +1,34 @@
/*
Copyright (c) 2017, 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.
*/
#ifndef __DIRINFO_HPP__
#define __DIRINFO_HPP__
#include <string>
class DirInfo
{
public:
DirInfo(const char *fusepath_)
: fusepath(fusepath_)
{
}
public:
std::string fusepath;
};
#endif

2
src/fgetattr.cpp

@ -48,7 +48,7 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _fgetattr(fi->fd,*st);
return ::_fgetattr(fi->fd,*st);
}
}
}

9
src/fileinfo.hpp

@ -17,16 +17,21 @@
#ifndef __FILEINFO_HPP__
#define __FILEINFO_HPP__
#include <string>
class FileInfo
{
public:
FileInfo(int _fd) :
fd(_fd)
FileInfo(const int fd_,
const char *fusepath_)
: fd(fd_),
fusepath(fusepath_)
{
}
public:
int fd;
std::string fusepath;
};
#endif

2
src/flush.cpp

@ -46,7 +46,7 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _flush(fi->fd);
return ::_flush(fi->fd);
}
}
}

4
src/fs_base_fsync.hpp

@ -19,6 +19,10 @@
#ifndef __FS_BASE_FSYNC_HPP__
#define __FS_BASE_FSYNC_HPP__
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <unistd.h>
#include "errno.hpp"

6
src/fs_base_ioctl.hpp

@ -26,9 +26,9 @@ namespace fs
static
inline
int
ioctl(const int fd,
const int request,
void *data)
ioctl(const int fd,
const unsigned long request,
void *data)
{
return ::ioctl(fd,request,data);
}

7
src/fsync.cpp

@ -14,10 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <fuse.h>
#include <string>
@ -52,8 +48,7 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _fsync(fi->fd,
isdatasync);
return ::_fsync(fi->fd,isdatasync);
}
}
}

53
src/fsyncdir.cpp

@ -0,0 +1,53 @@
/*
Copyright (c) 2017, 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 <fuse.h>
#include <string>
#include <vector>
#include "errno.hpp"
#include "dirinfo.hpp"
#include "fs_base_fsync.hpp"
static
int
_fsyncdir(const DirInfo *di,
const int isdatasync)
{
int rv;
rv = -1;
errno = ENOSYS;
return ((rv == -1) ? -errno : 0);
}
namespace mergerfs
{
namespace fuse
{
int
fsyncdir(const char *fusepath,
int isdatasync,
fuse_file_info *ffi)
{
DirInfo *di = reinterpret_cast<DirInfo*>(ffi->fh);
return ::_fsyncdir(di,isdatasync);
}
}
}

33
src/fsyncdir.hpp

@ -0,0 +1,33 @@
/*
Copyright (c) 2017, 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.
*/
#ifndef __FSYNCDIR_HPP__
#define __FSYNCDIR_HPP__
#include <fuse.h>
namespace mergerfs
{
namespace fuse
{
int
fsyncdir(const char *fusepath,
int isdatasync,
fuse_file_info *ffi);
}
}
#endif

3
src/ftruncate.cpp

@ -43,8 +43,7 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _ftruncate(fi->fd,
size);
return ::_ftruncate(fi->fd,size);
}
}
}

38
src/ioctl.cpp

@ -22,6 +22,7 @@
#include <fcntl.h>
#include "config.hpp"
#include "dirinfo.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_close.hpp"
@ -37,9 +38,9 @@ using namespace mergerfs;
static
int
_ioctl(const int fd,
const int cmd,
void *data)
_ioctl(const int fd,
const unsigned long cmd,
void *data)
{
int rv;
@ -48,6 +49,17 @@ _ioctl(const int fd,
return ((rv == -1) ? -errno : rv);
}
static
int
_ioctl_file(fuse_file_info *ffi,
const unsigned long cmd,
void *data)
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _ioctl(fi->fd,cmd,data);
}
#ifdef FUSE_IOCTL_DIR
#ifndef O_NOATIME
@ -60,7 +72,7 @@ _ioctl_dir_base(Policy::Func::Search searchFunc,
const vector<string> &srcmounts,
const uint64_t minfreespace,
const char *fusepath,
const int cmd,
const unsigned long cmd,
void *data)
{
int fd;
@ -88,10 +100,11 @@ _ioctl_dir_base(Policy::Func::Search searchFunc,
static
int
_ioctl_dir(const char *fusepath,
const int cmd,
void *data)
_ioctl_dir(fuse_file_info *ffi,
const unsigned long cmd,
void *data)
{
DirInfo *di = reinterpret_cast<DirInfo*>(ffi->fh);
const fuse_context *fc = fuse_get_context();
const Config &config = Config::get(fc);
const ugid::Set ugid(fc->uid,fc->gid);
@ -100,7 +113,7 @@ _ioctl_dir(const char *fusepath,
return _ioctl_dir_base(config.getattr,
config.srcmounts,
config.minfreespace,
fusepath,
di->fusepath.c_str(),
cmd,
data);
}
@ -120,15 +133,10 @@ namespace mergerfs
{
#ifdef FUSE_IOCTL_DIR
if(flags & FUSE_IOCTL_DIR)
return _ioctl_dir(fusepath,
cmd,
data);
return ::_ioctl_dir(ffi,cmd,data);
#endif
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _ioctl(fi->fd,
cmd,
data);
return ::_ioctl_file(ffi,cmd,data);
}
}
}

7
src/mergerfs.cpp

@ -35,6 +35,7 @@
#include "flock.hpp"
#include "flush.hpp"
#include "fsync.hpp"
#include "fsyncdir.hpp"
#include "ftruncate.hpp"
#include "getattr.hpp"
#include "getxattr.hpp"
@ -71,9 +72,9 @@ namespace local
get_fuse_operations(struct fuse_operations &ops,
const bool direct_io)
{
ops.flag_nullpath_ok = false;
ops.flag_nullpath_ok = true;
#if FLAG_NOPATH
ops.flag_nopath = false;
ops.flag_nopath = true;
#endif
#if FLAG_UTIME
ops.flag_utime_omit_ok = true;
@ -94,7 +95,7 @@ namespace local
#endif
ops.flush = mergerfs::fuse::flush;
ops.fsync = mergerfs::fuse::fsync;
ops.fsyncdir = NULL;
ops.fsyncdir = mergerfs::fuse::fsyncdir;
ops.ftruncate = mergerfs::fuse::ftruncate;
ops.getattr = mergerfs::fuse::getattr;
ops.getdir = NULL; /* deprecated; use readdir */

2
src/open.cpp

@ -49,7 +49,7 @@ _open_core(const string *basepath,
if(fd == -1)
return -errno;
fh = reinterpret_cast<uint64_t>(new FileInfo(fd));
fh = reinterpret_cast<uint64_t>(new FileInfo(fd,fusepath));
return 0;
}

4
src/opendir.cpp

@ -16,6 +16,8 @@
#include <fuse.h>
#include "dirinfo.hpp"
namespace mergerfs
{
namespace fuse
@ -24,7 +26,7 @@ namespace mergerfs
opendir(const char *fusepath,
fuse_file_info *ffi)
{
ffi->fh = 0;
ffi->fh = reinterpret_cast<uint64_t>(new DirInfo(fusepath));
return 0;
}

4
src/read.cpp

@ -73,7 +73,7 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _read(fi->fd,buf,count,offset);
return ::_read(fi->fd,buf,count,offset);
}
int
@ -85,7 +85,7 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _read_direct_io(fi->fd,buf,count,offset);
return ::_read_direct_io(fi->fd,buf,count,offset);
}
}
}

13
src/readdir.cpp

@ -23,6 +23,7 @@
#include <vector>
#include "config.hpp"
#include "dirinfo.hpp"
#include "errno.hpp"
#include "fs_base_closedir.hpp"
#include "fs_base_dirfd.hpp"
@ -39,7 +40,6 @@
using std::string;
using std::vector;
using std::pair;
#define NO_OFFSET 0
@ -103,17 +103,18 @@ namespace mergerfs
void *buf,
fuse_fill_dir_t filler,
off_t offset,
fuse_file_info *fi)
fuse_file_info *ffi)
{
DirInfo *di = reinterpret_cast<DirInfo*>(ffi->fh);
const fuse_context *fc = fuse_get_context();
const Config &config = Config::get(fc);
const ugid::Set ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
return _readdir(config.srcmounts,
fusepath,
buf,
filler);
return ::_readdir(config.srcmounts,
di->fusepath.c_str(),
buf,
filler);
}
}
}

5
src/release.cpp

@ -52,9 +52,8 @@ namespace mergerfs
release(const char *fusepath,
fuse_file_info *ffi)
{
const fuse_context *fc = fuse_get_context();
const Config &config = Config::get(fc);
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
const Config &config = Config::get();
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _release(fi,config.dropcacheonclose);
}

15
src/releasedir.cpp

@ -16,6 +16,17 @@
#include <fuse.h>
#include "dirinfo.hpp"
static
int
_releasedir(DirInfo *di)
{
delete di;
return 0;
}
namespace mergerfs
{
namespace fuse
@ -24,7 +35,9 @@ namespace mergerfs
releasedir(const char *fusepath,
fuse_file_info *ffi)
{
return 0;
DirInfo *di = reinterpret_cast<DirInfo*>(ffi->fh);
return ::_releasedir(di);
}
}
}

10
src/write.cpp

@ -72,9 +72,6 @@ _write_direct_io(const int fd,
return rv;
}
namespace mergerfs
{
namespace fuse
@ -83,7 +80,6 @@ namespace mergerfs
inline
int
write(WriteFunc func,
const char *fusepath,
const char *buf,
const size_t count,
const off_t offset,
@ -103,7 +99,7 @@ namespace mergerfs
const ugid::Set ugid(0,0);
const rwlock::ReadGuard readlock(&config.srcmountslock);
rv = fs::movefile(config.srcmounts,fusepath,count,fi->fd);
rv = fs::movefile(config.srcmounts,fi->fusepath,count,fi->fd);
if(rv == -1)
return -ENOSPC;
@ -121,7 +117,7 @@ namespace mergerfs
off_t offset,
fuse_file_info *ffi)
{
return write(_write,fusepath,buf,count,offset,ffi);
return write(_write,buf,count,offset,ffi);
}
int
@ -131,7 +127,7 @@ namespace mergerfs
off_t offset,
fuse_file_info *ffi)
{
return write(_write_direct_io,fusepath,buf,count,offset,ffi);
return write(_write_direct_io,buf,count,offset,ffi);
}
}
}
Loading…
Cancel
Save