mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-11-25 17:57:41 +08:00
Merge pull request #57 from trapexit/remove-fileinfo
remove FileInfo and keep only file descriptor
This commit is contained in:
commit
8b41dca91a
|
@ -34,13 +34,11 @@
|
|||
|
||||
#include "config.hpp"
|
||||
#include "ugid.hpp"
|
||||
#include "fileinfo.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "rwlock.hpp"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::FileInfo;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
|
@ -81,7 +79,7 @@ _create(const fs::find::Func searchFunc,
|
|||
if(fd == -1)
|
||||
return -errno;
|
||||
|
||||
fh = (uint64_t)new FileInfo(fd,flags,path);
|
||||
fh = fd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_fallocate(const int fd,
|
||||
|
@ -75,9 +73,7 @@ namespace mergerfs
|
|||
off_t len,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
|
||||
|
||||
return _fallocate(fileinfo->fd,
|
||||
return _fallocate(ffi->fh,
|
||||
mode,
|
||||
offset,
|
||||
len);
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_fgetattr(const int fd,
|
||||
|
@ -52,9 +50,7 @@ namespace mergerfs
|
|||
struct stat *st,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
|
||||
|
||||
return _fgetattr(fileinfo->fd,
|
||||
return _fgetattr(ffi->fh,
|
||||
*st);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FILEINFO_H__
|
||||
#define __FILEINFO_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace mergerfs
|
||||
{
|
||||
struct FileInfo
|
||||
{
|
||||
public:
|
||||
FileInfo(int fd_,
|
||||
int flags_,
|
||||
std::string realpath_) :
|
||||
fd(fd_),
|
||||
flags(flags_),
|
||||
realpath(realpath_)
|
||||
{
|
||||
}
|
||||
|
||||
int fd;
|
||||
int flags;
|
||||
std::string realpath;
|
||||
|
||||
private:
|
||||
FileInfo() {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __FILEINFO_H__ */
|
|
@ -27,8 +27,6 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_flush(const int fd)
|
||||
|
@ -52,7 +50,7 @@ namespace mergerfs
|
|||
flush(const char *fusepath,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
return _flush(((FileInfo*)ffi->fh)->fd);
|
||||
return _flush(ffi->fh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_fsync(const int fd,
|
||||
|
@ -59,9 +57,7 @@ namespace mergerfs
|
|||
int isdatasync,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
|
||||
|
||||
return _fsync(fileinfo->fd,
|
||||
return _fsync(ffi->fh,
|
||||
isdatasync);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_ftruncate(const int fd,
|
||||
|
@ -51,9 +49,7 @@ namespace mergerfs
|
|||
off_t size,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
|
||||
|
||||
return _ftruncate(fileinfo->fd,
|
||||
return _ftruncate(ffi->fh,
|
||||
size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <linux/fs.h>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "fileinfo.hpp"
|
||||
#include "ugid.hpp"
|
||||
#include "rwlock.hpp"
|
||||
|
||||
|
@ -145,8 +144,6 @@ namespace mergerfs
|
|||
unsigned int flags,
|
||||
void *data)
|
||||
{
|
||||
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
|
||||
|
||||
#ifdef FUSE_IOCTL_DIR
|
||||
if(flags & FUSE_IOCTL_DIR)
|
||||
return _ioctl_dir(fusepath,
|
||||
|
@ -156,7 +153,7 @@ namespace mergerfs
|
|||
data);
|
||||
#endif
|
||||
|
||||
return _ioctl(fileinfo->fd,
|
||||
return _ioctl(ffi->fh,
|
||||
cmd,
|
||||
arg,
|
||||
flags,
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include "ugid.hpp"
|
||||
#include "fileinfo.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "config.hpp"
|
||||
#include "rwlock.hpp"
|
||||
|
|
|
@ -32,14 +32,12 @@
|
|||
#include <vector>
|
||||
|
||||
#include "ugid.hpp"
|
||||
#include "fileinfo.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "config.hpp"
|
||||
#include "rwlock.hpp"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::FileInfo;
|
||||
|
||||
static
|
||||
int
|
||||
|
@ -61,7 +59,7 @@ _open(const fs::find::Func searchFunc,
|
|||
if(fd == -1)
|
||||
return -errno;
|
||||
|
||||
fh = (uint64_t)new FileInfo(fd,flags,path[0].full);
|
||||
fh = fd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_read(const int fd,
|
||||
|
@ -57,7 +55,7 @@ namespace mergerfs
|
|||
off_t offset,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
return _read(((FileInfo*)ffi->fh)->fd,
|
||||
return _read(ffi->fh,
|
||||
buf,
|
||||
count,
|
||||
offset);
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_read_buf(const int fd,
|
||||
|
@ -67,7 +65,7 @@ namespace mergerfs
|
|||
off_t offset,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
return _read_buf(((FileInfo*)ffi->fh)->fd,
|
||||
return _read_buf(ffi->fh,
|
||||
bufp,
|
||||
size,
|
||||
offset);
|
||||
|
|
|
@ -29,19 +29,11 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
using mergerfs::FileInfo;
|
||||
|
||||
static
|
||||
int
|
||||
_release(uint64_t &fh)
|
||||
{
|
||||
const FileInfo *fileinfo = (FileInfo*)fh;
|
||||
|
||||
::close(fileinfo->fd);
|
||||
|
||||
delete fileinfo;
|
||||
::close(fh);
|
||||
|
||||
fh = 0;
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
_write(const int fd,
|
||||
|
@ -54,7 +52,7 @@ namespace mergerfs
|
|||
off_t offset,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
return _write(((FileInfo*)ffi->fh)->fd,
|
||||
return _write(ffi->fh,
|
||||
buf,
|
||||
count,
|
||||
offset);
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "fileinfo.hpp"
|
||||
#include "write.hpp"
|
||||
|
||||
static
|
||||
|
@ -59,7 +58,7 @@ namespace mergerfs
|
|||
off_t offset,
|
||||
struct fuse_file_info *ffi)
|
||||
{
|
||||
return _write_buf(((FileInfo*)ffi->fh)->fd,
|
||||
return _write_buf(ffi->fh,
|
||||
*src,
|
||||
offset);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user