mirror of https://github.com/trapexit/mergerfs.git
Browse Source
Merge pull request #774 from trapexit/readdir
Merge pull request #774 from trapexit/readdir
additional readdir refactor cleanuppull/775/head
trapexit
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 453 additions and 177 deletions
-
2LICENSE
-
18libfuse/include/fuse_dirents.h
-
9libfuse/include/linux_dirent.h
-
12libfuse/include/linux_dirent64.h
-
33libfuse/lib/fuse_dirents.c
-
2src/config.cpp
-
2src/config.hpp
-
49src/config_readdir.cpp
-
29src/config_readdir.hpp
-
2src/enum.hpp
-
2src/fs_base_fstatat.hpp
-
37src/fs_base_getdents.cpp
-
27src/fs_base_getdents.hpp
-
2src/fs_copydata_copy_file_range.cpp
-
4src/fs_copydata_copy_file_range.hpp
-
2src/fs_glob.hpp
-
2src/fs_statvfs_cache.hpp
-
37src/fuse_readdir.cpp
-
50src/fuse_readdir_linux.cpp
-
33src/fuse_readdir_linux.hpp
-
45src/fuse_readdir_plus.cpp
-
4src/fuse_readdir_plus.hpp
-
58src/fuse_readdir_plus_linux.cpp
-
35src/fuse_readdir_plus_linux.hpp
-
37src/fuse_readdir_plus_posix.cpp
-
35src/fuse_readdir_plus_posix.hpp
-
29src/fuse_readdir_posix.cpp
-
33src/fuse_readdir_posix.hpp
@ -0,0 +1,9 @@ |
|||
#pragma once |
|||
|
|||
struct linux_dirent |
|||
{ |
|||
unsigned long ino; |
|||
unsigned long off; |
|||
unsigned short reclen; |
|||
char name[]; |
|||
}; |
@ -1,12 +0,0 @@ |
|||
#pragma once |
|||
|
|||
#include <stdint.h> |
|||
|
|||
struct linux_dirent64 |
|||
{ |
|||
uint64_t d_ino; |
|||
int64_t d_off; |
|||
uint16_t d_reclen; |
|||
uint8_t d_type; |
|||
char d_name[]; |
|||
}; |
@ -0,0 +1,49 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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 "config_readdir.hpp"
|
|||
#include "ef.hpp"
|
|||
|
|||
template<> |
|||
int |
|||
ReadDir::from_string(const std::string &s_) |
|||
{ |
|||
if(s_ == "posix") |
|||
_data = ReadDir::ENUM::POSIX; |
|||
ef(s_ == "linux") |
|||
_data = ReadDir::ENUM::LINUX; |
|||
else |
|||
return -EINVAL; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
template<> |
|||
std::string |
|||
ReadDir::to_string(void) const |
|||
{ |
|||
switch(_data) |
|||
{ |
|||
case ReadDir::ENUM::POSIX: |
|||
return "posix"; |
|||
case ReadDir::ENUM::LINUX: |
|||
return "linux"; |
|||
} |
|||
|
|||
return "invalid"; |
|||
} |
@ -0,0 +1,29 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include "enum.hpp"
|
|||
|
|||
enum class ReadDirEnum |
|||
{ |
|||
POSIX, |
|||
LINUX |
|||
}; |
|||
|
|||
typedef Enum<ReadDirEnum> ReadDir; |
@ -0,0 +1,37 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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. |
|||
*/ |
|||
|
|||
#if defined __linux__
|
|||
#include <unistd.h>
|
|||
#include <sys/syscall.h>
|
|||
#endif
|
|||
|
|||
namespace fs |
|||
{ |
|||
int |
|||
getdents(unsigned int fd_, |
|||
void *dirp_, |
|||
unsigned int count_) |
|||
{ |
|||
#if defined SYS_getdents64
|
|||
return ::syscall(SYS_getdents,fd_,dirp_,count_); |
|||
#else
|
|||
return (errno=ENOTSUP,-1); |
|||
#endif
|
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
namespace fs |
|||
{ |
|||
int |
|||
getdents(unsigned int fd, |
|||
void *dirp, |
|||
unsigned int count); |
|||
} |
@ -0,0 +1,33 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include "branch.hpp"
|
|||
|
|||
#include <fuse.h>
|
|||
|
|||
#include <stdint.h>
|
|||
|
|||
namespace FUSE |
|||
{ |
|||
int |
|||
readdir_linux(const Branches &branches, |
|||
const char *dirname, |
|||
fuse_dirents_t *buf); |
|||
} |
@ -0,0 +1,35 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include "branch.hpp"
|
|||
|
|||
#include <fuse.h>
|
|||
|
|||
#include <stdint.h>
|
|||
|
|||
namespace FUSE |
|||
{ |
|||
int |
|||
readdir_plus_linux(const Branches &branches_, |
|||
const char *dirname_, |
|||
const uint64_t entry_timeout_, |
|||
const uint64_t attr_timeout_, |
|||
fuse_dirents_t *buf_); |
|||
} |
@ -0,0 +1,35 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include "branch.hpp"
|
|||
|
|||
#include <fuse.h>
|
|||
|
|||
#include <stdint.h>
|
|||
|
|||
namespace FUSE |
|||
{ |
|||
int |
|||
readdir_plus_posix(const Branches &branches_, |
|||
const char *dirname_, |
|||
const uint64_t entry_timeout_, |
|||
const uint64_t attr_timeout_, |
|||
fuse_dirents_t *buf_); |
|||
} |
@ -0,0 +1,33 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include "branch.hpp"
|
|||
|
|||
#include <fuse.h>
|
|||
|
|||
#include <stdint.h>
|
|||
|
|||
namespace FUSE |
|||
{ |
|||
int |
|||
readdir_posix(const Branches &branches, |
|||
const char *dirname, |
|||
fuse_dirents_t *buf); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue