Skip to content

Commit

Permalink
Merge pull request #57 from trapexit/remove-fileinfo
Browse files Browse the repository at this point in the history
   remove FileInfo and keep only file descriptor
  • Loading branch information
trapexit committed Mar 6, 2015
2 parents 15b2c8b + 91671d7 commit 8b41dca
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 107 deletions.
4 changes: 1 addition & 3 deletions src/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 1 addition & 5 deletions src/fallocate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include <errno.h>
#include <fcntl.h>

#include "fileinfo.hpp"

static
int
_fallocate(const int fd,
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions src/fgetattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include <unistd.h>
#include <errno.h>

#include "fileinfo.hpp"

static
int
_fgetattr(const int fd,
Expand All @@ -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);
}
}
Expand Down
53 changes: 0 additions & 53 deletions src/fileinfo.hpp

This file was deleted.

4 changes: 1 addition & 3 deletions src/flush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <unistd.h>
#include <errno.h>

#include "fileinfo.hpp"

static
int
_flush(const int fd)
Expand All @@ -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);
}
}
}
6 changes: 1 addition & 5 deletions src/fsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#include <unistd.h>
#include <errno.h>

#include "fileinfo.hpp"

static
int
_fsync(const int fd,
Expand All @@ -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);
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/ftruncate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include <sys/types.h>
#include <errno.h>

#include "fileinfo.hpp"

static
int
_ftruncate(const int fd,
Expand All @@ -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);
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/ioctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <linux/fs.h>

#include "config.hpp"
#include "fileinfo.hpp"
#include "ugid.hpp"
#include "rwlock.hpp"

Expand Down Expand Up @@ -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,
Expand All @@ -156,7 +153,7 @@ namespace mergerfs
data);
#endif

return _ioctl(fileinfo->fd,
return _ioctl(ffi->fh,
cmd,
arg,
flags,
Expand Down
1 change: 0 additions & 1 deletion src/mkdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <vector>

#include "ugid.hpp"
#include "fileinfo.hpp"
#include "fs.hpp"
#include "config.hpp"
#include "rwlock.hpp"
Expand Down
4 changes: 1 addition & 3 deletions src/open.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

#include <string>

#include "fileinfo.hpp"

static
int
_read(const int fd,
Expand All @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/read_buf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include <errno.h>
#include <string.h>

#include "fileinfo.hpp"

static
int
_read_buf(const int fd,
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 1 addition & 9 deletions src/release.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <errno.h>
#include <unistd.h>

#include "fileinfo.hpp"

static
int
_write(const int fd,
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/write_buf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <stdlib.h>

#include "fileinfo.hpp"
#include "write.hpp"

static
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 8b41dca

Please sign in to comment.