Compare commits

...
409 Commits
Author SHA1 Message Date
Antonio SJ Musumeci 05d81dbc23 update manpage 2016-11-15 23:35:06 -05:00
Antonio SJ Musumeci 00235c15bf Merge pull request #336 from trapexit/sigfpe
ignore filesystems which return zeros for statfs. closes #335
2016-11-15 23:27:49 -05:00
Antonio SJ Musumeci 3c5351af93 ignore filesystems which return zeros for statfs. closes #335 2016-11-15 23:27:17 -05:00
Antonio SJ Musumeci 12b9fc1750 Merge pull request #334 from trapexit/freebsd
changes to allow compiling on FreeBSD
2016-11-01 15:47:37 -04:00
Antonio SJ Musumeci 3d2283f10f clang cpp doesn't like grep exiting early 2016-10-31 09:39:10 -04:00
Antonio SJ Musumeci 192bb9c57e remove usage of -D from install 2016-10-28 22:04:15 -04:00
Antonio SJ Musumeci 157dae0d2f define O_LARGEFILE and O_NOATIME if needed 2016-10-28 22:04:15 -04:00
Antonio SJ Musumeci 00c814dc58 consolidate and simplify utime 2016-10-28 22:04:09 -04:00
Antonio SJ Musumeci 6d6fb45a3b check if fdatasync is available and return ENOSYS if not 2016-10-27 16:59:04 -04:00
Antonio SJ Musumeci f954be60a4 Merge pull request #333 from yatesco/patch-1
minor correction of spelling mistake
2016-10-24 17:18:36 -04:00
Colin Yates 897f20bff8 minor correction of spelling mistake
:%s/cateogry/category/g
2016-10-24 09:32:41 +01:00
Antonio SJ Musumeci c7c5b07389 Merge pull request #330 from trapexit/cleanup
further abstraction of system calls
2016-10-20 16:52:32 -04:00
Antonio SJ Musumeci d0b6cd1f38 further abstraction of system calls 2016-10-20 16:51:49 -04:00
Antonio SJ Musumeci 1ad05d7783 Merge pull request #329 from trapexit/namespace
wrap most posix filesystem functions
2016-10-19 17:10:31 -04:00
Antonio SJ Musumeci 1dc7bff6e6 wrap most posix filesystem functions 2016-10-19 16:58:52 -04:00
Antonio SJ Musumeci 18d684cd16 Merge pull request #328 from trapexit/flock
add flock
2016-10-19 12:17:23 -04:00
Antonio SJ Musumeci 8f594e17d7 add flock 2016-10-19 11:58:44 -04:00
Antonio SJ Musumeci 77269a8bac Merge pull request #327 from trapexit/mhddfs
add some more explination to the FAQ
2016-10-19 09:39:25 -04:00
Antonio SJ Musumeci cd90193deb add some more explination to the FAQ 2016-10-19 09:38:48 -04:00
Antonio SJ Musumeci 35fca6364f Merge pull request #325 from trapexit/readme
add mergerfs.ctl and scorch to tooling section
2016-10-14 13:27:18 -04:00
Antonio SJ Musumeci cd71af8c5b add mergerfs.ctl and scorch to tooling section 2016-10-13 11:02:20 -04:00
Antonio SJ Musumeci a7f26d3769 Merge pull request #324 from trapexit/edquota
add EDQUOT to errors which trigger moveonenospc
2016-10-07 10:27:31 -04:00
Antonio SJ Musumeci 3fb7f8919a add EDQUOT to errors which trigger moveonenospc 2016-10-06 13:54:57 -04:00
Antonio SJ Musumeci abc4ed4d9f Merge pull request #321 from trapexit/manpage
update manpage
2016-09-19 17:07:42 -04:00
Antonio SJ Musumeci dfa82699b9 update manpage 2016-09-19 17:07:41 -04:00
Antonio SJ Musumeci b8beeaceb3 Merge pull request #320 from trapexit/setgroups-arm
use SYS_setgroup32 syscall if available. closes #319
2016-09-19 17:05:10 -04:00
Antonio SJ Musumeci d9a79062b8 use SYS_setgroup32 syscall if available. closes #319 2016-09-19 17:04:11 -04:00
Antonio SJ Musumeci a22b79c416 Merge pull request #318 from trapexit/pagecache-bug
add information about page cache kernel panic bug
2016-09-14 11:20:25 -04:00
Antonio SJ Musumeci b1f2e94a2f add information about page cache kernel panic bug
https://lkml.org/lkml/2016/9/14/527
2016-09-14 11:20:13 -04:00
Antonio SJ Musumeci 2ebd386b5b Merge pull request #317 from trapexit/manpage
recreate manpage
2016-09-14 08:50:51 -04:00
Antonio SJ Musumeci a8cd9b710e recreate manpage 2016-09-14 08:50:42 -04:00
Antonio SJ Musumeci 12d2cf7464 Merge pull request #316 from trapexit/debian-kfreebsd
small tweaks to build on Debian kFreeBSD
2016-09-14 08:36:25 -04:00
Antonio SJ Musumeci 7e423cd9ce small tweaks to build on Debian kFreeBSD 2016-09-14 08:36:06 -04:00
Antonio SJ Musumeci fa3218cb72 Merge pull request #315 from trapexit/futimes
fix futimes version of utimes wrapper
2016-09-13 21:36:58 -04:00
Antonio SJ Musumeci 0395e7c776 fix futimes version of utimes wrapper 2016-09-13 21:30:45 -04:00
Antonio SJ Musumeci a575cf76c2 Merge pull request #314 from trapexit/fadvise
fix #define typo
2016-09-13 17:40:28 -04:00
Antonio SJ Musumeci 93923177ee fix #define typo 2016-09-13 17:40:23 -04:00
Antonio SJ Musumeci 51858114b2 Merge pull request #313 from trapexit/fadvise
abstract posix_fadvise
2016-09-13 17:36:49 -04:00
Antonio SJ Musumeci 1513c92cbc abstract posix_fadvise 2016-09-13 17:36:28 -04:00
Antonio SJ Musumeci 7824586f76 Merge pull request #309 from jfreax/patch-1
Fix minor typo
2016-09-03 22:24:31 -04:00
Jens Dieskau 158dda9f23 Fix minor typo 2016-09-03 22:33:36 +02:00
Antonio SJ Musumeci 577bc67fa7 Merge pull request #305 from trapexit/ugid
rename include cpp files to have icpp extension
2016-08-26 14:44:43 -04:00
Antonio SJ Musumeci 1a698e5ef5 rename include cpp files to have icpp extension 2016-08-26 14:41:56 -04:00
Antonio SJ Musumeci a0885e33dc Merge pull request #304 from trapexit/freebsd
fix some build issues with Debian/kFreeBSD
2016-08-26 13:10:41 -04:00
Antonio SJ Musumeci 2ee6b4f581 include sys/types.h to pick up ssize_t 2016-08-26 13:09:15 -04:00
Antonio SJ Musumeci 709dda5069 support systems without ENODATA 2016-08-26 12:59:32 -04:00
Antonio SJ Musumeci f0f8e527b4 Merge pull request #301 from trapexit/time
make futimes crossplatform
2016-08-07 14:46:43 -04:00
Antonio SJ Musumeci 49474f01ca make futimes crossplatform 2016-08-07 14:42:54 -04:00
Antonio SJ Musumeci 9e8b309a90 Merge pull request #300 from trapexit/fuseversion
bump FUSE_USE_VERSION to 29
2016-08-04 17:15:37 -04:00
Antonio SJ Musumeci f7547d7cf5 Merge pull request #299 from trapexit/realpath
use dynamic buffer for realpath
2016-08-04 17:14:09 -04:00
Antonio SJ Musumeci bb02ab2cba Merge pull request #298 from trapexit/fssendfile
split sendfile wrapper into separate files
2016-08-04 17:13:28 -04:00
Antonio SJ Musumeci fb1432e14e Merge pull request #297 from trapexit/fsattr
make fs_attr compile on unsupported platforms
2016-08-04 17:12:33 -04:00
Antonio SJ Musumeci 34d38cb0fb split sendfile wrapper into separate files 2016-08-04 17:11:23 -04:00
Antonio SJ Musumeci 192a9d54d1 make fs_attr compile on unsupported platforms 2016-08-04 17:10:02 -04:00
Antonio SJ Musumeci 40574bd138 use dynamic buffer for realpath 2016-08-04 14:52:27 -04:00
Antonio SJ Musumeci 064fd5560f bump FUSE_USE_VERSION to 29 2016-08-04 14:02:59 -04:00
Antonio SJ Musumeci 073d1b6f6f Merge pull request #296 from trapexit/fallocate
add osx version of fallocate
2016-08-02 23:46:21 -04:00
Antonio SJ Musumeci 45f757dc60 add osx version of fallocate 2016-08-02 17:14:45 -04:00
Antonio SJ Musumeci 939b4a0fe5 Merge pull request #294 from trapexit/eprand
add epall and eprand policies
2016-08-02 11:29:20 -04:00
Antonio SJ Musumeci 0fceb8e0a3 add epall and eprand policies 2016-08-01 16:08:02 -04:00
Antonio SJ Musumeci 34662da806 Merge pull request #293 from trapexit/faccessat
replace nonstandard eaccess with POSIX.1-2008 faccessat
2016-07-29 12:48:08 -04:00
Antonio SJ Musumeci 7634eb1440 replace nonstandard eaccess with POSIX.1-2008 faccessat 2016-07-29 12:39:44 -04:00
Antonio SJ Musumeci 08cd5f89ff Merge pull request #291 from trapexit/typo
fix typo and clarify feature
2016-07-26 09:09:31 -04:00
Antonio SJ Musumeci 47f184a944 fix typo and clarify feature 2016-07-26 09:09:10 -04:00
Antonio SJ Musumeci 920f7fd049 Merge pull request #290 from trapexit/epff
add existing path first found policy. closes #289
2016-07-11 20:50:32 -04:00
Antonio SJ Musumeci a93ab6c2f5 add existing path first found policy. closes #289 2016-07-11 20:42:56 -04:00
Antonio SJ Musumeci a375f33eb4 Merge pull request #288 from trapexit/uint64_t
move size calculations to use uint64_t. fixes #287
2016-07-11 09:14:14 -04:00
Antonio SJ Musumeci 1e7b84f7fd Merge pull request #285 from waldyrious/patch-1
add license title
2016-07-11 09:13:36 -04:00
Antonio SJ Musumeci 43cbd9c670 move size calculations to use uint64_t. fixes #287 2016-07-11 09:04:47 -04:00
Waldir Pimenta 9f36eada14 add license title
It's not strictly required, but it's useful metadata, and part of the recommended license template text (see http://choosealicense.com/licenses/isc/ and https://opensource.org/licenses/isc-license)
2016-07-01 00:28:12 +01:00
Antonio SJ Musumeci 30cdfa64b8 reiterate path preserving policies 2016-06-07 20:51:18 -04:00
Antonio SJ Musumeci 81e9544f7d Merge pull request #281 from trapexit/update-man
update man page
2016-05-19 17:30:07 -04:00
Antonio SJ Musumeci 3cb2045ebb update man page 2016-05-19 17:28:37 -04:00
Antonio SJ Musumeci 652440fd8c Merge pull request #280 from trapexit/mmapbug
update info on mmap bug and when it was fixed
2016-05-17 16:09:38 -04:00
Antonio SJ Musumeci 6dc6fde641 update info on mmap bug and when it was fixed 2016-05-17 16:09:22 -04:00
Antonio SJ Musumeci 66fdcc4ef7 Merge pull request #279 from trapexit/fallocate
rework fallocate logic
2016-05-11 13:23:33 -04:00
Antonio SJ Musumeci cb35a374ac rework fallocate logic 2016-05-11 13:19:44 -04:00
Antonio SJ Musumeci 68210d9252 Merge pull request #278 from trapexit/ioctl-dir
fix ioctl on directories
2016-05-11 13:12:50 -04:00
Antonio SJ Musumeci 23b8e4582e fix ioctl on directories 2016-05-11 11:22:00 -04:00
Antonio SJ Musumeci 13511ea72a Merge pull request #275 from trapexit/updateman
update man page
2016-05-07 15:19:34 -04:00
Antonio SJ Musumeci 3a50344cb9 update man page 2016-05-07 15:18:48 -04:00
Antonio SJ Musumeci 9f27ad448a Merge pull request #274 from trapexit/lus
add least used space and existing path, least used space policies
2016-05-07 15:17:58 -04:00
Antonio SJ Musumeci be6341e6f0 create eplus (existing path, least used space) policy. closes #273 2016-05-07 15:15:51 -04:00
Antonio SJ Musumeci f7d3e8bf47 create lus (least used space) policy. closes #273 2016-05-07 14:59:42 -04:00
Antonio SJ Musumeci e541cdb755 Merge pull request #272 from trapexit/faq-direct-reads
faq update on direct writes
2016-05-03 11:44:24 -04:00
Antonio SJ Musumeci 74ed1b09ee faq update on direct writes 2016-05-03 11:44:04 -04:00
Antonio SJ Musumeci 9987111fa4 Merge pull request #271 from trapexit/fstabdocs
clean up information regarding fstab
2016-04-27 07:13:28 -04:00
Antonio SJ Musumeci d0414d7c78 clean up information regarding fstab 2016-04-27 07:13:05 -04:00
Antonio SJ Musumeci 8f6a7ba79a Merge pull request #270 from trapexit/fsname
add fsname to readme
2016-04-25 16:58:27 -04:00
Antonio SJ Musumeci ef8d8f306e add fsname to readme 2016-04-25 16:58:18 -04:00
Antonio SJ Musumeci 1de01684e0 Merge pull request #269 from trapexit/createcatdesc
further tweak language regarding policies wrt create category
2016-04-13 13:06:49 -04:00
Antonio SJ Musumeci cd15b7a66a further tweak language regarding policies wrt create category 2016-04-13 13:06:35 -04:00
Antonio SJ Musumeci 6b88258d81 Merge pull request #268 from trapexit/policy-desc
make policy descriptions more explicit
2016-04-13 12:46:26 -04:00
Antonio SJ Musumeci 8643d35ebf make policy descriptions more explicit 2016-04-13 12:45:49 -04:00
Antonio SJ Musumeci b7d7ace9bf Merge pull request #266 from trapexit/tweakreadme
tweak doc language
2016-04-06 14:57:21 -04:00
Antonio SJ Musumeci 1cfe1c3715 tweak doc language 2016-04-06 14:57:02 -04:00
Antonio SJ Musumeci 63b02b327b Merge pull request #265 from trapexit/mmap-bug
add details of mmap cache bug
2016-04-03 16:57:06 -04:00
Antonio SJ Musumeci dbb13ef7ad add details of mmap cache bug 2016-04-03 16:56:47 -04:00
Antonio SJ Musumeci 6aec6c939a Merge pull request #263 from trapexit/dualmount
add dual mount suggestion to mmap problem
2016-03-15 16:45:06 -04:00
Antonio SJ Musumeci 90ca14afff add dual mount suggestion to mmap problem 2016-03-15 16:44:49 -04:00
Antonio SJ Musumeci c7328293a0 Merge pull request #262 from trapexit/mmap-direct_io
add details regarding rtorrent, mmap, and direct_io
2016-03-15 08:25:06 -04:00
Antonio SJ Musumeci cfaf812c62 add details regarding rtorrent, mmap, and direct_io 2016-03-15 08:24:35 -04:00
Antonio SJ Musumeci 47fb6e29c6 Merge pull request #259 from trapexit/dedup-tool
update readme to include mergerfs.dedup
2016-03-11 18:03:33 -05:00
Antonio SJ Musumeci 0c6c69e02e update readme to include mergerfs.dedup 2016-03-11 18:03:22 -05:00
Antonio SJ Musumeci 4b6cfdc68a Merge pull request #258 from trapexit/tarball-url
change tar.gz build url
2016-03-11 16:55:26 -05:00
Antonio SJ Musumeci 309cfee52b change tar.gz build url 2016-03-11 16:55:10 -05:00
Antonio SJ Musumeci 9b3c085cf3 Merge pull request #257 from trapexit/man
tweak man page creation
2016-03-10 18:43:12 -05:00
Antonio SJ Musumeci 382ca876ca tweak man page creation 2016-03-10 18:42:32 -05:00
Antonio SJ Musumeci 93acfb015c Merge pull request #256 from trapexit/xattr
properly check errors of xattr. closes #255
2016-03-10 18:38:05 -05:00
Antonio SJ Musumeci 070ed08caa properly check errors of xattr. closes #255 2016-03-10 18:37:09 -05:00
Antonio SJ Musumeci 5d44161e77 Merge pull request #251 from trapexit/man
update precompiled man page
2016-03-06 02:23:47 -05:00
Antonio SJ Musumeci 6492fda483 update precompiled man page 2016-03-06 02:22:58 -05:00
Antonio SJ Musumeci 447fd8b2fb Merge pull request #250 from trapexit/rename
fix rename failing on non-path preserving policies
2016-03-06 02:22:23 -05:00
Antonio SJ Musumeci 2061211894 fix rename failing on non-path preserving policies 2016-03-06 02:21:23 -05:00
Antonio SJ Musumeci 5030d5a5b4 Merge pull request #249 from trapexit/clarify-rename
clarify that rename uses the create policy to make decisions
2016-03-04 20:33:10 -05:00
Antonio SJ Musumeci 4928944167 clarify that rename uses the create policy to make decisions 2016-03-04 20:32:52 -05:00
Antonio SJ Musumeci 6957cf39d1 Merge pull request #247 from trapexit/epmfs
re-add minfreespace check to epmfs policy
2016-03-04 13:56:15 -05:00
Antonio SJ Musumeci 12cf57dc5a re-add minfreespace check to epmfs policy 2016-03-04 13:52:31 -05:00
Antonio SJ Musumeci 26c2ebc843 Merge pull request #245 from trapexit/readme
change tooling names and add guide link
2016-03-03 10:47:45 -05:00
Antonio SJ Musumeci 59b08a5bc3 change tooling names and add guide link 2016-03-03 10:46:53 -05:00
Antonio SJ Musumeci 8ac3518725 Merge pull request #244 from trapexit/gitdebcl
fix building of platform specific deb packages
2016-03-01 00:19:59 -05:00
Antonio SJ Musumeci f4a4cc5812 fix building of platform specific deb packages 2016-03-01 00:19:05 -05:00
Antonio SJ Musumeci b93783ede0 Merge pull request #243 from trapexit/git2dbcl
fix printing of versions with no changes
2016-02-29 23:56:29 -05:00
Antonio SJ Musumeci ef4c583b3f fix printing of versions with no changes 2016-02-29 23:55:36 -05:00
Antonio SJ Musumeci 6d049c16d1 Merge pull request #242 from trapexit/statvfs
clearly separate usage of statvfs from stat for file existance
2016-02-29 23:11:00 -05:00
Antonio SJ Musumeci 4ecf3c5797 clearly separate usage of statvfs from stat for file existance
Used statvfs to also check for existance vs lstat. On dead symlinks
this resulted in ENOENT making certain functions fail.

closes #239
2016-02-29 23:04:59 -05:00
Antonio SJ Musumeci 4a63c000ca Merge pull request #241 from trapexit/policy-ff
add minfreespace checks to policy ff's create and remove fwfs
2016-02-29 18:15:12 -05:00
Antonio SJ Musumeci 779143f4b6 add minfreespace checks to policy ff's create and remove fwfs
fwfs is now covered by ff with the minfreespace and readonly checks
2016-02-29 18:06:59 -05:00
Antonio SJ Musumeci ccd3b5d2d0 Merge pull request #240 from trapexit/readme
update readme with minfreespace and readonly details
2016-02-29 15:15:10 -05:00
Antonio SJ Musumeci 4d7148cdd1 update readme with minfreespace and readonly details 2016-02-29 15:14:31 -05:00
Antonio SJ Musumeci 98a051b161 Merge pull request #238 from trapexit/policy-all
add readonly and minfreespace filters to all policy for creates. clos…
2016-02-29 10:55:55 -05:00
Antonio SJ Musumeci 14886a27f4 add readonly and minfreespace filters to all policy for creates. closes #236 2016-02-29 10:15:53 -05:00
Antonio SJ Musumeci 81b9918f6b Merge pull request #237 from trapexit/renamefix 2016-02-26 17:18:39 -05:00
Antonio SJ Musumeci 9819cf6133 fix clonepath being called on wrong source 2016-02-26 17:16:09 -05:00
Antonio SJ Musumeci c5e584fa5a Merge pull request #235 from trapexit/changeloger
fix creation of changelog
2016-02-25 17:53:24 -05:00
Antonio SJ Musumeci c56b488c8d fix creation of changelog 2016-02-25 17:52:47 -05:00
Antonio SJ Musumeci cd50a0b0c8 Merge pull request #234 from trapexit/renametweaks
normalize error handling in rename policy
2016-02-24 17:11:58 -05:00
Antonio SJ Musumeci e593927095 normalize error handling in rename policy 2016-02-24 17:10:56 -05:00
Antonio SJ Musumeci 12251cf7c2 Merge pull request #233 from trapexit/ffopt
ff policy tweaks
2016-02-24 13:02:24 -05:00
Antonio SJ Musumeci 7c85cd906a ff policy tweaks 2016-02-24 12:40:02 -05:00
Antonio SJ Musumeci 32c4b1ad1c Merge pull request #232 from trapexit/version
override standard libfuse version flag
2016-02-24 08:39:56 -05:00
Antonio SJ Musumeci 5cf3bb7c98 override standard libfuse version flag 2016-02-24 06:36:33 -05:00
Antonio SJ Musumeci 3f8a6525b3 Merge pull request #231 from trapexit/fstweaks
minor tweaks to filesystem utility functions
2016-02-23 12:35:42 -05:00
Antonio SJ Musumeci 25a039942c minor tweaks to filesystem utility functions 2016-02-23 12:28:20 -05:00
Antonio SJ Musumeci 400537d711 Merge pull request #230 from trapexit/findonfs
use stat/2 rather than statvfs/2 to find file drive
2016-02-23 12:07:31 -05:00
Antonio SJ Musumeci 792c9b9808 use stat/2 rather than statvfs/2 to find file drive 2016-02-23 12:06:16 -05:00
Antonio SJ Musumeci 476a8a50ea Merge pull request #228 from trapexit/readme
update / tweak readme
2016-02-21 18:31:02 -05:00
Antonio SJ Musumeci a698a8a545 update / tweak readme 2016-02-21 18:30:25 -05:00
Antonio SJ Musumeci 5b06bb24fb Merge pull request #227 from trapexit/policy-cleanup
remove unnecessary policies
2016-02-21 18:25:11 -05:00
Antonio SJ Musumeci d4ec341c4f remove unnecessary policies 2016-02-21 18:24:15 -05:00
Antonio SJ Musumeci 1bbe3a8879 Merge pull request #226 from trapexit/readonly
ignore drives mounted as readonly from create policies. closes #224
2016-02-21 14:35:53 -05:00
Antonio SJ Musumeci 5813d1e477 ignore drives mounted as readonly from create policies. closes #224 2016-02-21 14:34:40 -05:00
Antonio SJ Musumeci 81e77216fc Merge pull request #225 from trapexit/eplfs-readme
add eplfs info to readme
2016-02-18 13:32:44 -05:00
Antonio SJ Musumeci a4e60d7471 add eplfs info to readme 2016-02-18 13:32:30 -05:00
Antonio SJ Musumeci 8edb7c1e1c Merge pull request #223 from trapexit/statvfs
use stat.st_dev to uniquely identify mounts for statfs. closes #213
2016-02-15 22:57:35 -05:00
Antonio SJ Musumeci f3e75a0544 use stat.st_dev to uniquely identify mounts for statfs. closes #213 2016-02-15 22:55:47 -05:00
Antonio SJ Musumeci eed2bbf913 Merge pull request #222 from trapexit/policy
simplify policies
2016-02-15 02:14:48 -05:00
Antonio SJ Musumeci b3248a8f78 simplify policies 2016-02-15 02:06:58 -05:00
Antonio SJ Musumeci fc100006f9 Merge pull request #220 from trapexit/eplfs
add existing path, least free space policy. closes #216
2016-02-12 10:08:15 -05:00
Antonio SJ Musumeci 7bf1ca45e4 add existing path, least free space policy. closes #216 2016-02-12 10:06:41 -05:00
Antonio SJ Musumeci c568a6d356 Merge pull request #219 from trapexit/pathmake
use references to srcmounts rather than copies
2016-02-11 21:14:45 -05:00
Antonio SJ Musumeci 6086620e23 use references to srcmounts rather than copies 2016-02-11 21:09:31 -05:00
Antonio SJ Musumeci f7c37d2974 Merge pull request #218 from trapexit/why-mergerfs
add some "why mergerfs instead of X" sections to the FAQ
2016-02-11 15:51:55 -05:00
Antonio SJ Musumeci 3a51ceb327 add some "why mergerfs instead of X" sections to the FAQ 2016-02-11 15:51:22 -05:00
Antonio SJ Musumeci f510e539ab Merge pull request #215 from trapexit/trashdirs
add section to readme about trash directories
2016-02-11 15:08:28 -05:00
Antonio SJ Musumeci 681f3d7492 add section to readme about trash directories 2016-02-11 15:07:55 -05:00
Antonio SJ Musumeci a7c1b88bfe Merge pull request #212 from trapexit/libfuse-crashes
add information on fixing libfuse crashes
2016-02-01 09:47:14 -05:00
Antonio SJ Musumeci 0bac344c8b add information on fixing libfuse crashes 2016-02-01 09:45:40 -05:00
Antonio SJ Musumeci 40e41e472d Merge pull request #211 from trapexit/rpmspec
remove sbin from rpm spec file
2016-01-25 09:43:07 -05:00
Antonio SJ Musumeci 840f9b8593 remove sbin from rpm spec file 2016-01-25 09:42:27 -05:00
Antonio SJ Musumeci 1160868243 Merge pull request #210 from trapexit/statvfs
fix statvfs drive dedup. closes #209
2016-01-22 10:16:01 -05:00
Antonio SJ Musumeci f779f82ed6 fix statvfs drive dedup. closes #209 2016-01-22 10:15:24 -05:00
Antonio SJ Musumeci a629e60f5c Merge pull request #208 from trapexit/remove-clone
remove clone test tool
2016-01-21 14:55:15 -05:00
Antonio SJ Musumeci 3e20adb109 remove clone test tool 2016-01-21 14:48:12 -05:00
Antonio SJ Musumeci 1931e263be Merge pull request #207 from trapexit/update-man
update the precompiled man page
2016-01-21 12:49:44 -05:00
Antonio SJ Musumeci e285bde962 update the precompiled man page 2016-01-21 12:49:04 -05:00
Antonio SJ Musumeci d058a366ee Merge pull request #206 from trapexit/readme-tweaks
general tweaks to readme
2016-01-21 12:47:50 -05:00
Antonio SJ Musumeci 853769bd7c general tweaks to readme 2016-01-21 12:47:13 -05:00
Antonio SJ Musumeci a3e693c30e Merge pull request #205 from trapexit/symlink
make symlink function like mknod/mkdir. closes #204
2016-01-20 17:56:03 -05:00
Antonio SJ Musumeci ea325755a7 make symlink function like mknod/mkdir. closes #204 2016-01-20 17:55:20 -05:00
Antonio SJ Musumeci 091cc230d8 Merge pull request #203 from trapexit/mknod-fix
fix indexing of mknod targets. closes #202
2016-01-20 17:27:19 -05:00
Antonio SJ Musumeci 1d1694bbb5 fix indexing of mknod targets. closes #202 2016-01-20 17:24:50 -05:00
Antonio SJ Musumeci 8287f7f119 Merge pull request #201 from trapexit/remove-warning
remove incorrect warning about race condition with mkdir/mknod
2016-01-20 17:08:04 -05:00
Antonio SJ Musumeci 93397ea170 remove incorrect warning about race condition with mkdir/mknod 2016-01-20 17:07:33 -05:00
Antonio SJ Musumeci da6d9b8eab Merge pull request #200 from trapexit/statfs
dedup based on full statvfs struct rather than fsid. closes #183
2016-01-20 16:45:58 -05:00
Antonio SJ Musumeci 25265f4e85 dedup based on full statvfs struct rather than fsid. closes #183 2016-01-20 16:44:05 -05:00
Antonio SJ Musumeci d4caecacbd Merge pull request #199 from trapexit/remove-tools
remove tooling from repo. closes #198
2016-01-19 16:32:46 -05:00
Antonio SJ Musumeci de776b7cf0 remove tooling from repo. closes #198 2016-01-19 16:29:51 -05:00
Antonio SJ Musumeci 02c1ce5181 Merge pull request #197 from trapexit/link
have link act similar to rename
2016-01-19 16:14:06 -05:00
Antonio SJ Musumeci 62f8fc524e have link act similar to rename
closes #193
2016-01-19 16:08:02 -05:00
Antonio SJ Musumeci 2fe465a29c Merge pull request #196 from trapexit/license
move from MIT to ISC license. closes #194
2016-01-14 16:57:43 -05:00
Antonio SJ Musumeci 242af777be move from MIT to ISC license. closes #194 2016-01-14 16:56:38 -05:00
Antonio SJ Musumeci fe7d841500 Merge pull request #195 from trapexit/rv
all action functions return success should at least one succeed
2016-01-14 08:26:16 -05:00
Antonio SJ Musumeci 4c77ac4d24 all action functions return success should at least one succeed. closes #189 2016-01-14 07:58:57 -05:00
Antonio SJ Musumeci f905116c3d Merge pull request #192 from trapexit/manpage
update man page
2016-01-12 23:37:10 -05:00
Antonio SJ Musumeci b811522474 update man page 2016-01-12 23:36:32 -05:00
Antonio SJ Musumeci 9b80d6905b Merge pull request #191 from trapexit/srcmounts
replace srcpoints with srcmounts
2016-01-12 16:28:27 -05:00
Antonio SJ Musumeci 8a5c5240f2 replace srcpoints with srcmounts 2016-01-12 16:27:47 -05:00
Antonio SJ Musumeci 8257a1f765 Merge pull request #190 from trapexit/rename
rework rename algo to minimize likelihood of EXDEV being returned. cl…
2016-01-12 16:24:08 -05:00
Antonio SJ Musumeci a3e6a0352d rework rename algo to minimize likelihood of EXDEV being returned. closes #187 2016-01-12 16:23:12 -05:00
Antonio SJ Musumeci 47dc59bff2 Merge pull request #185 from trapexit/policy_template
change to using template for policy class
2015-12-29 16:23:10 -05:00
Antonio SJ Musumeci eb6d1a1bc2 change to using template for policy class 2015-12-29 16:14:37 -05:00
Antonio SJ Musumeci fbc2cd95cd Merge pull request #180 from trapexit/nonbash
Nonbash
2015-12-14 23:51:26 -05:00
Antonio SJ Musumeci 55c4a32614 add artifacts to gitignore 2015-12-14 23:50:35 -05:00
Antonio SJ Musumeci 51ae7d1980 change make to work with non-bash shells 2015-12-14 23:50:02 -05:00
Antonio SJ Musumeci 4adeb6348b Merge pull request #179 from trapexit/fix-noxattr
fix building without xattr
2015-12-14 19:02:05 -05:00
Antonio SJ Musumeci c731b7035c fix building without xattr 2015-12-14 18:48:04 -05:00
Antonio SJ Musumeci 0165fb24d4 Merge pull request #177 from trapexit/xattr-pid
add mergerfs pid to xattrs
2015-12-07 23:57:24 -05:00
Antonio SJ Musumeci 9e24796429 add mergerfs pid to xattrs 2015-12-07 21:20:12 -05:00
Antonio SJ Musumeci 2d71229fe9 Merge pull request #172 from trapexit/setgroups
use SYS_setgroups rather than setgroups on linux
2015-10-29 23:38:45 -04:00
Antonio SJ Musumeci 5e880bddba use SYS_setgroups rather than setgroups 2015-10-29 23:20:37 -04:00
Antonio SJ Musumeci af24bdb426 Merge pull request #171 from trapexit/support
add support section to readme and manpage
2015-10-29 15:27:56 -04:00
Antonio SJ Musumeci 8a651b0372 add support section to readme and manpage 2015-10-29 15:27:05 -04:00
Antonio SJ Musumeci 762a04242f Merge pull request #169 from trapexit/scan-check-cleanup
fix misc issues flagged by clang scan-build
2015-10-22 18:08:41 -04:00
Antonio SJ Musumeci 8cd747e673 Merge pull request #168 from trapexit/debversion
include distro and codename in deb package versions
2015-10-22 18:06:40 -04:00
Antonio SJ Musumeci 93cedabe9c fix misc issues flagged by clang scan-build 2015-10-22 18:06:11 -04:00
Antonio SJ Musumeci fd4ce1b5fa include distro and codename in deb package versions 2015-10-22 18:05:16 -04:00
Antonio SJ Musumeci f3a6876362 remove pandoc from build requirements 2015-10-18 00:15:28 -04:00
Antonio SJ Musumeci 61dbb85f35 Merge pull request #165 from trapexit/manpage
remove manpage from root directory
2015-10-17 22:08:46 -04:00
Antonio SJ Musumeci 30c29c9fae remove manpage from root directory 2015-10-17 22:07:40 -04:00
Antonio SJ Musumeci 10eb05a14b Merge pull request #164 from trapexit/manpage
if pandoc doesn't exist copy premade version
2015-10-17 21:38:52 -04:00
Antonio SJ Musumeci 8ed11a0e8f if pandoc doesn't exist copy premade version 2015-10-17 21:38:15 -04:00
Antonio SJ Musumeci 74f2a88ed2 Merge pull request #163 from trapexit/manpage
offer prebuilt manpage for platforms without easy access to pandoc
2015-10-16 18:57:27 -04:00
Antonio SJ Musumeci 46c8361fa9 offer prebuilt manpage for platforms without easy access to pandoc 2015-10-16 18:50:51 -04:00
Antonio SJ Musumeci 02df44129d update info on Samba client EXDEV issue 2015-10-16 08:30:54 -04:00
Antonio SJ Musumeci fe7960974d fix typo 2015-10-14 08:07:05 -04:00
Antonio SJ Musumeci 873c4a9840 add link to gvfs-fuse patch 2015-10-14 06:48:40 -04:00
Antonio SJ Musumeci 4df9b2e6f1 add documentation on SMB client EXDEV / EIO issue 2015-10-14 00:27:26 -04:00
Antonio SJ Musumeci e84c458cad Merge pull request #162 from trapexit/intsizes
fix minor integer casting issues
2015-10-13 23:34:18 -04:00
Antonio SJ Musumeci 1c7de2d83e fix minor integer casting issues 2015-10-13 23:33:33 -04:00
Antonio SJ Musumeci a10de2aaf9 update build dependencies for Fedora 2015-10-13 09:07:38 -04:00
Antonio SJ Musumeci f83cdc215f Merge pull request #160 from trapexit/rpm
add sbin directory to rpm spec
2015-10-13 07:14:23 -04:00
Antonio SJ Musumeci 3d7d2cf80a add sbin directory to rpm spec 2015-10-13 07:13:17 -04:00
Antonio SJ Musumeci 5d5428fbb3 Merge pull request #159 from trapexit/git2dbcl
enhance git2debcl to work with older python releases
2015-10-13 00:21:14 -04:00
Antonio SJ Musumeci 5489952aa8 enhance git2debcl to work with older python releases 2015-10-13 00:20:47 -04:00
Antonio SJ Musumeci 280309ad6d Merge pull request #158 from trapexit/fusedep
set rpm dependency to fuse
2015-10-12 23:52:16 -04:00
Antonio SJ Musumeci 068fbc0269 set rpm dependency to fuse 2015-10-12 23:51:52 -04:00
Antonio SJ Musumeci 6709791156 Merge pull request #157 from trapexit/mount.mergerfs
create mount.mergerfs symlink. closes #149
2015-10-12 23:45:04 -04:00
Antonio SJ Musumeci 5a76c41236 create mount.mergerfs symlink. closes #149 2015-10-12 23:43:17 -04:00
Antonio SJ Musumeci 3ccc94a560 Merge pull request #156 from trapexit/cisms
misc fixes to compile on older platforms
2015-10-12 19:52:34 -04:00
Antonio SJ Musumeci 58446f9124 misc fixes to compile on older platforms 2015-10-12 19:51:57 -04:00
Antonio SJ Musumeci ce2ec89964 Merge pull request #155 from trapexit/gidcache
rewrite gid cache system
2015-10-11 15:07:24 -04:00
Antonio SJ Musumeci 40f569be37 rewrite gid cache system
Uses fixed storage so as to not require C++11 local thread storage or memory allocation.
2015-10-11 15:01:57 -04:00
Antonio SJ Musumeci db85a7d3f2 Merge pull request #152 from trapexit/fsck
audit (and fix) file permissions and ownership. closes #148
2015-10-06 00:38:22 -04:00
Antonio SJ Musumeci f6d396c30d audit (and fix) file permissions and ownership. closes #148 2015-10-06 00:37:03 -04:00
Antonio SJ Musumeci 95e6ebf607 Merge pull request #151 from trapexit/uint32
remove usage of UINT32_MAX macro
2015-10-01 23:37:46 -04:00
Antonio SJ Musumeci 53e3284b26 remove usage of UINT32_MAX macro 2015-10-01 10:26:12 -04:00
Antonio SJ Musumeci 746bb68a0c Merge pull request #147 from trapexit/usage
provide usage text and version info. closes #146
2015-09-29 07:30:02 -04:00
Antonio SJ Musumeci 09ffc8c903 provide usage text and version info. closes #146 2015-09-29 07:29:10 -04:00
Antonio SJ Musumeci f844daa76c Merge pull request #145 from trapexit/debswap
swap deb and unsigned-deb make tagets. closes #140
2015-09-26 14:14:04 -04:00
Antonio SJ Musumeci c289dafadc swap deb and unsigned-deb make tagets. closes #140 2015-09-26 14:12:10 -04:00
Antonio SJ Musumeci 2e538068ef Merge pull request #144 from trapexit/enospc
move on enospc when writing feature. closes #141
2015-09-25 15:41:24 -04:00
Antonio SJ Musumeci 5808ab7795 move on enospc when writing feature. closes #141
This feature mimics the standard mhddfs behavior but is more thorough.
If a write fails and the errno is set to ENOSPC then mergerfs will (if
the feature is enabled) attempt to move the file to the drive with
the most free space but only if it has enough room for the file plus
the amount to be written. If that transfer is successful it will then
unlink the original file and attempt the previously failed write again.

The copy includes copying the path and file including the acls, owners,
attributes, extended attributes, and timestamps.
2015-09-25 15:14:17 -04:00
Antonio SJ Musumeci 4e5578de9c make note about escaping glob tokens more explicit 2015-09-25 13:48:03 -04:00
Antonio SJ Musumeci 4b375faf12 include rpm-build in Fedora dependencies 2015-09-24 17:59:49 -04:00
Antonio SJ Musumeci 9542e6340b include link to release page in readme 2015-09-24 15:07:39 -04:00
Antonio SJ Musumeci de583b70f7 clean up options listing 2015-09-23 16:42:36 -04:00
Antonio SJ Musumeci 8bf0f755e1 create summary feature section
And tweak intro.
2015-09-22 12:46:47 -04:00
Antonio SJ Musumeci 5850fbe3f1 bump README date 2015-09-14 22:45:45 -04:00
Antonio SJ Musumeci 1cc1b1f746 Merge pull request #139 from trapexit/setxattr-cleanup
cleanup controlfile manipulation
2015-09-14 22:42:06 -04:00
Antonio SJ Musumeci a960a7ef46 cleanup controlfile manipulation 2015-09-14 22:40:49 -04:00
Antonio SJ Musumeci 9afd0654b7 Merge pull request #138 from trapexit/defaults
include default_permissions in default arguments
2015-09-14 22:13:37 -04:00
Antonio SJ Musumeci e0cf97261c include default_permissions in default arguments
closes #130
2015-09-14 22:12:24 -04:00
Antonio SJ Musumeci 1782910437 Merge pull request #137 from trapexit/setgroups-docs
change README regarding setgroups cache and new rwlock ugid fallback
2015-09-14 19:34:22 -04:00
Antonio SJ Musumeci f4e3f28153 change README regarding setgroups cache and new rwlock ugid fallback 2015-09-14 19:33:30 -04:00
Antonio SJ Musumeci 6a96d3b69b Merge pull request #136 from trapexit/typo
fix typo in README
2015-09-14 19:06:37 -04:00
Antonio SJ Musumeci 08c0c2dfae fix typo in README. closes #134 2015-09-14 19:05:42 -04:00
Antonio SJ Musumeci ad5380d69e Merge pull request #135 from trapexit/op-ugid
make changing credentials opportunistic + per thread setgroups cache
2015-09-14 19:01:23 -04:00
Antonio SJ Musumeci 3163258a33 make changing credentials opportunistic + per thread setgroups cache
closes #129,#131
2015-09-14 19:00:07 -04:00
Antonio SJ Musumeci b194272e39 add notes on permissions and errors to readme 2015-09-08 18:06:32 -04:00
Antonio SJ Musumeci c131310c55 include known issues section to readme 2015-09-07 19:58:10 -04:00
Antonio SJ Musumeci 8323e16ad2 Merge pull request #126 from trapexit/realpathize
realpath'ize all source mount points. closes #117
2015-09-06 18:25:21 -04:00
Antonio SJ Musumeci ce9352987c realpath'ize all source mount points. closes #117 2015-09-06 18:24:36 -04:00
Antonio SJ Musumeci accd2d4ae0 Merge pull request #125 from trapexit/xattr-minfreespace
fix non-suffixed setxattr of user.mergerfs.minfreespace
2015-09-06 12:07:43 -04:00
Antonio SJ Musumeci 2d899479c3 fix non-suffixed setxattr of user.mergerfs.minfreespace 2015-09-05 23:08:11 -04:00
Antonio SJ Musumeci 803b2ae999 Merge pull request #122 from trapexit/clean-version
remove version.hpp on clean
2015-09-05 22:30:49 -04:00
Antonio SJ Musumeci e98b801c9d remove version.hpp on clean 2015-09-05 22:29:28 -04:00
Antonio SJ Musumeci 27cf7f8148 Merge pull request #121 from trapexit/xattr-version
add user.mergerfs.version xattr
2015-09-05 21:55:43 -04:00
Antonio SJ Musumeci b22528bac4 add user.mergerfs.version xattr 2015-09-05 21:48:15 -04:00
Antonio SJ Musumeci adf983c8c3 Merge pull request #120 from trapexit/policies-xattr
add user.mergerfs.policies xattr
2015-09-05 20:04:12 -04:00
Antonio SJ Musumeci e377d54c93 add user.mergerfs.policies xattr 2015-09-05 19:49:08 -04:00
Antonio SJ Musumeci 7bee6230ba Merge pull request #119 from trapexit/rpm
add building of rpm
2015-09-05 18:44:14 -04:00
Antonio SJ Musumeci 08d07b71e1 add building of rpm 2015-09-05 18:41:18 -04:00
Antonio SJ Musumeci ce2462042f Merge pull request #118 from trapexit/basic-fedora-build
add basic instructions for building on Fedora
2015-09-05 16:35:40 -04:00
Antonio SJ Musumeci 305f190f09 add basic instructions for building on Fedora 2015-09-05 16:34:59 -04:00
Antonio SJ Musumeci d89735abf6 Merge pull request #114 from trapexit/xattr
refactor and simplify getxattr for user.mergerfs.\*
2015-09-03 17:24:57 -04:00
Antonio SJ Musumeci 8178bf518c refactor and simplify getxattr for user.mergerfs.\* 2015-09-03 16:56:54 -04:00
Antonio SJ Musumeci 22d254e8df Merge pull request #113 from trapexit/git2dbcl
use correct variable for finding version
2015-09-02 08:02:26 -04:00
Antonio SJ Musumeci aea5e440d7 use correct variable for finding version 2015-09-02 08:02:12 -04:00
Antonio SJ Musumeci 908a2f61f7 Merge pull request #112 from trapexit/epmfs+minfreespace
add minfreespace check to epmfs create policy
2015-09-01 22:37:45 -04:00
Antonio SJ Musumeci bc77b0fd2a add minfreespace check to epmfs create policy 2015-09-01 22:28:35 -04:00
Antonio SJ Musumeci 4141181243 Merge pull request #111 from trapexit/rename
rework rename
2015-09-01 18:35:22 -04:00
Antonio SJ Musumeci 1f1e481075 rework rename
Return EXDEV if directories of tragets differ. If the old and new path exist in the same directory first rename each old found by the policy and then unlink/rmdir any new on a drive which didn't rename. The unlink/rmdir will occur only if there were no rename errors. Any failures of unlink/rmdir are ignored. The last rename error is returned.
2015-09-01 18:32:31 -04:00
Antonio SJ Musumeci 6b5b7c38f4 Merge pull request #109 from trapexit/einval
forgot to add einval to policy
2015-08-30 17:08:58 -04:00
Antonio SJ Musumeci 7a93198d4a forgot to add einval to policy 2015-08-30 17:08:24 -04:00
Antonio SJ Musumeci fd26793305 Merge pull request #108 from trapexit/error-policies
create errno policies for simulating errors. closes #107
2015-08-27 22:52:20 -04:00
Antonio SJ Musumeci bbc75f6ff1 create errno policies for simulating errors. closes #107 2015-08-27 22:38:23 -04:00
Antonio SJ Musumeci cac5f1b827 Merge pull request #106 from trapexit/epmfs-fix
fix epmfs failing to pick the existing path. closes #102
2015-08-24 15:52:47 -04:00
Antonio SJ Musumeci 126df0fbf1 fix epmfs failing to pick the existing path. closes #102 2015-08-24 15:51:17 -04:00
Antonio SJ Musumeci 2cc9b42c9c Merge pull request #101 from trapexit/buildupdate
enhance deb building
2015-08-07 21:05:52 -04:00
Antonio SJ Musumeci ab68ac0cb1 enhance deb building 2015-08-07 21:03:39 -04:00
Antonio SJ Musumeci f3a3609998 Merge pull request #100 from trapexit/readme
format README better for man pages
2015-08-07 21:02:28 -04:00
Antonio SJ Musumeci e73ea33e9c format README better for man pages 2015-08-07 20:59:43 -04:00
Antonio SJ Musumeci c2164457bc Merge pull request #97 from trapexit/option-docs
update README regarding options
2015-08-05 12:30:14 -04:00
Antonio SJ Musumeci 95192511b1 update README regarding options 2015-08-05 12:29:53 -04:00
Antonio SJ Musumeci 7775d6830c Merge pull request #96 from trapexit/epmfs-fix
remove unused variable
2015-08-05 12:00:03 -04:00
Antonio SJ Musumeci 8767db971a remove unused variable 2015-08-05 11:59:39 -04:00
Antonio SJ Musumeci 838c081b8c Merge pull request #94 from trapexit/config-cleanup
config get and struct naming cleanup
2015-08-05 11:51:33 -04:00
Antonio SJ Musumeci ac41bc43f3 Merge pull request #95 from trapexit/flags
move requesting of FUSE flags to init from cli args
2015-08-05 11:50:54 -04:00
Antonio SJ Musumeci 267f2d291c move requesting of FUSE flags to init from cli args 2015-08-05 11:50:21 -04:00
Antonio SJ Musumeci f130d07fd8 config get and struct naming cleanup 2015-08-05 09:28:53 -04:00
Antonio SJ Musumeci 81dbafdc19 Merge pull request #93 from trapexit/ioctlfixes
passthrough ioctl args without processing. closes #90
2015-08-05 09:23:23 -04:00
Antonio SJ Musumeci 52d80299b5 passthrough ioctl args without processing. closes #90 2015-08-05 09:18:34 -04:00
Antonio SJ Musumeci 416cb4a084 Merge pull request #92 from trapexit/timecompare
use gte rather than gt for mtime comparisons. fixes #91
2015-08-04 14:09:20 -04:00
Antonio SJ Musumeci c60d03831f use gte rather than gt for mtime comparisons. fixes #91 2015-08-04 14:03:44 -04:00
Antonio SJ Musumeci ac03e08d31 Merge pull request #89 from trapexit/openpath
add creation of full path for open
2015-07-16 16:58:14 -04:00
Antonio SJ Musumeci 80b2c35175 add creation of full path for open 2015-07-16 16:57:01 -04:00
Antonio SJ Musumeci f8f63cdbd1 Merge pull request #87 from trapexit/namespaces
change fuse functions to use the fuse namespace
2015-07-15 10:54:23 -04:00
Antonio SJ Musumeci 983fa9100d change fuse functions to use the fuse namespace 2015-07-15 10:53:13 -04:00
Antonio SJ Musumeci efadd2c8d8 Merge pull request #86 from trapexit/readdir-cleanup
remove unused readdir function
2015-07-15 10:51:43 -04:00
Antonio SJ Musumeci c505ec0cdb Merge pull request #85 from trapexit/pthread_getugid_np
use pthread_getugid_np instead of gete{u,g}id on OSX. fixes #84
2015-07-15 10:51:20 -04:00
Antonio SJ Musumeci e5359ebd05 remove unused readdir function 2015-07-15 10:50:25 -04:00
Antonio SJ Musumeci f00cd1467e use pthread_getugid_np instead of gete{u,g}id on OSX. fixes #84 2015-07-15 10:39:47 -04:00
Antonio SJ Musumeci e4be3aac2a Merge pull request #83 from trapexit/enotsup
ignore ENOTSUP errors when cloning paths. fixes #82
2015-07-13 12:21:48 -04:00
Antonio SJ Musumeci 4d605388a4 ignore ENOTSUP errors when cloning paths. fixes #82 2015-07-13 12:20:19 -04:00
Antonio SJ Musumeci 2ee3d4eec2 Merge pull request #81 from trapexit/num
add str to size_t conversion code
2015-07-05 21:03:34 -04:00
Antonio SJ Musumeci aafc1e9394 add str to size_t conversion code 2015-07-05 21:02:42 -04:00
Antonio SJ Musumeci eebfe456f6 Merge pull request #80 from trapexit/minfreespace-xattr
add minfreespace to xattr interface
2015-07-05 20:01:12 -04:00
Antonio SJ Musumeci b3109ac506 add minfreespace to xattr interface 2015-07-05 19:36:23 -04:00
Antonio SJ Musumeci 54484f35fc Merge pull request #79 from trapexit/readme
Readme
2015-07-03 10:51:29 -04:00
Antonio SJ Musumeci d079856e09 add info on lfs and fwfs policies and minfreespace option 2015-07-03 10:49:18 -04:00
Antonio SJ Musumeci c101430b98 rework category -> fuse function table 2015-07-03 10:49:18 -04:00
Antonio SJ Musumeci 1d798ad285 Merge pull request #78 from trapexit/typed-policies
Typed policies
2015-07-03 10:47:02 -04:00
Antonio SJ Musumeci b2cd79154a stop auto calculating and storing fullpath in policies 2015-07-03 10:40:47 -04:00
Antonio SJ Musumeci 0c60701b29 create different policies based on category of use 2015-07-03 08:53:36 -04:00
Antonio SJ Musumeci 51b6d3f647 add category to policies so as to distinguish between creates and searches 2015-07-03 08:51:19 -04:00
Antonio SJ Musumeci a5bf48c8ae Merge pull request #77 from trapexit/paths
Paths
2015-06-23 22:30:35 -04:00
Antonio SJ Musumeci 6ca43893ea separate policies into individual modules 2015-06-23 22:27:01 -04:00
Antonio SJ Musumeci 3c8f12281f move policy function type from fs to policy 2015-06-23 00:24:14 -04:00
Antonio SJ Musumeci 2bd44568a1 move Path object to separate file 2015-06-22 23:22:51 -04:00
Antonio SJ Musumeci 23cca83742 Merge pull request #76 from trapexit/lfs
create lfs policy. closes #73
2015-06-22 11:27:58 -04:00
Antonio SJ Musumeci 8e5b79647b create lfs policy. closes #73 2015-06-22 11:06:36 -04:00
Antonio SJ Musumeci 9ea4bf2828 Merge pull request #75 from trapexit/fwfs
first w/ free space policy. closes #72
2015-06-22 11:03:49 -04:00
Antonio SJ Musumeci 58167c3636 first w/ free space policy. closes #72 2015-06-22 10:53:39 -04:00
Antonio SJ Musumeci 6578b93190 Merge pull request #74 from trapexit/minfreespace
create minfreespace option. closes #71
2015-06-22 10:19:03 -04:00
Antonio SJ Musumeci ccb22c1fbe create minfreespace option. closes #71 2015-06-22 09:59:16 -04:00
Antonio SJ Musumeci ad7ce487bb fix readme typos and misc formatting 2015-06-05 20:13:24 -04:00
Antonio SJ Musumeci fd2ba50cad Merge pull request #70 from trapexit/readme
Readme
2015-06-05 19:53:14 -04:00
Antonio SJ Musumeci fe0f442c3d add Tips and FAQ section to readme 2015-06-05 19:52:31 -04:00
Antonio SJ Musumeci 1879c9c4a9 update readme with defaults option info 2015-06-04 23:19:49 -04:00
Antonio SJ Musumeci 247bac76eb Merge pull request #69 from trapexit/getxattr
fix calling of lgetxattr. closes #68
2015-06-04 21:46:44 -04:00
Antonio SJ Musumeci 45b73e53be fix calling of lgetxattr. closes #68 2015-06-04 09:31:43 -04:00
Antonio SJ Musumeci ffc90f52bc Merge pull request #67 from trapexit/priority
attempt to set priority to -10 on startup. closes #65
2015-03-17 20:40:35 -04:00
Antonio SJ Musumeci 5fb277529f attempt to set priority to -10 on startup. closes #65 2015-03-17 20:39:20 -04:00
Antonio SJ Musumeci 7552ad6781 Merge pull request #66 from trapexit/pseudo-file-permissions
restrict who can setxattr the pseudo file. closes #64
2015-03-13 20:45:25 -04:00
Antonio SJ Musumeci 4b204b8fba restrict who can setxattr the pseudo file. closes #64 2015-03-13 20:31:02 -04:00
Antonio SJ Musumeci 4ea49fcfbb Merge pull request #63 from trapexit/defaults
provide 'defaults' option. closes #58
2015-03-11 18:23:57 -04:00
Antonio SJ Musumeci 33c837a560 provide 'defaults' option. closes #58 2015-03-11 18:21:28 -04:00
Antonio SJ Musumeci 3725387132 Merge pull request #62 from trapexit/subtype
set FUSE subtype to 'mergerfs'. closes #59
2015-03-11 14:08:11 -04:00
Antonio SJ Musumeci 951b22b671 set FUSE subtype to 'mergerfs'. closes #59 2015-03-11 14:00:47 -04:00
Antonio SJ Musumeci 0a0e8fdefc Merge pull request #61 from trapexit/docs
add default policies for categories and description of `all`
2015-03-10 18:53:40 -04:00
Antonio SJ Musumeci 74c334c372 add default policies for categories and description of all 2015-03-10 18:53:06 -04:00
Antonio SJ Musumeci 711261bb02 Merge pull request #60 from trapexit/options
match cli options to xattrs
2015-03-10 18:45:11 -04:00
Antonio SJ Musumeci 08366a35be match cli options to xattrs 2015-03-10 18:44:45 -04:00
Antonio SJ Musumeci 8b41dca91a Merge pull request #57 from trapexit/remove-fileinfo
remove FileInfo and keep only file descriptor
2015-03-05 22:16:49 -05:00
Antonio SJ Musumeci 91671d7364 remove FileInfo and keep only file descriptor 2015-03-05 22:15:54 -05:00
Antonio SJ Musumeci 15b2c8be1b Merge pull request #56 from trapexit/revert-all-policy-removal
revert removal of 'all' policy and relevant behavior. closes #54
2015-03-05 21:07:05 -05:00
Antonio SJ Musumeci c022741ffb revert removal of 'all' policy and relevant behavior. closes #54 2015-03-05 21:01:22 -05:00
Antonio SJ Musumeci a359c88173 Merge pull request #55 from trapexit/policyperfunc
per FUSE function policies. closes #52, #53
2015-03-05 20:42:18 -05:00
Antonio SJ Musumeci 12f393a55e per FUSE function policies. closes #52, #53 2015-02-23 20:02:50 -05:00
Antonio SJ Musumeci e0f0bb53f7 Merge pull request #51 from trapexit/rlimits
Try RLIMIT_INFINITY first, then cur = max, then loop and try to increase...
2015-02-17 11:48:55 -05:00
Antonio SJ Musumeci 283a2b2285 Try RLIMIT_INFINITY first, then cur = max, then loop and try to increase till error. closes #50 2015-02-17 11:46:54 -05:00
Antonio SJ Musumeci dba9e00adc Merge pull request #49 from trapexit/clonefdleak
close file after getting ioc flags. closes #48
2015-02-17 00:36:25 -05:00
Antonio SJ Musumeci 1a1c9db37b close file after getting ioc flags. closes #48 2015-02-17 00:28:27 -05:00
Antonio SJ Musumeci f3f5a18ef5 Merge pull request #47 from trapexit/getxattr_all
add user.mergerfs.allpaths and user.mergerfs.relpath to getxattr
2015-02-07 18:49:36 -05:00
Antonio SJ Musumeci d30cae217b add user.mergerfs.allpaths and user.mergerfs.relpath to getxattr 2015-02-07 18:27:47 -05:00
Antonio SJ Musumeci dbe630c37d Merge pull request #46 from trapexit/action-search-merge
merge action and search category
2015-02-05 19:59:04 -05:00
Antonio SJ Musumeci 2e95c6e78e merge action and search category 2015-02-05 18:23:01 -05:00
Antonio SJ Musumeci 58ec83dcd8 Merge pull request #45 from trapexit/remove_all
Remove 'all' policy and simplify logic
2015-02-03 18:03:44 -05:00
Antonio SJ Musumeci b411c63df1 Remove 'all' policy and simplify logic 2015-02-02 23:59:45 -05:00
Antonio SJ Musumeci 1f61a662ad Merge pull request #44 from trapexit/platformdefines
use standard platform macros. closes #43
2015-02-02 21:32:23 -05:00
Antonio SJ Musumeci 1f90203025 use standard platform macros. closes #43 2015-02-02 21:30:31 -05:00
Antonio SJ Musumeci 805bc2d2e6 Merge pull request #42 from trapexit/clonepath
clonepath fixes
2015-01-29 14:54:13 -05:00
Antonio SJ Musumeci c2cbb93c25 elevate privileges when calling clonepath. closes #41 2015-01-29 14:28:38 -05:00
Antonio SJ Musumeci 6276ce9779 handle EEXIST while cloning a path. closes #40 2015-01-29 14:28:38 -05:00
Antonio SJ Musumeci d1f3bd82e8 add clonepath tool 2015-01-29 14:28:34 -05:00
Antonio SJ Musumeci 031b87f674 slight refactoring 2015-01-27 16:08:13 -05:00
Antonio SJ Musumeci 233c216e66 Merge pull request #39 from trapexit/truncate_mount_list
remove longest common prefix from fsname. closes #38
2015-01-22 16:33:34 -05:00
Antonio SJ Musumeci 5dd072962b remove longest common prefix from fsname. closes #38 2015-01-22 16:30:12 -05:00
Antonio SJ Musumeci 90b0fcd5f5 Merge pull request #35 from trapexit/dttoif
provide stat to readdir filler. closes #32
2014-11-10 21:11:17 -05:00
Antonio SJ Musumeci 66563aa142 Merge pull request #34 from trapexit/byref
pass const strings by reference. closes #33
2014-11-10 21:10:31 -05:00
Antonio SJ Musumeci 6c3ff01a0a pass const strings by reference. closes #33 2014-11-10 21:01:20 -05:00
Antonio SJ Musumeci d7ede20abe provide stat to readdir filler. closes #32 2014-11-10 07:41:15 -05:00
Antonio SJ Musumeci 19051925db Merge pull request #31 from trapexit/compat
support RHEL6. closes #29
2014-11-04 13:57:34 -05:00
Antonio SJ Musumeci 613b996296 support RHEL6. closes #29 2014-11-04 13:52:04 -05:00
Antonio SJ Musumeci 39c750b368 Merge branch 'no-merges' 2014-09-29 19:30:12 -04:00
Antonio SJ Musumeci 47522a25cc exclude merges in the debian changelog. closes #28 2014-09-26 22:51:33 -04:00
Antonio SJ Musumeci 6c31efc964 Merge branch 'dirioctl' 2014-09-26 18:33:51 -04:00
Antonio SJ Musumeci 075d62d647 add support for ioctl on directories. closes #27 2014-09-26 18:33:20 -04:00
Antonio SJ Musumeci cfe7609bcd find functions now return errors. closes #24 2014-08-23 11:44:40 -04:00
Antonio SJ Musumeci 8f35406000 use lstat to confirm file existance instead of eaccess. closes #25 2014-08-22 17:54:38 -04:00
Antonio SJ Musumeci 4ea1adbf96 use f_frsize rather than f_bsize for mfs calculations. closes #26 2014-08-22 17:06:59 -04:00
Antonio SJ Musumeci 15f88494e4 add custom git log to debian changelog script 2014-08-14 21:54:22 -04:00
Antonio SJ Musumeci 7e9ccd0317 support runtime setting of srcmounts. closes #12 2014-08-08 10:20:27 -04:00
Antonio SJ Musumeci 992e05e897 update docs for xattr features 2014-07-31 17:27:43 -04:00
Antonio SJ Musumeci b82db46e29 getxattr for user.mergerfs.{base,full}path returns the source paths. closes #23 2014-07-30 15:26:49 -04:00
Antonio SJ Musumeci 7b0d703f00 only allow manipulation of runtime settings via xattrs. closes #22 2014-07-29 09:26:11 -04:00
Antonio SJ Musumeci 45cec2d301 use int instead of long for ioctl. fixes #21 2014-07-22 07:07:25 -04:00
Antonio SJ Musumeci 2295714548 on ENOENT try cloning the dest path to source drive. closes #20 2014-07-07 21:54:38 -04:00
209 changed files with 12668 additions and 4493 deletions
+12
View File
@@ -11,3 +11,15 @@
*.lai
*.la
*.a
# build artifacts
mergerfs
obj/
src/version.hpp
# Debian files
debian/files
debian/changelog
# RPM files
rpmbuild/
+12 -18
View File
@@ -1,23 +1,17 @@
/*
The MIT License (MIT)
ISC License
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2016, 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:
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 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.
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.
*/
+142 -75
View File
@@ -1,40 +1,39 @@
# The MIT License (MIT)
# Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
#
# Copyright (c) 2014 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.
#
# 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.
# 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.
PKGCONFIG = $(shell which pkg-config)
GIT = $(shell which git)
TAR = $(shell which tar)
MKDIR = $(shell which mkdir)
TOUCH = $(shell which touch)
CP = $(shell which cp)
RM = $(shell which rm)
FIND = $(shell which find)
INSTALL = $(shell which install)
MKTEMP = $(shell which mktemp)
STRIP = $(shell which strip)
PANDOC = $(shell which pandoc)
GIT = $(shell which git)
TAR = $(shell which tar)
MKDIR = $(shell which mkdir)
TOUCH = $(shell which touch)
CP = $(shell which cp)
RM = $(shell which rm)
LN = $(shell which ln)
FIND = $(shell which find)
INSTALL = $(shell which install)
MKTEMP = $(shell which mktemp)
STRIP = $(shell which strip)
PANDOC = $(shell which pandoc)
SED = $(shell which sed)
GZIP = $(shell which gzip)
RPMBUILD = $(shell which rpmbuild)
GIT2DEBCL = ./tools/git2debcl
CPPFIND = ./tools/cppfind
ifeq ($(PKGCONFIG),"")
$(error "pkg-config not installed"
$(error "pkg-config not installed")
endif
ifeq ($(PANDOC),"")
@@ -53,48 +52,77 @@ ifeq ($(FUSE_AVAILABLE),0)
$(error "FUSE development package doesn't appear available")
endif
OPTS = -O2
SRC = $(wildcard src/*.cpp)
OBJ = $(SRC:src/%.cpp=obj/%.o)
DEPS = $(OBJ:obj/%.o=obj/%.d)
TARGET = mergerfs
MANPAGE = $(TARGET).1
CFLAGS = -g -Wall \
$(OPTS) \
$(shell $(PKGCONFIG) fuse --cflags) \
-DFUSE_USE_VERSION=26 \
-MMD
LDFLAGS = $(shell $(PKGCONFIG) fuse --libs)
FLAG_NOPATH = $(shell $(CPPFIND) "flag_nopath")
FALLOCATE = $(shell $(CPPFIND) "fuse_fs_fallocate")
FLOCK = $(shell $(CPPFIND) "fuse_fs_flock")
READ_BUF = $(shell $(CPPFIND) "fuse_fs_read_buf")
WRITE_BUF = $(shell $(CPPFIND) "fuse_fs_write_buf")
BINDIR = $(PREFIX)/usr/bin
MANDIR = $(PREFIX)/usr/share/man/man1
INSTALLTARGET = $(DESTDIR)/$(BINDIR)/$(TARGET)
MANTARGET = $(DESTDIR)/$(MANDIR)/$(MANPAGE)
UGID_USE_RWLOCK = 0
OPTS = -O2
SRC = $(wildcard src/*.cpp)
OBJ = $(SRC:src/%.cpp=obj/%.o)
DEPS = $(OBJ:obj/%.o=obj/%.d)
TARGET = mergerfs
MANPAGE = $(TARGET).1
FUSE_CFLAGS = $(shell $(PKGCONFIG) --cflags fuse)
CFLAGS = -g -Wall \
$(OPTS) \
-Wno-unused-result \
$(FUSE_CFLAGS) \
-DFUSE_USE_VERSION=29 \
-MMD \
-DFLAG_NOPATH=$(FLAG_NOPATH) \
-DFALLOCATE=$(FALLOCATE) \
-DFLOCK=$(FLOCK) \
-DREAD_BUF=$(READ_BUF) \
-DWRITE_BUF=$(WRITE_BUF) \
-DUGID_USE_RWLOCK=$(UGID_USE_RWLOCK)
LDFLAGS = $(shell $(PKGCONFIG) fuse --libs)
PREFIX = /usr/local
EXEC_PREFIX = $(PREFIX)
DATAROOTDIR = $(PREFIX)/share
DATADIR = $(DATAROOTDIR)
BINDIR = $(EXEC_PREFIX)/bin
SBINDIR = $(EXEC_PREFIX)/sbin
MANDIR = $(DATAROOTDIR)/man
MAN1DIR = $(MANDIR)/man1
INSTALLBINDIR = $(DESTDIR)$(BINDIR)
INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
ifeq ($(XATTR_AVAILABLE),0)
$(warning "xattr not available: disabling")
CFLAGS += -DWITHOUT_XATTR
endif
KERNEL = $(shell uname -s)
ifeq ($(KERNEL),Linux)
CFLAGS += -DLINUX
endif
ifeq ($(KERNEL),Darwin)
CFLAGS += -DOSX
endif
all: $(TARGET)
help:
@echo "usage: make"
@echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
$(TARGET): obj/obj-stamp $(OBJ)
$(TARGET): src/version.hpp obj/obj-stamp $(OBJ)
$(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
mount.mergerfs: $(TARGET)
$(LN) -fs "$<" "$@"
changelog:
$(GIT) log --pretty --numstat --summary | git2cl > ChangeLog
$(GIT2DEBCL) --name $(TARGET) > ChangeLog
authors:
$(GIT) log --format='%aN <%aE>' | sort -f | uniq > AUTHORS
src/version.hpp:
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
@echo "#ifndef _VERSION_HPP" > src/version.hpp
@echo "#define _VERSION_HPP" >> src/version.hpp
@echo "static const char MERGERFS_VERSION[] = \"$(VERSION)\";" >> src/version.hpp
@echo "#endif" >> src/version.hpp
obj/obj-stamp:
$(MKDIR) -p obj
@@ -103,42 +131,81 @@ obj/obj-stamp:
obj/%.o: src/%.cpp
$(CXX) $(CFLAGS) -c $< -o $@
clean:
$(RM) -rf obj "$(TARGET)" "$(MANPAGE)"
$(FIND) -name "*~" -delete
clean: rpm-clean
$(RM) -rf obj
$(RM) -f src/version.hpp
$(RM) -f "$(TARGET)" mount.mergerfs
$(FIND) . -name "*~" -delete
distclean: clean
$(GIT) clean -ifd
$(GIT) clean -fd
install: $(TARGET) $(MANPAGE)
$(INSTALL) -m 0755 -D "$(TARGET)" "$(INSTALLTARGET)"
$(INSTALL) -m 0644 -D "$(MANPAGE)" "$(MANTARGET)"
install: install-base install-mount.mergerfs install-man
install-strip: install
$(STRIP) "$(INSTALLTARGET)"
install-base: $(TARGET)
$(MKDIR) -p "$(INSTALLBINDIR)"
$(INSTALL) -v -m 0755 "$(TARGET)" "$(INSTALLBINDIR)/$(TARGET)"
uninstall:
$(RM) "$(INSTALLTARGET)"
$(RM) "$(MANTARGET)"
install-mount.mergerfs: mount.mergerfs
$(MKDIR) -p "$(INSTALLBINDIR)"
$(CP) -a "$<" "$(INSTALLBINDIR)/$<"
install-man: $(MANPAGE)
$(MKDIR) -p "$(INSTALLMAN1DIR)"
$(INSTALL) -v -m 0644 "man/$(MANPAGE)" "$(INSTALLMAN1DIR)/$(MANPAGE)"
install-strip: install-base
$(STRIP) "$(INSTALLBINDIR)/$(TARGET)"
uninstall: uninstall-base uninstall-mount.mergerfs uninstall-man
uninstall-base:
$(RM) -f "$(INSTALLBINDIR)/$(TARGET)"
uninstall-mount.mergerfs:
$(RM) -f "$(INSTALLBINDIR)/mount.mergerfs"
uninstall-man:
$(RM) -f "$(INSTALLMAN1DIR)/$(MANPAGE)"
$(MANPAGE): README.md
$(PANDOC) -s -t man -o $(MANPAGE) README.md
ifneq (,$(PANDOC))
$(PANDOC) -s -t man -o "man/$(MANPAGE)" README.md
endif
man: $(MANPAGE)
tarball: clean changelog man
tarball: clean man changelog authors src/version.hpp
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
$(eval VERSION := $(subst -,_,$(VERSION)))
$(eval FILENAME := $(TARGET)-$(VERSION))
$(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX))
$(MKDIR) $(TMPDIR)/$(FILENAME)
$(CP) -ar . $(TMPDIR)/$(FILENAME)
$(TAR) --exclude=.git -cz -C $(TMPDIR) -f ../$(FILENAME).tar.gz $(FILENAME)
$(TAR) --exclude=.git -cz -C $(TMPDIR) -f $(FILENAME).tar.gz $(FILENAME)
$(RM) -rf $(TMPDIR)
deb:
debian-changelog:
$(GIT2DEBCL) --name $(TARGET) > debian/changelog
signed-deb: debian-changelog
dpkg-buildpackage
deb: debian-changelog
dpkg-buildpackage -uc -us
rpm-clean:
$(RM) -rf rpmbuild
rpm: tarball
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
$(GIT) dch --auto --release --new-version="$(VERSION)"
$(GIT) buildpackage --git-ignore-new
$(eval VERSION := $(subst -,_,$(VERSION)))
$(MKDIR) -p rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SOURCES
$(SED) 's/__VERSION__/$(VERSION)/g' $(TARGET).spec > \
rpmbuild/SOURCES/$(TARGET).spec
cp -ar $(TARGET)-$(VERSION).tar.gz rpmbuild/SOURCES
$(RPMBUILD) -ba rpmbuild/SOURCES/$(TARGET).spec \
--define "_topdir $(CURDIR)/rpmbuild"
.PHONY: all clean install help
+397 -78
View File
@@ -1,136 +1,455 @@
% mergerfs(1) mergerfs user manual
% Antonio SJ Musumeci <trapexit@spawn.link>
% June 9, 2014
% 2016-10-13
# NAME
mergerfs - another FUSE union filesystem
mergerfs - another (FUSE based) union filesystem
# SYNOPSIS
mergerfs -ocreate=epmfs,search=ff,action=ff &lt;srcpoints&gt; &lt;mountpoint&gt;
mergerfs -o&lt;options&gt; &lt;srcmounts&gt; &lt;mountpoint&gt;
# DESCRIPTION
mergerfs is similar to mhddfs, unionfs, and aufs. Like mhddfs in that it too uses FUSE. Like aufs in that it provides multiple policies for how to handle behavior.
**mergerfs** is a union filesystem geared towards simplifying storage and management of files across numerous commodity storage devices. It is similar to **mhddfs**, **unionfs**, and **aufs**.
Why create mergerfs when those exist? mhddfs isn't really maintained or flexible. There are also issues with running as root. aufs is more flexible but contains some hard to debug inconsistencies in behavior. Neither support file attributes ([chattr](http://linux.die.net/man/1/chattr)).
# FEATURES
* Runs in userspace (FUSE)
* Configurable behaviors
* Support for extended attributes (xattrs)
* Support for file attributes (chattr)
* Runtime configurable (via xattrs)
* Safe to run as root
* Opportunistic credential caching
* Works with heterogeneous filesystem types
* Handling of writes to full drives (transparently move file to drive with capacity)
* Handles pool of readonly and read/write drives
# OPTIONS
###options###
| Option | Default |
|--------|--------|
| search | ff |
| action | ff |
| create | epmfs |
* **defaults**: a shortcut for FUSE's **atomic_o_trunc**, **auto_cache**, **big_writes**, **default_permissions**, **splice_move**, **splice_read**, and **splice_write**. These options seem to provide the best performance.
* **direct_io**: causes FUSE to bypass an addition caching step which can increase write speeds at the detriment of read speed.
* **minfreespace**: the minimum space value used for creation policies. Understands 'K', 'M', and 'G' to represent kilobyte, megabyte, and gigabyte respectively. (default: 4G)
* **moveonenospc**: when enabled (set to **true**) if a **write** fails with **ENOSPC** or **EDQUOT** a scan of all drives will be done looking for the drive with most free space which is at least the size of the file plus the amount which failed to write. An attempt to move the file to that drive will occur (keeping all metadata possible) and if successful the original is unlinked and the write retried. (default: false)
* **func.&lt;func&gt;=&lt;policy&gt;**: sets the specific FUSE function's policy. See below for the list of value types. Example: **func.getattr=newest**
* **category.&lt;category&gt;=&lt;policy&gt;**: Sets policy of all FUSE functions in the provided category. Example: **category.create=mfs**
* **fsname**: sets the name of the filesystem as seen in **mount**, **df**, etc. Defaults to a list of the source paths concatenated together with the longest common prefix removed.
###srcpoints###
**NOTE:** Options are evaluated in the order listed so if the options are **func.rmdir=rand,category.action=ff** the **action** category setting will override the **rmdir** setting.
The source points argument is a colon (':') delimited list of paths. To make it simplier to include multiple source points without having to modify your [fstab](http://linux.die.net/man/5/fstab) we also support [globbing](http://linux.die.net/man/7/glob).
###srcmounts###
The srcmounts (source mounts) argument is a colon (':') delimited list of paths to be included in the pool. It does not matter if the paths are on the same or different drives nor does it matter the filesystem. Used and available space will not be duplicated for paths on the same device and any features which aren't supported by the underlying filesystem (such as file attributes or extended attributes) will return the appropriate errors.
To make it easier to include multiple source mounts mergerfs supports [globbing](http://linux.die.net/man/7/glob). **The globbing tokens MUST be escaped when using via the shell else the shell itself will expand it.**
```
$ mergerfs /mnt/disk*:/mnt/cdrom /media/drives
$ mergerfs -o defaults,allow_other /mnt/disk\*:/mnt/cdrom /media/drives
```
The above line will use all points in /mnt prefixed with *disk* and the directory *cdrom*.
The above line will use all mount points in /mnt prefixed with **disk** and the **cdrom**.
In /etc/fstab it'd look like the following:
To have the pool mounted at boot or otherwise accessable from related tools use **/etc/fstab**.
```
# <file system> <mount point> <type> <options> <dump> <pass>
/mnt/disk*:/mnt/cdrom /media/drives fuse.mergerfs allow_other 0 0
# <file system> <mount point> <type> <options> <dump> <pass>
/mnt/disk*:/mnt/cdrom /media/drives fuse.mergerfs defaults,allow_other 0 0
```
**NOTE:** the globbing is done at mount time. If a new directory is added matching the glob after the fact it will not be included.
**NOTE:** the globbing is done at mount or xattr update time (see below). If a new directory is added matching the glob after the fact it will not be automatically included.
# POLICIES
**NOTE:** for mounting via **fstab** to work you must have **mount.fuse** installed. For Ubuntu/Debian it is included in the **fuse** package.
Filesystem calls are broken up into 4 functional categories: search, action, create, and none. These categories can be assigned a policy which dictates how [mergerfs](http://github.com/trapexit/mergerfs) behaves while when action on the filesystem. Any policy can be assigned to a category though some aren't terribly practical. For instance: rand (Random) may be useful for **create** but could lead to very odd behavior if used for **search** or **action**. Since the input for any policy is the source mounts and fusepath and the output a vector of targets the choice was made to simplify the implementation and allow a policies usage in any category. **NOTE:** In any policy which can return more than one location (currently only **all**) the first value will be used in **search** and **create** policies since they can only ever act on 1 filepath.
# FUNCTIONS / POLICIES / CATEGORIES
#### Functional classifications ####
| Class | FUSE calls |
|-------|------------|
| search | access, getattr, getxattr, listxattr, open, readlink |
| action | chmod, link, removexattr, rmdir, setxattr, truncate, unlink, utimens |
| create | create, mkdir, mknod |
| none | fallocate, fgetattr, fsync, ftruncate, ioctl, read, readdir, rename, statfs, symlink, write, release |
The POSIX filesystem API has a number of functions. **creat**, **stat**, **chown**, etc. In mergerfs these functions are grouped into 3 categories: **action**, **create**, and **search**. Functions and categories can be assigned a policy which dictates how **mergerfs** behaves. Any policy can be assigned to a function or category though some are not very practical. For instance: **rand** (random) may be useful for file creation (create) but could lead to very odd behavior if used for `chmod` (though only if there were more than one copy of the file).
Policies, when called to create, will ignore drives which are readonly or have less than **minfreespace**. This allows for read/write and readonly drives to be mixed together and keep drives which may remount as readonly on error from further affecting the pool.
#### Function / Category classifications ####
| Category | FUSE Functions |
|----------|----------------|
| action | chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate, unlink, utimens |
| create | create, mkdir, mknod, symlink |
| search | access, getattr, getxattr, ioctl, listxattr, open, readlink |
| N/A | fallocate, fgetattr, fsync, ftruncate, ioctl, read, readdir, release, statfs, write |
Due to FUSE limitations **ioctl** behaves differently if its acting on a directory. It'll use the **getattr** policy to find and open the directory before issuing the **ioctl**. In other cases where something may be searched (to confirm a directory exists across all source mounts) **getattr** will also be used.
#### Policy descriptions ####
| Policy | Description |
|--------------|-------------|
| ff (first found) | Given the order the paths were provided at mount time act on the first one found (regardless if stat would return EACCES). |
| ffwp (first found w/ permissions) | Given the order the paths were provided at mount time act on the first one found which you have access (stat does not error with EACCES). |
| newest (newest file) | If multiple files exist return the one with the most recent mtime. |
| all (all files found) | Attempt to apply the call to each file found. If any sub call succeeds the entire operation succeeds and other errors ignored. If all fail then the last error is reported. |
| mfs (most free space) | Assuming the path is found to exist (ENOENT would not be returned) use the drive with the most free space available. |
| epmfs (existing path, most free space) | If the path exists in multiple locations use the one with the most free space. Otherwise fall back to mfs. |
| rand (random) | Pick a destination at random. Again the dirname of the full path must exist somewhere. |
| all | Search category: acts like **ff**. Action category: apply to all found. Create category: for **mkdir**, **mknod**, and **symlink** it will apply to all found. **create** works like **ff**. It will exclude readonly drives and those with free space less than **minfreespace**. |
| epall (existing path, all) | Search category: acts like **epff**. Action category: apply to all found. Create category: for **mkdir**, **mknod**, and **symlink** it will apply to all existing paths found. **create** works like **epff**. It will exclude readonly drives and those with free space less than **minfreespace**. |
| epff | Given the order of the drives, as defined at mount time or when configured via the xattr interface, act on the first one found where the path already exists. For **create** category it will exclude readonly drives and those with free space less than **minfreespace** (unless there is no other option). Falls back to **ff**. |
| eplfs (existing path, least free space) | If the path exists on multiple drives use the one with the least free space. For **create** category it will exclude readonly drives and those with free space less than **minfreespace**. Falls back to **lfs**. |
| eplus (existing path, least used space) | If the path exists on multiple drives use the one with the least used space. For **create** category it will exclude readonly drives and those with free space less than **minfreespace**. Falls back to **lus**. |
| epmfs (existing path, most free space) | If the path exists on multiple drives use the one with the most free space. For **create** category it will exclude readonly drives and those with free space less than **minfreespace**. Falls back to **mfs**. |
| eprand (existing path, random) | Calls **epall** and then randomizes. |
| erofs | Exclusively return **-1** with **errno** set to **EROFS**. By setting **create** functions to this you can in effect turn the filesystem readonly. |
| ff (first found) | Given the order of the drives, as defined at mount time or when configured via xattr interface, act on the first one found. For **create** category it will exclude readonly drives and those with free space less than **minfreespace** (unless there is no other option). |
| lfs (least free space) | Pick the drive with the least available free space. For **create** category it will exclude readonly drives and those with free space less than **minfreespace**. Falls back to **mfs**. |
| lus (least used space) | Pick the drive with the least used space. For **create** category it will exclude readonly drives and those with free space less than **minfreespace**. Falls back to **mfs**. |
| mfs (most free space) | Pick the drive with the most available free space. For **create** category it will exclude readonly drives and those with free space less than **minfreespace**. Falls back to **ff**. |
| newest (newest file) | Pick the file / directory with the largest mtime. For **create** category it will exclude readonly drives and those with free space less than **minfreespace** (unless there is no other option). |
| rand (random) | Calls **all** and then randomizes. |
**epff**, **eplfs**, **eplus**, and **epmf** are path preserving policies. As the descriptions above explain they will only consider drives where the path being accessed exists. Non-path preserving policies will clone paths as necessary.
#### Defaults ####
| Category | Policy |
|----------|--------|
| action | all |
| create | epmfs |
| search | ff |
#### rename & link ####
[rename](http://man7.org/linux/man-pages/man2/rename.2.html) is a tricky function in a merged system. Normally if a rename can't be done atomically due to the source and destination paths existing on different mount points it will return **-1** with **errno = EXDEV**. The atomic rename is most critical for replacing files in place atomically (such as securing writing to a temp file and then replacing a target). The problem is that by merging multiple paths you can have N instances of the source and destinations on different drives. This can lead to several undesirable situtations with or without errors and it's not entirely obvious what to do when an error occurs.
Originally mergerfs would return EXDEV whenever a rename was requested which was cross directory in any way. This made the code simple and was technically complient with POSIX requirements. However, many applications fail to handle EXDEV at all and treat it as a normal error or they only partially support EXDEV (don't respond the same as `mv` would). Such apps include: gvfsd-fuse v1.20.3 and prior, Finder / CIFS/SMB client in Apple OSX 10.9+, NZBGet, Samba's recycling bin feature.
* If using a **create** policy which tries to preserve directory paths (epff,eplfs,eplus,epmfs)
* Using the **rename** policy get the list of files to rename
* For each file attempt rename:
* If failure with ENOENT run **create** policy
* If create policy returns the same drive as currently evaluating then clone the path
* Re-attempt rename
* If **any** of the renames succeed the higher level rename is considered a success
* If **no** renames succeed the first error encountered will be returned
* On success:
* Remove the target from all drives with no source file
* Remove the source from all drives which failed to rename
* If using a **create** policy which does **not** try to preserve directory paths
* Using the **rename** policy get the list of files to rename
* Using the **getattr** policy get the target path
* For each file attempt rename:
* If the source drive != target drive:
* Clone target path from target drive to source drive
* Rename
* If **any** of the renames succeed the higher level rename is considered a success
* If **no** renames succeed the first error encountered will be returned
* On success:
* Remove the target from all drives with no source file
* Remove the source from all drives which failed to rename
The the removals are subject to normal entitlement checks.
The above behavior will help minimize the likelihood of EXDEV being returned but it will still be possible. To remove the possibility all together mergerfs would need to perform the as **mv** does when it receives EXDEV normally.
**link** uses the same basic strategy.
#### readdir ####
[readdir](http://linux.die.net/man/3/readdir) is different from all other filesystem functions. While it could have it's own set of policies to tweak its behavior at this time it provides a simple union of files and directories found. Remember that any action or information queried about these files and directories come from the respective function. For instance: an **ls** is a **readdir** and for each file/directory returned **getattr** is called. Meaning the policy of **getattr** is responsible for choosing the file/directory which is the source of the metadata you see in an **ls**.
#### statvfs ####
It normalizes the source drives based on the fragment size and sums the number of adjusted blocks and inodes. This means you will see the combined space of all sources. Total, used, and free. The sources however are dedupped based on the drive so multiple points on the same drive will not result in double counting it's space.
**NOTE:** create is really a search for existence and then create. The 'search' policy applies to the first part. If the [dirname](http://linux.die.net/man/3/dirname) of the full path is not found to exist [ENOENT](http://linux.die.net/man/3/errno) is returned.
[statvfs](http://linux.die.net/man/2/statvfs) normalizes the source drives based on the fragment size and sums the number of adjusted blocks and inodes. This means you will see the combined space of all sources. Total, used, and free. The sources however are dedupped based on the drive so multiple sources on the same drive will not result in double counting it's space.
# BUILDING
* Need to install FUSE development libraries (libfuse-dev).
* Optionally need libattr1 (libattr1-dev).
**NOTE:** Prebuilt packages can be found at: https://github.com/trapexit/mergerfs/releases
First get the code from [github](http://github.com/trapexit/mergerfs).
```
[trapexit:~/dev/mergerfs] $ make help
usage: make
make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)
$ git clone https://github.com/trapexit/mergerfs.git
$ # or
$ wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.tar.gz
```
# Runtime Settings
#### Debian / Ubuntu
```
$ sudo apt-get install g++ pkg-config git git-buildpackage pandoc debhelper libfuse-dev libattr1-dev python
$ cd mergerfs
$ make deb
$ sudo dpkg -i ../mergerfs_version_arch.deb
```
#### /.mergerfs pseudo file ####
#### Fedora
```
$ su -
# dnf install rpm-build fuse-devel libattr-devel pandoc gcc-c++ git make which python
# cd mergerfs
# make rpm
# rpm -i rpmbuild/RPMS/<arch>/mergerfs-<verion>.<arch>.rpm
```
#### Generically
Have git, python, pkg-config, pandoc, libfuse, libattr1 installed.
```
$ cd mergerfs
$ make
$ make man
$ sudo make install
```
# RUNTIME
#### .mergerfs pseudo file ####
```
<mountpoint>/.mergerfs
```
There is a pseudo file available at the mountpoint which allows for the runtime modification of policies. The file will not show up in readdirs but can be stat'ed, read, and writen. Most other calls will fail with EPERM, EINVAL, or whatever may be appropriate for that call. Anything not understood while writing will result in EINVAL otherwise the number of bytes written will be returned.
There is a pseudo file available at the mount point which allows for the runtime modification of certain **mergerfs** options. The file will not show up in **readdir** but can be **stat**'ed and manipulated via [{list,get,set}xattrs](http://linux.die.net/man/2/listxattr) calls.
Reading the file will result in a newline delimited list of current settings as followed:
Even if xattrs are disabled for mergerfs the [{list,get,set}xattrs](http://linux.die.net/man/2/listxattr) calls against this pseudo file will still work.
Any changes made at runtime are **not** persisted. If you wish for values to persist they must be included as options wherever you configure the mounting of mergerfs (fstab).
##### Keys #####
Use `xattr -l /mount/point/.mergerfs` to see all supported keys. Some are informational and therefore readonly.
###### user.mergerfs.srcmounts ######
Used to query or modify the list of source mounts. When modifying there are several shortcuts to easy manipulation of the list.
| Value | Description |
|--------------|-------------|
| [list] | set |
| +<[list] | prepend |
| +>[list] | append |
| -[list] | remove all values provided |
| -< | remove first in list |
| -> | remove last in list |
###### minfreespace ######
Input: interger with an optional multiplier suffix. **K**, **M**, or **G**.
Output: value in bytes
###### moveonenospc ######
Input: **true** and **false**
Ouput: **true** or **false**
###### categories / funcs ######
Input: short policy string as described elsewhere in this document
Output: the policy string except for categories where its funcs have multiple types. In that case it will be a comma separated list
##### Example #####
```
[trapexit:/tmp/mount] $ cat .mergerfs
action=ff
create=epmfs
search=ff
```
[trapexit:/tmp/mount] $ xattr -l .mergerfs
user.mergerfs.srcmounts: /tmp/a:/tmp/b
user.mergerfs.minfreespace: 4294967295
user.mergerfs.moveonenospc: false
...
Writing to the file is buffered and waits till a newline to process. Meaning echo works well.
```
[trapexit:/tmp/mount] $ echo "search=newest" >> .mergerfs
[trapexit:/tmp/mount] $ cat .mergerfs
action=ff
create=epmfs
search=newest
```
*NOTE:* offset is not supported and ignored in both read and write. There is also a safety check which limits buffered + incoming length to a max of 1024 bytes.
#### xattrs ####
If xattrs has been enabled you can also use [{list,get,set}xattrs](http://linux.die.net/man/2/listxattr) on the pseudo file **.mergerfs** to modify the policies. The keys are **mergerfs.action**, **mergerfs.create**, and **mergerfs.search**.
```
[trapexit:/tmp/mount] $ attr -l .mergerfs
Attribute "mergerfs.action" has a 2 byte value for .mergerfs
Attribute "mergerfs.create" has a 5 byte value for .mergerfs
Attribute "mergerfs.search" has a 2 byte value for .mergerfs
[trapexit:/tmp/mount] $ attr -g mergerfs.action .mergerfs
Attribute "mergerfs.action" had a 2 byte value for .mergerfs:
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.category.search .mergerfs
ff
[trapexit:/tmp/mount] 1 $ attr -s mergerfs.action -V ffwp .mergerfs
Attribute "mergerfs.action" set to a 4 byte value for .mergerfs:
ffwp
[trapexit:/tmp/mount] $ xattr -w user.mergerfs.category.search newest .mergerfs
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.category.search .mergerfs
newest
[trapexit:/tmp/mount] $ xattr -w user.mergerfs.srcmounts +/tmp/c .mergerfs
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.srcmounts .mergerfs
/tmp/a:/tmp/b:/tmp/c
[trapexit:/tmp/mount] $ xattr -w user.mergerfs.srcmounts =/tmp/c .mergerfs
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.srcmounts .mergerfs
/tmp/c
[trapexit:/tmp/mount] $ xattr -w user.mergerfs.srcmounts '+</tmp/a:/tmp/b' .mergerfs
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.srcmounts .mergerfs
/tmp/a:/tmp/b:/tmp/c
```
#### file / directory xattrs ####
While they won't show up when using [listxattr](http://linux.die.net/man/2/listxattr) **mergerfs** offers a number of special xattrs to query information about the files served. To access the values you will need to issue a [getxattr](http://linux.die.net/man/2/getxattr) for one of the following:
* **user.mergerfs.basepath:** the base mount point for the file given the current getattr policy
* **user.mergerfs.relpath:** the relative path of the file from the perspective of the mount point
* **user.mergerfs.fullpath:** the full path of the original file given the getattr policy
* **user.mergerfs.allpaths:** a NUL ('\0') separated list of full paths to all files found
```
[trapexit:/tmp/mount] $ ls
A B C
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.fullpath A
/mnt/a/full/path/to/A
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.basepath A
/mnt/a
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.relpath A
/full/path/to/A
[trapexit:/tmp/mount] $ xattr -p user.mergerfs.allpaths A | tr '\0' '\n'
/mnt/a/full/path/to/A
/mnt/b/full/path/to/A
```
# TOOLING
* https://github.com/trapexit/mergerfs-tools
* mergerfs.ctl: A tool to make it easier to query and configure mergerfs at runtime
* mergerfs.fsck: Provides permissions and ownership auditing and the ability to fix them
* mergerfs.dedup: Will help identify and optionally remove duplicate files
* mergerfs.mktrash: Creates FreeDesktop.org Trash specification compatible directories on a mergerfs mount
* https://github.com/trapexit/scorch
* scorch: A tool to help discover silent corruption of files
# TIPS / NOTES
* https://github.com/trapexit/backup-and-recovery-howtos : A set of guides / howtos on creating a data storage system, backing it up, maintaining it, and recovering from failure.
* If you don't see some directories / files you expect in a merged point be sure the user has permission to all the underlying directories. If `/drive0/a` has is owned by `root:root` with ACLs set to `0700` and `/drive1/a` is `root:root` and `0755` you'll see only `/drive1/a`. Use `mergerfs.fsck` to audit the drive for out of sync permissions.
* Do *not* use `direct_io` if you expect applications (such as rtorrent) to [mmap](http://linux.die.net/man/2/mmap) files. It is not currently supported in FUSE w/ `direct_io` enabled.
* Since POSIX gives you only error or success on calls its difficult to determine the proper behavior when applying the behavior to multiple targets. **mergerfs** will return an error only if all attempts of an action fail. Any success will lead to a success returned.
* The recommended options are **defaults,allow_other**. The **allow_other** is to allow users who are not the one which executed mergerfs access to the mountpoint. **defaults** is described above and should offer the best performance. It's possible that if you're running on an older platform the **splice** features aren't available and could error. In that case simply use the other options manually.
* If write performance is valued more than read it may be useful to enable **direct_io**. Best to benchmark with and without and choose appropriately.
* Remember: some policies mixed with some functions may result in strange behaviors. Not that some of these behaviors and race conditions couldn't happen outside **mergerfs** but that they are far more likely to occur on account of attempt to merge together multiple sources of data which could be out of sync due to the different policies.
* An example: [Kodi](http://kodi.tv) and [Plex](http://plex.tv) can use directory [mtime](http://linux.die.net/man/2/stat) to more efficiently determine whether to scan for new content rather than simply performing a full scan. If using the current default **getattr** policy of **ff** its possible **Kodi** will miss an update on account of it returning the first directory found's **stat** info and its a later directory on another mount which had the **mtime** recently updated. To fix this you will want to set **func.getattr=newest**. Remember though that this is just **stat**. If the file is later **open**'ed or **unlink**'ed and the policy is different for those then a completely different file or directory could be acted on.
* Due to previously mentioned issues its generally best to set **category** wide policies rather than individual **func**'s. This will help limit the confusion of tools such as [rsync](http://linux.die.net/man/1/rsync).
# KNOWN ISSUES / BUGS
#### rtorrent fails with ENODEV (No such device)
Be sure to turn off `direct_io`. rtorrent and some other applications use [mmap](http://linux.die.net/man/2/mmap) to read and write to files and offer no failback to traditional methods. FUSE does not currently support mmap while using `direct_io`. There will be a performance penalty on writes with `direct_io` off but it's the only way to get such applications to work. If the performance loss is too high for other apps you can mount mergerfs twice. Once with `direct_io` enabled and one without it.
#### mmap performance is really bad
There [is a bug](https://lkml.org/lkml/2016/3/16/260) in caching which affects overall performance of mmap through FUSE in Linux 4.x kernels. It is fixed in [4.4.10 and 4.5.4](https://lkml.org/lkml/2016/5/11/59).
#### Trashing files occasionally fails
This is the same issue as with Samba. `rename` returns `EXDEV` (in our case that will really only happen with path preserving policies like `epmfs`) and the software doesn't handle the situtation well. This is unfortunately a common failure of software which moves files around. The standard indicates that an implementation `MAY` choose to support non-user home directory trashing of files (which is a `MUST`). The implementation `MAY` also support "top directory trashes" which many probably do.
To create a `$topdir/.Trash` directory as defined in the standard use the [mergerfs-tools](https://github.com/trapexit/mergerfs-tools) tool `mergerfs.mktrash`.
#### Samba: Moving files / directories fails
Workaround: Copy the file/directory and then remove the original rather than move.
This isn't an issue with Samba but some SMB clients. GVFS-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed to handle certain error codes correctly. Particularly **STATUS_NOT_SAME_DEVICE** which comes from the **EXDEV** which is returned by **rename** when the call is crossing mount points. When a program gets an **EXDEV** it needs to explicitly take an alternate action to accomplish it's goal. In the case of **mv** or similar it tries **rename** and on **EXDEV** falls back to a manual copying of data between the two locations and unlinking the source. In these older versions of GVFS-fuse if it received **EXDEV** it would translate that into **EIO**. This would cause **mv** or most any application attempting to move files around on that SMB share to fail with a IO error.
[GVFS-fuse v1.22.0](https://bugzilla.gnome.org/show_bug.cgi?id=734568) and above fixed this issue but a large number of systems use the older release. On Ubuntu the version can be checked by issuing `apt-cache showpkg gvfs-fuse`. Most distros released in 2015 seem to have the updated release and will work fine but older systems may not. Upgrading gvfs-fuse or the distro in general will address the problem.
In Apple's MacOSX 10.9 they replaced Samba (client and server) with their own product. It appears their new client does not handle **EXDEV** either and responds similar to older release of gvfs on Linux.
#### Supplemental user groups
Due to the overhead of [getgroups/setgroups](http://linux.die.net/man/2/setgroups) mergerfs utilizes a cache. This cache is opportunistic and per thread. Each thread will query the supplemental groups for a user when that particular thread needs to change credentials and will keep that data for the lifetime of the thread. This means that if a user is added to a group it may not be picked up without the restart of mergerfs. However, since the high level FUSE API's (at least the standard version) thread pool dynamically grows and shrinks it's possible that over time a thread will be killed and later a new thread with no cache will start and query the new data.
The gid cache uses fixed storage to simplify the design and be compatible with older systems which may not have C++11 compilers. There is enough storage for 256 users' supplemental groups. Each user is allowed upto 32 supplemental groups. Linux >= 2.6.3 allows upto 65535 groups per user but most other *nixs allow far less. NFS allowing only 16. The system does handle overflow gracefully. If the user has more than 32 supplemental groups only the first 32 will be used. If more than 256 users are using the system when an uncached user is found it will evict an existing user's cache at random. So long as there aren't more than 256 active users this should be fine. If either value is too low for your needs you will have to modify `gidcache.hpp` to increase the values. Note that doing so will increase the memory needed by each thread.
#### mergerfs or libfuse crashing
If suddenly the mergerfs mount point disappears and `Transport endpoint is not connected` is returned when attempting to perform actions within the mount directory **and** the version of libfuse (use `mergerfs -v` to find the version) is older than `2.9.4` its likely due to a bug in libfuse. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu Precise and others.
In order to fix this please install newer versions of libfuse. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just install newer versions of [libfuse](https://packages.debian.org/unstable/libfuse2) and [fuse](https://packages.debian.org/unstable/fuse) from the repo of a newer release.
#### mergerfs under heavy load and memory preasure leads to kernel panic
https://lkml.org/lkml/2016/9/14/527
```
[25192.515454] kernel BUG at /build/linux-a2WvEb/linux-4.4.0/mm/workingset.c:346!
[25192.517521] invalid opcode: 0000 [#1] SMP
[25192.519602] Modules linked in: netconsole ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 configfs binfmt_misc veth bridge stp llc nf_conntrack_ipv6 nf_defrag_ipv6 xt_conntrack ip6table_filter ip6_tables xt_multiport iptable_filter ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_comment xt_nat iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack xt_CHECKSUM xt_tcpudp iptable_mangle ip_tables x_tables intel_rapl x86_pkg_temp_thermal intel_powerclamp eeepc_wmi asus_wmi coretemp sparse_keymap kvm_intel ppdev kvm irqbypass mei_me 8250_fintek input_leds serio_raw parport_pc tpm_infineon mei shpchp mac_hid parport lpc_ich autofs4 drbg ansi_cprng dm_crypt algif_skcipher af_alg btrfs raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid0 multipath linear raid10 raid1 i915 crct10dif_pclmul crc32_pclmul aesni_intel i2c_algo_bit aes_x86_64 drm_kms_helper lrw gf128mul glue_helper ablk_helper syscopyarea cryptd sysfillrect sysimgblt fb_sys_fops drm ahci r8169 libahci mii wmi fjes video [last unloaded: netconsole]
[25192.540910] CPU: 2 PID: 63 Comm: kswapd0 Not tainted 4.4.0-36-generic #55-Ubuntu
[25192.543411] Hardware name: System manufacturer System Product Name/P8H67-M PRO, BIOS 3904 04/27/2013
[25192.545840] task: ffff88040cae6040 ti: ffff880407488000 task.ti: ffff880407488000
[25192.548277] RIP: 0010:[<ffffffff811ba501>] [<ffffffff811ba501>] shadow_lru_isolate+0x181/0x190
[25192.550706] RSP: 0018:ffff88040748bbe0 EFLAGS: 00010002
[25192.553127] RAX: 0000000000001c81 RBX: ffff8802f91ee928 RCX: ffff8802f91eeb38
[25192.555544] RDX: ffff8802f91ee938 RSI: ffff8802f91ee928 RDI: ffff8804099ba2c0
[25192.557914] RBP: ffff88040748bc08 R08: 000000000001a7b6 R09: 000000000000003f
[25192.560237] R10: 000000000001a750 R11: 0000000000000000 R12: ffff8804099ba2c0
[25192.562512] R13: ffff8803157e9680 R14: ffff8803157e9668 R15: ffff8804099ba2c8
[25192.564724] FS: 0000000000000000(0000) GS:ffff88041f280000(0000) knlGS:0000000000000000
[25192.566990] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[25192.569201] CR2: 00007ffabb690000 CR3: 0000000001e0a000 CR4: 00000000000406e0
[25192.571419] Stack:
[25192.573550] ffff8804099ba2c0 ffff88039e4f86f0 ffff8802f91ee928 ffff8804099ba2c8
[25192.575695] ffff88040748bd08 ffff88040748bc58 ffffffff811b99bf 0000000000000052
[25192.577814] 0000000000000000 ffffffff811ba380 000000000000008a 0000000000000080
[25192.579947] Call Trace:
[25192.582022] [<ffffffff811b99bf>] __list_lru_walk_one.isra.3+0x8f/0x130
[25192.584137] [<ffffffff811ba380>] ? memcg_drain_all_list_lrus+0x190/0x190
[25192.586165] [<ffffffff811b9a83>] list_lru_walk_one+0x23/0x30
[25192.588145] [<ffffffff811ba544>] scan_shadow_nodes+0x34/0x50
[25192.590074] [<ffffffff811a0e9d>] shrink_slab.part.40+0x1ed/0x3d0
[25192.591985] [<ffffffff811a53da>] shrink_zone+0x2ca/0x2e0
[25192.593863] [<ffffffff811a64ce>] kswapd+0x51e/0x990
[25192.595737] [<ffffffff811a5fb0>] ? mem_cgroup_shrink_node_zone+0x1c0/0x1c0
[25192.597613] [<ffffffff810a0808>] kthread+0xd8/0xf0
[25192.599495] [<ffffffff810a0730>] ? kthread_create_on_node+0x1e0/0x1e0
[25192.601335] [<ffffffff8182e34f>] ret_from_fork+0x3f/0x70
[25192.603193] [<ffffffff810a0730>] ? kthread_create_on_node+0x1e0/0x1e0
```
There is a bug in the kernel. A work around appears to be turning off `splice`. Add `no_splice_write,no_splice_move,no_splice_read` to mergerfs' options. Should be placed after `defaults` if it is used since it will turn them on.
# FAQ
#### Why use mergerfs over mhddfs?
mhddfs is no longer maintained and has some known stability and security issues (see below). MergerFS provides a superset of mhddfs' features and should offer the same or maybe better performance.
#### Why use mergerfs over aufs?
While aufs can offer better peak performance mergerfs offers more configurability and is generally easier to use. mergerfs however doesn't offer the same overlay features (which tends to result in whiteout files being left around the underlying filesystems.)
#### Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation / striping?
With simple JBOD / drive concatenation / stripping / RAID0 a single drive failure will lead to full pool failure. mergerfs performs a similar behavior without the catastrophic failure and general lack of recovery. Drives can fail and all other data will continue to be accessable.
When combined with something like [SnapRaid](http://www.snapraid.it) and/or an offsite full backup solution you can have the flexibilty of JBOD without the single point of failure.
#### Can drives be written to directly? Outside of mergerfs while pooled?
Yes. It will be represented immediately in the pool as the policies would describe.
#### Why do I get an "out of space" error even though the system says there's lots of space left?
Please reread the sections above about policies, path preserving, and the **moveonenospc** option. If the policy is path preserving and a drive is almost full and the drive the policy would pick then the writing of the file may fill the drive and receive ENOSPC errors. That is expected with those settings. If you don't want that: enable **moveonenospc** and don't use a path preserving policy.
#### It's mentioned that there are some security issues with mhddfs. What are they? How does mergerfs address them?
[mhddfs](https://github.com/trapexit/mhddfs) tries to handle being run as **root** by calling [getuid()](https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319) and if it returns **0** then it will [chown](http://linux.die.net/man/1/chown) the file. Not only is that a race condition but it doesn't handle many other situations. Rather than attempting to simulate POSIX ACL behaviors the proper behavior is to use [seteuid](http://linux.die.net/man/2/seteuid) and [setegid](http://linux.die.net/man/2/setegid), become the user making the original call and perform the action as them. This is how [mergerfs](https://github.com/trapexit/mergerfs) handles things.
If you are familiar with POSIX standards you'll know that this behavior poses a problem. **seteuid** and **setegid** affect the whole process and **libfuse** is multithreaded by default. We'd need to lock access to **seteuid** and **setegid** with a mutex so that the several threads aren't stepping on one anofther and files end up with weird permissions and ownership. This however wouldn't scale well. With lots of calls the contention on that mutex would be extremely high. Thankfully on Linux and OSX we have a better solution.
OSX has a [non-portable pthread extension](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/pthread_setugid_np.2.html) for per-thread user and group impersonation.
Linux does not support [pthread_setugid_np](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/pthread_setugid_np.2.html) but user and group IDs are a per-thread attribute though documentation on that fact or how to manipulate them is not well distributed. From the **4.00** release of the Linux man-pages project for [setuid](http://man7.org/linux/man-pages/man2/setuid.2.html).
> At the kernel level, user IDs and group IDs are a per-thread attribute. However, POSIX requires that all threads in a process share the same credentials. The NPTL threading implementation handles the POSIX requirements by providing wrapper functions for the various system calls that change process UIDs and GIDs. These wrapper functions (including the one for setuid()) employ a signal-based technique to ensure that when one thread changes credentials, all of the other threads in the process also change their credentials. For details, see nptl(7).
Turns out the setreuid syscalls apply only to the thread. GLIBC hides this away using RT signals to inform all threads to change credentials. Taking after **Samba** mergerfs uses **syscall(SYS_setreuid,...)** to set the callers credentials for that thread only. Jumping back to **root** as necessary should escalated privileges be needed (for instance: to clone paths).
For non-Linux systems mergerfs uses a read-write lock and changes credentials only when necessary. If multiple threads are to be user X then only the first one will need to change the processes credentials. So long as the other threads need to be user X they will take a readlock allow multiple threads to share the credentials. Once a request comes in to run as user Y that thread will attempt a write lock and change to Y's credentials when it can. If the ability to give writers priority is supported then that flag will be used so threads trying to change credentials don't starve. This isn't the best solution but should work reasonably well. As new platforms are supported if they offer per thread credentials those APIs will be adopted.
# SUPPORT
#### Issues with the software
* github.com: https://github.com/trapexit/mergerfs/issues
* email: trapexit@spawn.link
#### Support development
* Gratipay: https://gratipay.com/~trapexit
* BitCoin: 12CdMhEPQVmjz3SSynkAEuD5q9JmhTDCZA
# LINKS
* http://github.com/trapexit/mergerfs
* http://github.com/trapexit/mergerfs-tools
* http://github.com/trapexit/scorch
* http://github.com/trapexit/backup-and-recovery-howtos
-27
View File
@@ -1,27 +0,0 @@
mergerfs (1.1.0) trusty; urgency=medium
* initial code commit
* fix building without libattr
* update build instructions in readme
* use {get,list,set}xattr to modify runtime
* use long instead of int to limit possibility of overflow in switch, closes #1
* add FS_IOC_{GET}VERSION to ioctl
* remove statfs policy
* fs::make_path should check for forward slashes, add if missing
* remove stat'ing of files in readdir. closes #3
* use eaccess to determine permissions for ffwp. closes #2
* rework policy code
* add fgetattr. closes #5
* when readdir's filler returns non-zero return ENOMEM. closes #7
* enhance Makefile
* further Makefile enhancements
* fix free space calculations. closes #8
* add debian package building
-- Antonio SJ Musumeci <trapexit@spawn.link> Fri, 30 May 2014 21:32:19 -0400
mergerfs (1.0.0) trusty; urgency=medium
* Initial commit
-- Antonio SJ Musumeci <trapexit@spawn.link> Fri, 30 May 2014 21:28:09 -0400
+15 -21
View File
@@ -4,28 +4,22 @@ Source: http://github.com/trapexit/mergerfs
Files: *
Copyright: 2014 Antonio SJ Musumeci <trapexit@spawn.link>
License: MIT
License: ISC
Files: debian/*
Copyright: 2014 Antonio SJ Musumeci <trapexit@spawn.link>
License: MIT
License: ISC
License: MIT
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.
n
License: ISC
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.
n
-1
View File
@@ -1 +0,0 @@
mergerfs_1.1.0_amd64.deb utils optional
+3
View File
@@ -6,3 +6,6 @@
%:
dh $@
override_dh_auto_install:
$(MAKE) DESTDIR=$(CURDIR)/debian/mergerfs PREFIX=/usr install
+1055
View File
File diff suppressed because it is too large Load Diff
+51
View File
@@ -0,0 +1,51 @@
Name: mergerfs
Version: __VERSION__
Release: 1%{?dist}
Summary: A FUSE union filesystem
Group: Applications/System
License: ISC
URL: https://github.com/trapexit/mergerfs
Source: mergerfs-%{version}.tar.gz
BuildRequires: gcc-c++
BuildRequires: libattr-devel
BuildRequires: fuse-devel
# rpmbuild driven by the Makefile uses git to generate a version number
BuildRequires: git
Requires: fuse
%prep
%setup -q
%description
mergerfs is similar to mhddfs, unionfs, and aufs. Like mhddfs in that it too
uses FUSE. Like aufs in that it provides multiple policies for how to handle
behavior.
%build
make %{?_smp_mflags}
%install
make install PREFIX=%{_prefix} DESTDIR=%{buildroot}
%files
%{_bindir}/*
%doc %{_mandir}/*
%changelog
* Mon Jan 25 2016 Antonio SJ Musumeci <trapexit@spawn.link>
- Remove sbin files
* Sat Sep 05 2015 Antonio SJ Musumeci <trapexit@spawn.link>
- Include PREFIX to install
* Mon Dec 29 2014 Joe Lawrence <joe.lawrence@stratus.com>
- Tweak rpmbuild to archive current git HEAD into a tarball, then (re)build in
the rpmbuild directory -- more complicated but seemingly better suited to
generate source and debug rpms.
* Fri Jun 20 2014 Joe Lawrence <joe.lawrence@stratus.com>
- Initial rpm spec file.
+35 -49
View File
@@ -1,87 +1,73 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <fuse.h>
#include <string>
#include <vector>
#include <unistd.h>
#include <errno.h>
#include "ugid.hpp"
#include "fs.hpp"
#include "config.hpp"
#include "assert.hpp"
#include "errno.hpp"
#include "fs_base_access.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
using std::string;
using std::vector;
using mergerfs::Policy;
using mergerfs::Category;
static
int
_access(const fs::SearchFunc searchFunc,
_access(Policy::Func::Search searchFunc,
const vector<string> &srcmounts,
const string fusepath,
const uint64_t minfreespace,
const char *fusepath,
const int mask)
{
int rv;
fs::PathVector path;
string fullpath;
vector<const string*> basepaths;
searchFunc(srcmounts,fusepath,path);
if(path.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,minfreespace,basepaths);
if(rv == -1)
return -errno;
rv = ::eaccess(path[0].full.c_str(),mask);
fs::path::make(basepaths[0],fusepath,fullpath);
rv = fs::eaccess(fullpath,mask);
return ((rv == -1) ? -errno : 0);
}
namespace mergerfs
{
namespace access
namespace fuse
{
int
access(const char *fusepath,
int mask)
{
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
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);
if(fusepath == config.controlfile)
return _access(*config.search,
config.srcmounts,
"/",
mask);
return _access(*config.search,
return _access(config.access,
config.srcmounts,
config.minfreespace,
fusepath,
mask);
}
+12 -20
View File
@@ -1,30 +1,22 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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.
*/
namespace mergerfs
{
namespace access
namespace fuse
{
int
access(const char *fusepath,
+11 -19
View File
@@ -1,25 +1,17 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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.
*/
#define STATIC_ASSERT(cond) assert::StaticAssert< (cond) >()
+11 -19
View File
@@ -1,25 +1,17 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <algorithm>
+11 -19
View File
@@ -1,25 +1,17 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <algorithm>
+16 -24
View File
@@ -1,25 +1,17 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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>
@@ -38,16 +30,16 @@ namespace mergerfs
(CATEGORY(action))
(CATEGORY(create))
(CATEGORY(search));
const Category * const Category::categories = &_categories_[1];
const Category &Category::invalid = Category::categories[Category::Enum::invalid];
const Category &Category::action = Category::categories[Category::Enum::action];
const Category &Category::create = Category::categories[Category::Enum::create];
const Category &Category::search = Category::categories[Category::Enum::search];
const Category &Category::search = Category::categories[Category::Enum::search];
const Category&
Category::find(const std::string str)
Category::find(const std::string &str)
{
for(int i = Enum::BEGIN; i != Enum::END; ++i)
{
@@ -66,5 +58,5 @@ namespace mergerfs
return categories[i];
return invalid;
}
}
}
+18 -26
View File
@@ -1,25 +1,17 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 __CATEGORY_HPP__
@@ -57,8 +49,8 @@ namespace mergerfs
{
}
Category(const Enum::Type enum_,
const std::string str_)
Category(const Enum::Type enum_,
const std::string &str_)
: _enum(enum_),
_str(str_)
{
@@ -66,15 +58,15 @@ namespace mergerfs
public:
operator const Enum::Type() const { return _enum; }
operator const std::string() const { return _str; }
operator const std::string&() const { return _str; }
operator const Category*() const { return this; }
bool operator==(const std::string str_) const
bool operator==(const std::string &str_) const
{ return _str == str_; }
bool operator==(const Enum::Type enum_) const
{ return _enum == enum_; }
{ return _enum == enum_; }
bool operator!=(const Category &r) const
{ return _enum != r._enum; }
@@ -82,7 +74,7 @@ namespace mergerfs
{ return _enum < r._enum; }
public:
static const Category &find(const std::string);
static const Category &find(const std::string&);
static const Category &find(const Enum::Type);
public:
+66 -49
View File
@@ -1,37 +1,31 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <errno.h>
#include <string>
#include <vector>
#include "ugid.hpp"
#include "fs.hpp"
#include "config.hpp"
#include "assert.hpp"
#include "errno.hpp"
#include "fs_base_chmod.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
using std::string;
using std::vector;
@@ -39,49 +33,72 @@ using mergerfs::Policy;
static
int
_chmod(const fs::SearchFunc searchFunc,
_chmod_loop_core(const string *basepath,
const char *fusepath,
const mode_t mode,
const int error)
{
int rv;
string fullpath;
fs::path::make(basepath,fusepath,fullpath);
rv = fs::chmod(fullpath,mode);
return calc_error(rv,error,errno);
}
static
int
_chmod_loop(const vector<const string*> &basepaths,
const char *fusepath,
const mode_t mode)
{
int error;
error = -1;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
error = _chmod_loop_core(basepaths[i],fusepath,mode,error);
}
return -error;
}
static
int
_chmod(Policy::Func::Action actionFunc,
const vector<string> &srcmounts,
const string fusepath,
const uint64_t minfreespace,
const char *fusepath,
const mode_t mode)
{
int rv;
int error;
fs::PathVector paths;
vector<const string*> basepaths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = actionFunc(srcmounts,fusepath,minfreespace,basepaths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;
for(fs::PathVector::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
{
rv &= ::chmod(i->full.c_str(),mode);
if(rv == -1)
error = errno;
}
return ((rv == -1) ? -error : 0);
return _chmod_loop(basepaths,fusepath,mode);
}
namespace mergerfs
{
namespace chmod
namespace fuse
{
int
chmod(const char *fusepath,
mode_t mode)
{
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const config::Config &config = config::get();
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);
if(fusepath == config.controlfile)
return -EPERM;
return _chmod(*config.action,
return _chmod(config.chmod,
config.srcmounts,
config.minfreespace,
fusepath,
mode);
}
+12 -20
View File
@@ -1,30 +1,22 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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.
*/
namespace mergerfs
{
namespace chmod
namespace fuse
{
int
chmod(const char *fusepath,
+69 -50
View File
@@ -1,90 +1,109 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <errno.h>
#include <string>
#include <vector>
#include "ugid.hpp"
#include "fs.hpp"
#include "config.hpp"
#include "assert.hpp"
#include "errno.hpp"
#include "fs_base_chown.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
using std::string;
using std::vector;
using mergerfs::Policy;
using mergerfs::Config;
static
int
_chown(const fs::SearchFunc searchFunc,
_chown_loop_core(const string *basepath,
const char *fusepath,
const uid_t uid,
const gid_t gid,
const int error)
{
int rv;
string fullpath;
fs::path::make(basepath,fusepath,fullpath);
rv = fs::lchown(fullpath,uid,gid);
return calc_error(rv,error,errno);
}
static
int
_chown_loop(const vector<const string*> &basepaths,
const char *fusepath,
const uid_t uid,
const gid_t gid)
{
int error;
error = -1;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
error = _chown_loop_core(basepaths[i],fusepath,uid,gid,error);
}
return -error;
}
static
int
_chown(Policy::Func::Action actionFunc,
const vector<string> &srcmounts,
const string fusepath,
const uint64_t minfreespace,
const char *fusepath,
const uid_t uid,
const gid_t gid)
{
int rv;
int error;
fs::PathVector paths;
vector<const string*> basepaths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = actionFunc(srcmounts,fusepath,minfreespace,basepaths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;
for(fs::PathVector::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
{
rv &= ::lchown(i->full.c_str(),uid,gid);
if(rv == -1)
error = errno;
}
return ((rv == -1) ? -error : 0);
return _chown_loop(basepaths,fusepath,uid,gid);
}
namespace mergerfs
{
namespace chown
namespace fuse
{
int
chown(const char *fusepath,
uid_t uid,
gid_t gid)
{
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
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);
if(fusepath == config.controlfile)
return -EPERM;
return _chown(*config.action,
return _chown(config.chown,
config.srcmounts,
config.minfreespace,
fusepath,
uid,
gid);
+12 -20
View File
@@ -1,30 +1,22 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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.
*/
namespace mergerfs
{
namespace chown
namespace fuse
{
int
chown(const char *fusepath,
+61
View File
@@ -0,0 +1,61 @@
/*
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 <unistd.h>
#include <string.h>
#include <iostream>
#include "errno.hpp"
#include "fs.hpp"
#include "fs_clonefile.hpp"
#include "fs_clonepath.hpp"
namespace clonetool
{
static
void
print_usage_and__exit(void)
{
std::cerr << "usage: clone "
<< "[path <sourcedir> <destdir> <relativepath>]"
<< " | "
<< "[file <source> <dest>]"
<< std::endl;
_exit(1);
}
int
main(const int argc,
char * const argv[])
{
int rv = 0;
if(argc == 4 && !strcmp(argv[1],"file"))
rv = fs::clonefile(argv[2],argv[3]);
else if(argc == 5 && !strcmp(argv[1],"path"))
rv = fs::clonepath(argv[2],argv[3],argv[4]);
else
print_usage_and__exit();
if(rv == -1)
std::cerr << "error: "
<< strerror(errno)
<< std::endl;
return 0;
}
}
+22
View File
@@ -0,0 +1,22 @@
/*
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.
*/
namespace clonetool
{
int
main(const int argc,
char * const *argv);
}
+91 -66
View File
@@ -1,89 +1,114 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <sstream>
#include <string>
#include <vector>
#include <unistd.h>
#include <sys/stat.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs.hpp"
#include "rwlock.hpp"
#define MINFREESPACE_DEFAULT (4294967295ULL)
#define POLICYINIT(X) X(policies[FuseFunc::Enum::X])
using std::string;
using std::vector;
namespace mergerfs
{
namespace config
Config::Config()
: destmount(),
srcmounts(),
srcmountslock(),
minfreespace(MINFREESPACE_DEFAULT),
moveonenospc(false),
POLICYINIT(access),
POLICYINIT(chmod),
POLICYINIT(chown),
POLICYINIT(create),
POLICYINIT(getattr),
POLICYINIT(getxattr),
POLICYINIT(link),
POLICYINIT(listxattr),
POLICYINIT(mkdir),
POLICYINIT(mknod),
POLICYINIT(open),
POLICYINIT(readlink),
POLICYINIT(removexattr),
POLICYINIT(rename),
POLICYINIT(rmdir),
POLICYINIT(setxattr),
POLICYINIT(symlink),
POLICYINIT(truncate),
POLICYINIT(unlink),
POLICYINIT(utimens),
controlfile("/.mergerfs")
{
Config::Config()
: action(policies[0]),
create(policies[1]),
search(policies[2]),
controlfile("/.mergerfs")
{
action = &Policy::ff;
create = &Policy::epmfs;
search = &Policy::ff;
pthread_rwlock_init(&srcmountslock,NULL);
time_t now = time(NULL);
set_category_policy("action","all");
set_category_policy("create","epmfs");
set_category_policy("search","ff");
}
controlfilestat.st_dev = 0;
controlfilestat.st_ino = 0;
controlfilestat.st_mode = (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
controlfilestat.st_nlink = 1;
controlfilestat.st_uid = ::getuid();
controlfilestat.st_gid = ::getgid();
controlfilestat.st_rdev = 0;
controlfilestat.st_size = 0;
controlfilestat.st_blksize = 1024;
controlfilestat.st_blocks = 0;
controlfilestat.st_atime = now;
controlfilestat.st_mtime = now;
controlfilestat.st_ctime = now;
}
int
Config::set_func_policy(const string &fusefunc_,
const string &policy_)
{
const Policy *policy;
const FuseFunc *fusefunc;
std::string
Config::controlfiledata() const
{
std::stringstream ss;
fusefunc = FuseFunc::find(fusefunc_);
if(fusefunc == FuseFunc::invalid)
return (errno=ENODATA,-1);
ss << "action=" << (std::string)*action << std::endl
<< "create=" << (std::string)*create << std::endl
<< "search=" << (std::string)*search << std::endl;
policy = Policy::find(policy_);
if(policy == Policy::invalid)
return (errno=EINVAL,-1);
return ss.str();
}
policies[(FuseFunc::Enum::Type)*fusefunc] = policy;
const Config&
get(void)
{
return (*((Config*)fuse_get_context()->private_data));
}
return 0;
}
Config&
get_writable(void)
{
return (*((Config*)fuse_get_context()->private_data));
}
int
Config::set_category_policy(const string &category_,
const string &policy_)
{
const Policy *policy;
const Category *category;
category = Category::find(category_);
if(category == Category::invalid)
return (errno=ENODATA,-1);
policy = Policy::find(policy_);
if(policy == Policy::invalid)
return (errno=EINVAL,-1);
for(int i = 0; i < FuseFunc::Enum::END; i++)
{
if(FuseFunc::fusefuncs[i] == (Category::Enum::Type)*category)
policies[(FuseFunc::Enum::Type)FuseFunc::fusefuncs[i]] = policy;
}
return 0;
}
}
+71 -44
View File
@@ -1,67 +1,94 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 __CONFIG_HPP__
#define __CONFIG_HPP__
#include <fuse.h>
#include <sys/stat.h>
#include <stdint.h>
#include <string>
#include <vector>
#include "policy.hpp"
#include "category.hpp"
#include "fusefunc.hpp"
namespace mergerfs
{
namespace config
class Config
{
class Config
public:
Config();
public:
int set_func_policy(const std::string &fusefunc_,
const std::string &policy_);
int set_category_policy(const std::string &category,
const std::string &policy);
public:
std::string destmount;
std::vector<std::string> srcmounts;
mutable pthread_rwlock_t srcmountslock;
uint64_t minfreespace;
bool moveonenospc;
public:
const Policy *policies[FuseFunc::Enum::END];
const Policy *&access;
const Policy *&chmod;
const Policy *&chown;
const Policy *&create;
const Policy *&getattr;
const Policy *&getxattr;
const Policy *&link;
const Policy *&listxattr;
const Policy *&mkdir;
const Policy *&mknod;
const Policy *&open;
const Policy *&readlink;
const Policy *&removexattr;
const Policy *&rename;
const Policy *&rmdir;
const Policy *&setxattr;
const Policy *&symlink;
const Policy *&truncate;
const Policy *&unlink;
const Policy *&utimens;
public:
const std::string controlfile;
public:
static
const Config &
get(const fuse_context *fc)
{
public:
Config();
return *((Config*)fc->private_data);
}
public:
std::string controlfiledata() const;
public:
std::string destmount;
std::vector<std::string> srcmounts;
const Policy *policies[Category::Enum::END];
const Policy *&action;
const Policy *&create;
const Policy *&search;
public:
const std::string controlfile;
struct stat controlfilestat;
};
const Config &get(void);
Config &get_writable(void);
}
static
Config &
get_writable(void)
{
return (*((Config*)fuse_get_context()->private_data));
}
};
}
#endif
+75 -69
View File
@@ -1,119 +1,125 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string>
#include <vector>
#include "config.hpp"
#include "ugid.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs.hpp"
#include "assert.hpp"
#include "fs_base_open.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
using std::string;
using std::vector;
using mergerfs::FileInfo;
using mergerfs::Policy;
using namespace mergerfs;
static
int
_create_controlfile(uint64_t &fh)
_create_core(const string &existingpath,
const string &createpath,
const char *fusepath,
const char *fusedirpath,
const mode_t mode,
const int flags,
uint64_t &fh)
{
fh = (uint64_t)new string;
int fd;
string fullpath;
if(createpath != existingpath)
{
const ugid::SetRootGuard ugidGuard;
fs::clonepath(existingpath,createpath,fusedirpath);
}
fs::path::make(&createpath,fusepath,fullpath);
fd = fs::open(fullpath,flags,mode);
if(fd == -1)
return -errno;
fh = reinterpret_cast<uint64_t>(new FileInfo(fd));
return 0;
}
static
int
_create(const fs::SearchFunc searchFunc,
const fs::SearchFunc createPathFunc,
_create(Policy::Func::Search searchFunc,
Policy::Func::Create createFunc,
const vector<string> &srcmounts,
const string fusepath,
const uint64_t minfreespace,
const char *fusepath,
const mode_t mode,
const int flags,
uint64_t &fh)
{
int fd;
string path;
string dirname;
fs::PathVector createpath;
fs::PathVector existingpath;
int rv;
string fullpath;
string fusedirpath;
const char *fusedirpathcstr;
vector<const string*> createpaths;
vector<const string*> existingpaths;
dirname = fs::dirname(fusepath);
searchFunc(srcmounts,dirname,existingpath);
if(existingpath.empty())
return -ENOENT;
fusedirpath = fusepath;
fs::path::dirname(fusedirpath);
fusedirpathcstr = fusedirpath.c_str();
createPathFunc(srcmounts,dirname,createpath);
if(createpath.empty())
return -ENOSPC;
if(createpath[0].base != existingpath[0].base)
fs::clonepath(existingpath[0].base,createpath[0].base,dirname);
path = fs::make_path(createpath[0].base,fusepath);
fd = ::open(path.c_str(),flags,mode);
if(fd == -1)
rv = searchFunc(srcmounts,fusedirpathcstr,minfreespace,existingpaths);
if(rv == -1)
return -errno;
fh = (uint64_t)new FileInfo(fd,flags,path);
rv = createFunc(srcmounts,fusedirpathcstr,minfreespace,createpaths);
if(rv == -1)
return -errno;
return 0;
return _create_core(*existingpaths[0],*createpaths[0],
fusepath,fusedirpathcstr,
mode,flags,fh);
}
namespace mergerfs
{
namespace create
namespace fuse
{
int
create(const char *fusepath,
mode_t mode,
struct fuse_file_info *fileinfo)
create(const char *fusepath,
mode_t mode,
fuse_file_info *ffi)
{
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
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);
if(fusepath == config.controlfile)
return _create_controlfile(fileinfo->fh);
return _create(*config.search,
*config.create,
return _create(config.getattr,
config.create,
config.srcmounts,
config.minfreespace,
fusepath,
(mode & ~fc->umask),
fileinfo->flags,
fileinfo->fh);
ffi->flags,
ffi->fh);
}
}
}
+17 -24
View File
@@ -1,37 +1,30 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <sys/types.h>
#include <fuse.h>
#include <sys/types.h>
namespace mergerfs
{
namespace create
namespace fuse
{
int
create(const char *fusepath,
mode_t mode,
struct fuse_file_info *fileinfo);
create(const char *fusepath,
mode_t mode,
fuse_file_info *ffi);
}
}
+27
View File
@@ -0,0 +1,27 @@
/*
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.
*/
namespace mergerfs
{
namespace fuse
{
void
destroy(void *)
{
}
}
}
+24
View File
@@ -0,0 +1,24 @@
/*
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.
*/
namespace mergerfs
{
namespace fuse
{
void
destroy(void *);
}
}
+29
View File
@@ -0,0 +1,29 @@
/*
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 <errno.h>
#if defined(ENODATA) && !defined(ENOATTR)
#define ENOATTR ENODATA
#endif
#if defined(ENOATTR) && !defined(ENODATA)
#define ENODATA ENOATTR
#endif
#if !defined(ENOATTR) && !defined(ENODATA)
#error "Neither ENOATTR or ENODATA defined: please contact mergerfs author with platform information"
#endif
+25 -56
View File
@@ -1,40 +1,26 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 _GNU_SOURCE
#define _GNU_SOURCE
#endif
#if FALLOCATE
#include <fuse.h>
#include <errno.h>
#include <fcntl.h>
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
using namespace mergerfs;
#include "fs_fallocate.hpp"
static
int
@@ -45,47 +31,30 @@ _fallocate(const int fd,
{
int rv;
#ifdef _GNU_SOURCE
rv = ::fallocate(fd,mode,offset,len);
#elif defined _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
if(mode)
{
rv = -1;
errno = EOPNOTSUPP;
}
else
{
rv = ::posix_fallocate(fd,offset,len);
}
#else
rv = -1;
errno = EOPNOTSUPP;
#endif
rv = fs::fallocate(fd,mode,offset,len);
return ((rv == -1) ? -errno : 0);
}
namespace mergerfs
{
namespace fallocate
namespace fuse
{
int
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
struct fuse_file_info *fi)
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
fuse_file_info *ffi)
{
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)fi->fh;
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
if(fusepath == config.controlfile)
return -EINVAL;
return _fallocate(fileinfo->fd,
return _fallocate(fi->fd,
mode,
offset,
len);
}
}
}
#endif
+17 -25
View File
@@ -1,36 +1,28 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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.
*/
namespace mergerfs
{
namespace fallocate
namespace fuse
{
int
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
struct fuse_file_info *fi);
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
fuse_file_info *fi);
}
}
+20 -50
View File
@@ -1,48 +1,24 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
static
int
_fgetattr_controlfile(const struct stat &controlfilestat,
const std::string cfdata,
struct stat &st)
{
st = controlfilestat;
st.st_size = cfdata.size();
return 0;
}
#include "fs_base_stat.hpp"
static
int
@@ -51,29 +27,23 @@ _fgetattr(const int fd,
{
int rv;
rv = ::fstat(fd,&st);
rv = fs::fstat(fd,st);
return ((rv == -1) ? -errno : 0);
}
namespace mergerfs
{
namespace fgetattr
namespace fuse
{
int
fgetattr(const char *fusepath,
struct stat *st,
struct fuse_file_info *ffi)
fgetattr(const char *fusepath,
struct stat *st,
fuse_file_info *ffi)
{
const config::Config &config = config::get();
const FileInfo *fileinfo = (FileInfo*)ffi->fh;
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
if(fusepath == config.controlfile)
return _fgetattr_controlfile(config.controlfilestat,
config.controlfiledata(),
*st);
return _fgetattr(fileinfo->fd,
return _fgetattr(fi->fd,
*st);
}
}
+16 -24
View File
@@ -1,38 +1,30 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace mergerfs
{
namespace fgetattr
namespace fuse
{
int
fgetattr(const char *fusepath,
struct stat *st,
struct fuse_file_info *fileinfo);
fgetattr(const char *fusepath,
struct stat *st,
fuse_file_info *fileinfo);
}
}
+22 -43
View File
@@ -1,53 +1,32 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 __FILEINFO_H__
#define __FILEINFO_H__
#ifndef __FILEINFO_HPP__
#define __FILEINFO_HPP__
#include <string>
namespace mergerfs
class FileInfo
{
struct FileInfo
public:
FileInfo(int _fd) :
fd(_fd)
{
public:
FileInfo(int fd_,
int flags_,
std::string realpath_) :
fd(fd_),
flags(flags_),
realpath(realpath_)
{
}
}
int fd;
int flags;
std::string realpath;
public:
int fd;
};
private:
FileInfo() {}
};
}
#endif /* __FILEINFO_H__ */
#endif
+49
View File
@@ -0,0 +1,49 @@
/*
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 <fuse.h>
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_flock.hpp"
static
int
_flock(const int fd,
const int operation)
{
int rv;
rv = fs::flock(fd,operation);
return ((rv == -1) ? -errno : 0);
}
namespace mergerfs
{
namespace fuse
{
int
flock(const char *fusepath,
fuse_file_info *ffi,
int op)
{
FileInfo* fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _flock(fi->fd,op);
}
}
}
+26
View File
@@ -0,0 +1,26 @@
/*
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.
*/
namespace mergerfs
{
namespace fuse
{
int
flock(const char *fusepath,
fuse_file_info *ffi,
int op);
}
}
+21 -33
View File
@@ -1,34 +1,25 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <unistd.h>
#include <errno.h>
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_close.hpp"
#include "fs_base_dup.hpp"
static
int
@@ -36,29 +27,26 @@ _flush(const int fd)
{
int rv;
rv = dup(fd);
rv = fs::dup(fd);
if(rv == -1)
errno = EIO;
else
rv = close(rv);
rv = fs::close(rv);
return ((rv == -1) ? -errno : 0);
}
namespace mergerfs
{
namespace flush
namespace fuse
{
int
flush(const char *fusepath,
struct fuse_file_info *fi)
flush(const char *fusepath,
fuse_file_info *ffi)
{
const config::Config &config = config::get();
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
if(fusepath == config.controlfile)
return 0;
return _flush(((FileInfo*)fi->fh)->fd);
return _flush(fi->fd);
}
}
}
+14 -22
View File
@@ -1,33 +1,25 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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.
*/
namespace mergerfs
{
namespace flush
namespace fuse
{
int
flush(const char *path,
struct fuse_file_info *fi);
flush(const char *path,
fuse_file_info *fi);
}
}
+211 -653
View File
@@ -1,697 +1,255 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 <vector>
#include <map>
#include <sstream>
#include <cstdlib>
#include <iterator>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/types.h>
#include <unistd.h>
#include <glob.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include "fs.hpp"
#include "xattr.hpp"
#include "errno.hpp"
#include "fs_attr.hpp"
#include "fs_base_realpath.hpp"
#include "fs_base_stat.hpp"
#include "fs_base_statvfs.hpp"
#include "fs_path.hpp"
#include "fs_xattr.hpp"
#include "statvfs_util.hpp"
#include "str.hpp"
#include "success_fail.hpp"
using std::string;
using std::vector;
using std::map;
using std::istringstream;
template<typename Container>
Container&
split(Container &result,
const typename Container::value_type &s,
typename Container::value_type::value_type delimiter)
{
string str;
istringstream ss(s);
while(std::getline(ss,str,delimiter))
result.push_back(str);
return result;
}
template <typename Iter>
Iter
random_element(Iter begin,
Iter end)
{
const unsigned long n = std::distance(begin, end);
std::advance(begin, (std::rand() % n));
return begin;
}
namespace fs
{
string
dirname(const string path)
bool
exists(const string &path,
struct stat &st)
{
string parent = path;
string::reverse_iterator i;
string::reverse_iterator bi;
int rv;
bi = parent.rend();
i = parent.rbegin();
while(*i == '/' && i != bi)
i++;
rv = fs::lstat(path,st);
while(*i != '/' && i != bi)
i++;
while(*i == '/' && i != bi)
i++;
parent.erase(i.base(),parent.end());
return parent;
}
string
basename(const string path)
{
return path.substr(path.find_last_of('/')+1);
return LSTAT_SUCCEEDED(rv);
}
bool
dir_is_empty(const string path)
exists(const string &path)
{
DIR *dir;
struct dirent *de;
struct stat st;
dir = ::opendir(path.c_str());
if(!dir)
return false;
return exists(path,st);
}
while((de = ::readdir(dir)))
bool
info(const string &path,
bool &readonly,
uint64_t &spaceavail,
uint64_t &spaceused)
{
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
if(STATVFS_SUCCEEDED(rv))
{
const char *d_name = de->d_name;
readonly = StatVFS::readonly(st);
spaceavail = StatVFS::spaceavail(st);
spaceused = StatVFS::spaceused(st);
}
if(d_name[0] == '.' &&
((d_name[1] == '\0') ||
(d_name[1] == '.' && d_name[2] == '\0')))
return STATVFS_SUCCEEDED(rv);
}
bool
readonly(const string &path)
{
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
return (STATVFS_SUCCEEDED(rv) && StatVFS::readonly(st));
}
bool
spaceavail(const string &path,
uint64_t &spaceavail)
{
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
if(STATVFS_SUCCEEDED(rv))
spaceavail = StatVFS::spaceavail(st);
return STATVFS_SUCCEEDED(rv);
}
bool
spaceused(const string &path,
uint64_t &spaceused)
{
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
if(STATVFS_SUCCEEDED(rv))
spaceused = StatVFS::spaceused(st);
return STATVFS_SUCCEEDED(rv);
}
void
findallfiles(const vector<string> &srcmounts,
const char *fusepath,
vector<string> &paths)
{
string fullpath;
for(size_t i = 0, ei = srcmounts.size(); i != ei; i++)
{
fs::path::make(&srcmounts[i],fusepath,fullpath);
if(!fs::exists(fullpath))
continue;
::closedir(dir);
return false;
paths.push_back(fullpath);
}
::closedir(dir);
return true;
}
string
make_path(const string base,
const string suffix)
{
if(suffix[0] == '/' ||
*base.rbegin() == '/')
return base + suffix;
return base + '/' + suffix;
}
bool
path_exists(vector<string>::const_iterator begin,
vector<string>::const_iterator end,
const string fusepath)
{
for(vector<string>::const_iterator
iter = begin; iter != end; ++iter)
{
int rv;
string path;
path = fs::make_path(*iter,fusepath);
rv = ::eaccess(path.c_str(),F_OK);
if(rv == 0)
return true;
}
return false;
}
bool
path_exists(const vector<string> &srcmounts,
const string fusepath)
{
return path_exists(srcmounts.begin(),
srcmounts.end(),
fusepath);
}
int
listxattr(const string path,
vector<char> &attrs)
{
#ifndef WITHOUT_XATTR
int rv;
int size;
rv = -1;
errno = ERANGE;
while(rv == -1 && errno == ERANGE)
{
size = ::listxattr(path.c_str(),NULL,0);
attrs.resize(size);
rv = ::listxattr(path.c_str(),&attrs[0],size);
}
return rv;
#else
errno = ENOTSUP;
return -1;
#endif
}
int
listxattr(const string path,
vector<string> &attrvector)
findonfs(const vector<string> &srcmounts,
const char *fusepath,
const int fd,
string &basepath)
{
int rv;
vector<char> attrs;
dev_t dev;
string fullpath;
struct stat st;
rv = listxattr(path,attrs);
if(rv != -1)
{
string tmp(attrs.begin(),attrs.end());
split(attrvector,tmp,'\0');
}
return rv;
}
int
listxattr(const string path,
string &attrstr)
{
int rv;
vector<char> attrs;
rv = listxattr(path,attrs);
if(rv != -1)
attrstr = string(attrs.begin(),attrs.end());
return rv;
}
int
getxattr(const string path,
const string attr,
vector<char> &value)
{
#ifndef WITHOUT_XATTR
int rv;
int size;
rv = -1;
errno = ERANGE;
while(rv == -1 && errno == ERANGE)
{
size = ::getxattr(path.c_str(),attr.c_str(),NULL,0);
value.resize(size);
rv = ::getxattr(path.c_str(),attr.c_str(),&value[0],size);
}
return rv;
#else
errno = ENOTSUP;
return -1;
#endif
}
int
getxattr(const string path,
const string attr,
string &value)
{
int rv;
vector<char> tmpvalue;
rv = getxattr(path,attr,tmpvalue);
if(rv != -1)
value = string(tmpvalue.begin(),tmpvalue.end());
return rv;
}
int
getxattrs(const string path,
map<string,string> &attrs)
{
int rv;
string attrstr;
rv = listxattr(path,attrstr);
if(rv == -1)
rv = fs::fstat(fd,st);
if(FSTAT_FAILED(rv))
return -1;
{
string key;
istringstream ss(attrstr);
dev = st.st_dev;
for(int i = 0, ei = srcmounts.size(); i != ei; i++)
{
fs::path::make(&srcmounts[i],fusepath,fullpath);
while(getline(ss,key,'\0'))
{
string value;
rv = fs::lstat(fullpath,st);
if(FSTAT_FAILED(rv))
continue;
rv = getxattr(path,key,value);
if(rv != -1)
attrs[key] = value;
}
}
if(st.st_dev != dev)
continue;
basepath = srcmounts[i];
return 0;
}
return (errno=ENOENT,-1);
}
void
glob(const vector<string> &patterns,
vector<string> &strs)
{
int flags;
size_t veclen;
glob_t gbuf = {0};
veclen = patterns.size();
if(veclen == 0)
return;
flags = 0;
glob(patterns[0].c_str(),flags,NULL,&gbuf);
flags = GLOB_APPEND;
for(size_t i = 1; i < veclen; i++)
glob(patterns[i].c_str(),flags,NULL,&gbuf);
for(size_t i = 0; i < gbuf.gl_pathc; ++i)
strs.push_back(gbuf.gl_pathv[i]);
globfree(&gbuf);
}
void
realpathize(vector<string> &strs)
{
char *rv;
for(size_t i = 0; i < strs.size(); i++)
{
rv = fs::realpath(strs[i]);
if(rv == NULL)
continue;
strs[i] = rv;
::free(rv);
}
}
int
getfl(const int fd)
{
return ::fcntl(fd,F_GETFL,0);
}
int
mfs(const vector<string> &basepaths,
const uint64_t minfreespace,
string &path)
{
fsblkcnt_t mfs;
const string *mfsbasepath;
mfs = 0;
mfsbasepath = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
uint64_t spaceavail;
const string &basepath = basepaths[i];
if(!fs::spaceavail(basepath,spaceavail))
continue;
if(spaceavail < minfreespace)
continue;
if(spaceavail <= mfs)
continue;
mfs = spaceavail;
mfsbasepath = &basepaths[i];
}
if(mfsbasepath == NULL)
return (errno=ENOENT,-1);
path = *mfsbasepath;
return 0;
}
int
setxattr(const string path,
const string key,
const string value,
const int flags)
{
#ifndef WITHOUT_XATTR
return ::setxattr(path.c_str(),
key.c_str(),
value.data(),
value.size(),
flags);
#else
errno = ENOTSUP;
return -1;
#endif
}
int
setxattr(const int fd,
const string key,
const string value,
const int flags)
{
#ifndef WITHOUT_XATTR
return ::fsetxattr(fd,
key.c_str(),
value.data(),
value.size(),
flags);
#else
errno = ENOTSUP;
return -1;
#endif
}
int
setxattrs(const string path,
const map<string,string> &attrs)
{
int fd;
fd = ::open(path.c_str(),O_RDONLY|O_NONBLOCK);
if(fd == -1)
return -1;
for(map<string,string>::const_iterator
i = attrs.begin(), ei = attrs.end(); i != ei; ++i)
{
setxattr(fd,i->first,i->second,0);
}
return ::close(fd);
}
int
copyxattrs(const string from,
const string to)
{
int rv;
map<string,string> attrs;
rv = getxattrs(from,attrs);
if(rv == -1)
return -1;
return setxattrs(to,attrs);
}
int
copyattr(const string from,
const string to)
{
int fd;
int rv;
int flags;
int error;
const int openflags = O_RDONLY|O_NONBLOCK;
fd = ::open(from.c_str(),openflags);
if(fd == -1)
return -1;
rv = ::ioctl(fd,FS_IOC_GETFLAGS,&flags);
if(rv == -1)
{
error = errno;
::close(fd);
errno = error;
return -1;
}
fd = ::open(to.c_str(),openflags);
if(fd == -1)
return -1;
rv = ::ioctl(fd,FS_IOC_SETFLAGS,&flags);
if(rv == -1)
{
error = errno;
::close(fd);
errno = error;
return -1;
}
return ::close(fd);
}
int
clonepath(const string fromsrc,
const string tosrc,
const string relative)
{
int rv;
struct stat st;
string topath;
string frompath;
string dirname;
dirname = fs::dirname(relative);
if(!dirname.empty())
{
rv = clonepath(fromsrc,tosrc,dirname);
if(rv == -1)
return -1;
}
frompath = fs::make_path(fromsrc,relative);
rv = ::stat(frompath.c_str(),&st);
if(rv == -1)
return -1;
else if(!S_ISDIR(st.st_mode))
return (errno = ENOTDIR,-1);
topath = fs::make_path(tosrc,relative);
rv = ::mkdir(topath.c_str(),st.st_mode);
if(rv == -1)
return -1;
rv = ::chown(topath.c_str(),st.st_uid,st.st_gid);
if(rv == -1)
return -1;
// It may not support it... it's fine...
rv = copyattr(frompath,topath);
if(rv == -1 && errno != ENOTTY)
return -1;
rv = copyxattrs(frompath,topath);
if(rv == -1 && errno != ENOTTY)
return -1;
return (errno = 0);
}
namespace find
{
void
invalid(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
return;
}
void
ff(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
string path;
path = fs::make_path(*iter,fusepath);
rv = ::eaccess(path.c_str(),F_OK);
if(rv == 0)
{
paths.push_back(Path(*iter,path));
return;
}
}
return;
}
void
ffwp(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
Path fallback;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
string path;
path = fs::make_path(*iter,fusepath);
rv = ((::eaccess(path.c_str(),R_OK) == 0) ||
(::eaccess(path.c_str(),X_OK) == 0) ||
(::eaccess(path.c_str(),W_OK) == 0));
if(rv)
{
paths.push_back(Path(*iter,path));
return;
}
else if(errno == EACCES)
{
fallback.base = *iter;
fallback.full = path;
}
}
if(!fallback.base.empty())
paths.push_back(fallback);
return;
}
void
newest(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
time_t newest;
string npath;
vector<string>::const_iterator niter;
newest = 0;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
struct stat st;
const string path = fs::make_path(*iter,fusepath);
rv = ::lstat(path.c_str(),&st);
if(rv == 0 && st.st_mtime > newest)
{
newest = st.st_mtime;
niter = iter;
npath = path;
}
}
if(newest)
paths.push_back(Path(*niter,npath));
return;
}
void
all(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
string path;
path = fs::make_path(*iter,fusepath);
rv = ::eaccess(path.c_str(),F_OK);
if(rv == 0)
paths.push_back(Path(*iter,path));
}
return;
}
void
mfs(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
fsblkcnt_t mfs = 0;
string mfspath;
string fullmfspath;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
struct statvfs fsstats;
const string mountpoint = *iter;
rv = ::statvfs(mountpoint.c_str(),&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_bsize * fsstats.f_bavail);
if(spaceavail > mfs)
{
mfs = spaceavail;
mfspath = mountpoint;
}
}
}
fullmfspath = fs::make_path(mfspath,fusepath);
paths.push_back(Path(mfspath,fullmfspath));
return;
}
void
epmfs(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
fsblkcnt_t existingmfs = 0;
fsblkcnt_t generalmfs = 0;
string path;
string generalmfspath;
string existingmfspath;
vector<string>::const_iterator iter = basepaths.begin();
vector<string>::const_iterator eiter = basepaths.end();
do
{
int rv;
struct statvfs fsstats;
const string mountpoint = *iter;
rv = ::statvfs(mountpoint.c_str(),&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_bsize * fsstats.f_bavail);
if(spaceavail > generalmfs)
{
generalmfs = spaceavail;
generalmfspath = mountpoint;
}
path = fs::make_path(mountpoint,fusepath);
rv = ::eaccess(path.c_str(),F_OK);
if(rv == 0)
{
if(spaceavail > existingmfs)
{
existingmfs = spaceavail;
existingmfspath = mountpoint;
}
}
}
++iter;
}
while(iter != eiter);
if(existingmfspath.empty())
existingmfspath = generalmfspath;
paths.push_back(Path(existingmfspath,path));
return;
}
void
rand(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
string randombasepath;
string randomfullpath;
randombasepath = *random_element(basepaths.begin(),
basepaths.end());
randomfullpath = fs::make_path(randombasepath,
fusepath);
paths.push_back(Path(randombasepath,randomfullpath));
}
}
};
+39 -107
View File
@@ -1,136 +1,68 @@
/*
The MIT License (MIT)
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Copyright (c) 2014 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.
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.
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 __FS_HPP__
#define __FS_HPP__
#include <stdint.h>
#include <string>
#include <vector>
#include <map>
namespace fs
{
using std::string;
using std::vector;
using std::map;
struct Path
{
Path() {}
Path(const string b,
const string f)
: base(b),
full(f)
{}
bool exists(const string &path,
struct stat &st);
bool exists(const string &path);
string base;
string full;
};
bool info(const string &path,
bool &readonly,
uint64_t &spaceavail,
uint64_t &spaceused);
typedef vector<Path> PathVector;
typedef void (*SearchFunc)(const vector<string>&,const string,PathVector&);
bool readonly(const string &path);
string dirname(const string path);
string basename(const string path);
bool spaceavail(const string &path,
uint64_t &spaceavail);
bool dir_is_empty(const string path);
bool spaceused(const string &path,
uint64_t &spaceavail);
string make_path(const string base,
const string suffix);
void findallfiles(const vector<string> &srcmounts,
const char *fusepath,
vector<string> &paths);
bool path_exists(vector<string>::const_iterator begin,
vector<string>::const_iterator end,
const string fusepath);
bool path_exists(const vector<string> &srcmounts,
const string fusepath);
int findonfs(const vector<string> &srcmounts,
const char *fusepath,
const int fd,
string &basepath);
int clonepath(const string srcfrom,
const string srcto,
const string relative);
void glob(const vector<string> &patterns,
vector<string> &strs);
int listxattr(const string path,
vector<char> &attrs);
int listxattr(const string path,
string &attrs);
int listxattr(const string path,
vector<string> &attrs);
void realpathize(vector<string> &strs);
int getxattr(const string path,
const string attr,
vector<char> &value);
int getxattr(const string path,
const string attr,
string &value);
int getfl(const int fd);
int getxattrs(const string path,
map<string,string> &attrs);
int setxattr(const string path,
const string key,
const string value,
const int flags);
int setxattr(const int fd,
const string key,
const string value,
const int flags);
int setxattrs(const string path,
const map<string,string> &attrs);
int copyxattrs(const string from,
const string to);
int copyattr(const string from,
const string to);
namespace find
{
void invalid(const vector<string> &basepaths,
const string fusepath,
PathVector &paths);
void ff(const vector<string> &basepaths,
const string fusepath,
PathVector &paths);
void ffwp(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void newest(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void all(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void mfs(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void epmfs(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void rand(const vector<string> &paths,
const string fusepath,
PathVector &rv);
}
int mfs(const vector<string> &srcs,
const uint64_t minfreespace,
string &path);
};
#endif // __FS_HPP__
+21
View File
@@ -0,0 +1,21 @@
/*
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.
*/
#ifdef __linux__
# include "fs_attr_linux.icpp"
#else
# include "fs_attr_unsupported.icpp"
#endif
+35
View File
@@ -0,0 +1,35 @@
/*
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.
*/
#ifndef __FS_ATTR_HPP__
#define __FS_ATTR_HPP__
#include <string>
namespace fs
{
namespace attr
{
using std::string;
int copy(const int fdin,
const int fdout);
int copy(const string &from,
const string &to);
}
}
#endif // __FS_ATTR_HPP__
+127
View File
@@ -0,0 +1,127 @@
/*
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 <fcntl.h>
#include <linux/fs.h>
#include <string>
#include "errno.hpp"
#include "fs_base_close.hpp"
#include "fs_base_open.hpp"
#include "fs_base_ioctl.hpp"
using std::string;
namespace fs
{
namespace attr
{
static
int
get_fs_ioc_flags(const int fd,
int &flags)
{
return fs::ioctl(fd,FS_IOC_GETFLAGS,(void*)&flags);
}
static
int
get_fs_ioc_flags(const string &file,
int &flags)
{
int fd;
int rv;
const int openflags = O_RDONLY|O_NONBLOCK;
fd = fs::open(file,openflags);
if(fd == -1)
return -1;
rv = get_fs_ioc_flags(fd,flags);
if(rv == -1)
{
int error = errno;
fs::close(fd);
errno = error;
return -1;
}
return fs::close(fd);
}
static
int
set_fs_ioc_flags(const int fd,
const int flags)
{
return fs::ioctl(fd,FS_IOC_SETFLAGS,(void*)&flags);
}
static
int
set_fs_ioc_flags(const string &file,
const int flags)
{
int fd;
int rv;
const int openflags = O_RDONLY|O_NONBLOCK;
fd = fs::open(file,openflags);
if(fd == -1)
return -1;
rv = set_fs_ioc_flags(fd,flags);
if(rv == -1)
{
int error = errno;
fs::close(fd);
errno = error;
return -1;
}
return fs::close(fd);
}
int
copy(const int fdin,
const int fdout)
{
int rv;
int flags;
rv = get_fs_ioc_flags(fdin,flags);
if(rv == -1)
return -1;
return set_fs_ioc_flags(fdout,flags);
}
int
copy(const string &from,
const string &to)
{
int rv;
int flags;
rv = get_fs_ioc_flags(from,flags);
if(rv == -1)
return -1;
return set_fs_ioc_flags(to,flags);
}
}
}
+39
View File
@@ -0,0 +1,39 @@
/*
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 "errno.hpp"
namespace fs
{
namespace attr
{
int
copy(const int fdin,
const int fdout)
{
return ENOTSUP;
}
int
copy(const std::string &from,
const std::string &to)
{
return ENOTSUP;
}
}
}
+55
View File
@@ -0,0 +1,55 @@
/*
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 <fcntl.h>
#include <unistd.h>
namespace fs
{
static
inline
int
access(const int dirfd,
const std::string &path,
const int mode,
const int flags)
{
return ::faccessat(dirfd,path.c_str(),mode,flags);
}
static
inline
int
access(const std::string &path,
const int mode,
const int flags)
{
return fs::access(AT_FDCWD,path,mode,flags);
}
static
inline
int
eaccess(const std::string &path,
const int mode)
{
return fs::access(path,mode,AT_EACCESS);
}
}
+49
View File
@@ -0,0 +1,49 @@
/*
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 <sys/stat.h>
namespace fs
{
static
inline
int
chmod(const std::string &path,
const mode_t mode)
{
return ::chmod(path.c_str(),mode);
}
static
inline
int
fchmod(const int fd,
const mode_t mode)
{
return ::fchmod(fd,mode);
}
static
inline
int
fchmod(const int fd,
const struct stat &st)
{
return ::fchmod(fd,st.st_mode);
}
}
+74
View File
@@ -0,0 +1,74 @@
/*
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 <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
chown(const std::string &path,
const uid_t uid,
const gid_t gid)
{
return ::chown(path.c_str(),uid,gid);
}
static
inline
int
chown(const std::string &path,
const struct stat &st)
{
return fs::chown(path,st.st_uid,st.st_gid);
}
static
inline
int
lchown(const std::string &path,
const uid_t uid,
const gid_t gid)
{
return ::lchown(path.c_str(),uid,gid);
}
static
inline
int
fchown(const int fd,
const uid_t uid,
const gid_t gid)
{
return ::fchown(fd,uid,gid);
}
static
inline
int
fchown(const int fd,
const struct stat &st)
{
return fs::fchown(fd,st.st_uid,st.st_gid);
}
}
+30
View File
@@ -0,0 +1,30 @@
/*
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 <unistd.h>
namespace fs
{
static
inline
int
close(const int fd)
{
return ::close(fd);
}
}
+31
View File
@@ -0,0 +1,31 @@
/*
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 <dirent.h>
#include <sys/types.h>
namespace fs
{
static
inline
int
closedir(DIR *dirp)
{
return ::closedir(dirp);
}
}
+30
View File
@@ -0,0 +1,30 @@
/*
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 <unistd.h>
namespace fs
{
static
inline
int
dup(const int fd)
{
return ::dup(fd);
}
}
+31
View File
@@ -0,0 +1,31 @@
/*
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 <sys/file.h>
namespace fs
{
static
inline
int
flock(const int fd,
const int operation)
{
return ::flock(fd,operation);
}
}
+43
View File
@@ -0,0 +1,43 @@
/*
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 <errno.h>
#include <unistd.h>
namespace fs
{
static
inline
int
fsync(const int fd)
{
return ::fsync(fd);
}
static
inline
int
fdatasync(const int fd)
{
#if _POSIX_SYNCHRONIZED_IO > 0
return ::fdatasync(fd);
#else
return (errno=ENOSYS,-1);
#endif
}
}
+32
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 <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
ftruncate(const int fd,
const off_t size)
{
return ::ftruncate(fd,size);
}
}
+40
View File
@@ -0,0 +1,40 @@
/*
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
lgetxattr(const std::string &path,
const char *attrname,
void *value,
const size_t size)
{
#ifndef WITHOUT_XATTR
return ::lgetxattr(path.c_str(),attrname,value,size);
#else
return (errno=ENOTSUP,-1);
#endif
}
}
+32
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 <sys/ioctl.h>
namespace fs
{
static
inline
int
ioctl(const int fd,
const int request,
void *data)
{
return ::ioctl(fd,request,data);
}
}
+33
View File
@@ -0,0 +1,33 @@
/*
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
link(const std::string &oldpath,
const std::string &newpath)
{
return ::link(oldpath.c_str(),newpath.c_str());
}
}
+39
View File
@@ -0,0 +1,39 @@
/*
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
llistxattr(const std::string &path,
char *list,
const size_t size)
{
#ifndef WITHOUT_XATTR
return ::llistxattr(path.c_str(),list,size);
#else
return (errno=ENOTSUP,-1);
#endif
}
}
+33
View File
@@ -0,0 +1,33 @@
/*
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 <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
off_t
lseek(const int fd,
const off_t offset,
const int whence)
{
return ::lseek(fd,offset,whence);
}
}
+34
View File
@@ -0,0 +1,34 @@
/*
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 <sys/stat.h>
#include <sys/types.h>
namespace fs
{
static
inline
int
mkdir(const std::string &path,
const mode_t mode)
{
return ::mkdir(path.c_str(),mode);
}
}
+35
View File
@@ -0,0 +1,35 @@
/*
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 <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
mknod(const std::string &path,
const mode_t mode,
const dev_t dev)
{
return ::mknod(path.c_str(),mode,dev);
}
}
+45
View File
@@ -0,0 +1,45 @@
/*
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 <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
namespace fs
{
static
inline
int
open(const std::string &path,
const int flags)
{
return ::open(path.c_str(),flags);
}
static
inline
int
open(const std::string &path,
const int flags,
const mode_t mode)
{
return ::open(path.c_str(),flags,mode);
}
}
+33
View File
@@ -0,0 +1,33 @@
/*
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 <dirent.h>
#include <sys/types.h>
namespace fs
{
static
inline
DIR *
opendir(const std::string &name)
{
return ::opendir(name.c_str());
}
}
+43
View File
@@ -0,0 +1,43 @@
/*
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 <unistd.h>
namespace fs
{
static
inline
ssize_t
read(const int fd,
void *buf,
const size_t count)
{
return ::read(fd,buf,count);
}
static
inline
ssize_t
pread(const int fd,
void *buf,
const size_t count,
const off_t offset)
{
return ::pread(fd,buf,count,offset);
}
}
+30
View File
@@ -0,0 +1,30 @@
/*
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 <dirent.h>
namespace fs
{
static
inline
struct dirent *
readdir(DIR *dirp)
{
return ::readdir(dirp);
}
}
+34
View File
@@ -0,0 +1,34 @@
/*
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
readlink(const std::string &path,
char *buf,
const size_t bufsiz)
{
return ::readlink(path.c_str(),buf,bufsiz);
}
}
+42
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 <limits.h>
#include <stdlib.h>
namespace fs
{
static
inline
char *
realpath(const std::string &path,
char *resolved_path)
{
return ::realpath(path.c_str(),resolved_path);
}
static
inline
char *
realpath(const std::string &path)
{
return fs::realpath(path,NULL);
}
}
+38
View File
@@ -0,0 +1,38 @@
/*
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
lremovexattr(const std::string &path,
const char *attrname)
{
#ifndef WITHOUT_XATTR
return ::lremovexattr(path.c_str(),attrname);
#else
return (errno=ENOTSUP,-1);
#endif
}
}
+31
View File
@@ -0,0 +1,31 @@
/*
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 <stdio.h>
namespace fs
{
static
inline
int
rename(const std::string &oldpath,
const std::string &newpath)
{
return ::rename(oldpath.c_str(),newpath.c_str());
}
}
+32
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 <unistd.h>
namespace fs
{
static
inline
int
rmdir(const std::string &path)
{
return ::rmdir(path.c_str());
}
}
+41
View File
@@ -0,0 +1,41 @@
/*
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
lsetxattr(const std::string &path,
const char *name,
const void *value,
const size_t size,
const int flags)
{
#ifndef WITHOUT_XATTR
return ::lsetxattr(path.c_str(),name,value,size,flags);
#else
return (errno=ENOTSUP,-1);
#endif
}
}
+62
View File
@@ -0,0 +1,62 @@
/*
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 <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
stat(const char *path,
struct stat &st)
{
return ::stat(path,&st);
}
static
inline
int
stat(const std::string &path,
struct stat &st)
{
return fs::stat(path.c_str(),st);
}
static
inline
int
lstat(const std::string &path,
struct stat &st)
{
return ::lstat(path.c_str(),&st);
}
static
inline
int
fstat(const int fd,
struct stat &st)
{
return ::fstat(fd,&st);
}
}
+42
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 <sys/statvfs.h>
namespace fs
{
static
inline
int
statvfs(const char *path,
struct statvfs &st)
{
return ::statvfs(path,&st);
}
static
inline
int
statvfs(const std::string &path,
struct statvfs &st)
{
return fs::statvfs(path.c_str(),st);
}
}
+34
View File
@@ -0,0 +1,34 @@
/*
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 <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
truncate(const std::string &path,
const off_t length)
{
return ::truncate(path.c_str(),length);
}
}
+32
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 <unistd.h>
namespace fs
{
static
inline
int
unlink(const std::string &path)
{
return ::unlink(path.c_str());
}
}
+63
View File
@@ -0,0 +1,63 @@
/*
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.
*/
#ifdef __linux__
# include "fs_base_utime_utimensat.hpp"
#elif __FreeBSD__ >= 11
# include "fs_base_utime_utimensat.hpp"
#else
# include "fs_base_utime_generic.hpp"
#endif
namespace fs
{
static
inline
int
utime(const std::string &path,
const struct stat &st)
{
struct timespec times[2];
times[0] = st.st_atim;
times[1] = st.st_mtim;
return fs::utime(AT_FDCWD,path,times,0);
}
static
inline
int
utime(const int fd,
const struct stat &st)
{
struct timespec times[2];
times[0] = st.st_atim;
times[1] = st.st_mtim;
return fs::utime(fd,times);
}
static
inline
int
lutime(const std::string &path,
const struct timespec times[2])
{
return fs::utime(AT_FDCWD,path,times,AT_SYMLINK_NOFOLLOW);
}
}
+298
View File
@@ -0,0 +1,298 @@
/*
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 <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#ifndef UTIME_NOW
# define UTIME_NOW ((1l << 30) - 1l)
#endif
#ifndef UTIME_OMIT
# define UTIME_OMIT ((1l << 30) - 2l)
#endif
static
inline
bool
_can_call_lutimes(const int dirfd,
const std::string &path,
const int flags)
{
return ((flags == AT_SYMLINK_NOFOLLOW) &&
((dirfd == AT_FDCWD) ||
(path[0] == '/')));
}
static
inline
bool
_should_ignore(const struct timespec ts[2])
{
return ((ts != NULL) &&
(ts[0].tv_nsec == UTIME_OMIT) &&
(ts[1].tv_nsec == UTIME_OMIT));
}
static
inline
bool
_should_be_set_to_now(const struct timespec ts[2])
{
return ((ts == NULL) ||
((ts[0].tv_nsec == UTIME_NOW) &&
(ts[1].tv_nsec == UTIME_NOW)));
}
static
inline
bool
_timespec_invalid(const struct timespec &ts)
{
return (((ts.tv_nsec < 0) ||
(ts.tv_nsec > 999999999)) &&
((ts.tv_nsec != UTIME_NOW) &&
(ts.tv_nsec != UTIME_OMIT)));
}
static
inline
bool
_timespec_invalid(const struct timespec ts[2])
{
return ((ts != NULL) &&
(_timespec_invalid(ts[0]) ||
_timespec_invalid(ts[1])));
}
static
inline
bool
_flags_invalid(const int flags)
{
return ((flags & ~AT_SYMLINK_NOFOLLOW) != 0);
}
static
inline
bool
_any_timespec_is_utime_omit(const struct timespec ts[2])
{
return ((ts[0].tv_nsec == UTIME_OMIT) ||
(ts[1].tv_nsec == UTIME_OMIT));
}
static
inline
bool
_any_timespec_is_utime_now(const struct timespec ts[2])
{
return ((ts[0].tv_nsec == UTIME_NOW) ||
(ts[1].tv_nsec == UTIME_NOW));
}
static
inline
int
_set_utime_omit_to_current_value(const int dirfd,
const std::string &path,
const struct timespec ts[2],
struct timeval tv[2],
const int flags)
{
int rv;
struct stat st;
if(!_any_timespec_is_utime_omit(ts))
return 0;
rv = ::fstatat(dirfd,path.c_str(),&st,flags);
if(rv == -1)
return -1;
if(ts[0].tv_nsec == UTIME_OMIT)
TIMESPEC_TO_TIMEVAL(&tv[0],&st.st_atim);
if(ts[1].tv_nsec == UTIME_OMIT)
TIMESPEC_TO_TIMEVAL(&tv[1],&st.st_mtim);
return 0;
}
static
inline
int
_set_utime_omit_to_current_value(const int fd,
const struct timespec ts[2],
struct timeval tv[2])
{
int rv;
struct stat st;
if(!_any_timespec_is_utime_omit(ts))
return 0;
rv = ::fstat(fd,&st);
if(rv == -1)
return -1;
if(ts[0].tv_nsec == UTIME_OMIT)
TIMESPEC_TO_TIMEVAL(&tv[0],&st.st_atim);
if(ts[1].tv_nsec == UTIME_OMIT)
TIMESPEC_TO_TIMEVAL(&tv[1],&st.st_mtim);
return 0;
}
static
inline
int
_set_utime_now_to_now(const struct timespec ts[2],
struct timeval tv[2])
{
int rv;
struct timeval now;
if(_any_timespec_is_utime_now(ts))
return 0;
rv = ::gettimeofday(&now,NULL);
if(rv == -1)
return -1;
if(ts[0].tv_nsec == UTIME_NOW)
tv[0] = now;
if(ts[1].tv_nsec == UTIME_NOW)
tv[1] = now;
return 0;
}
static
inline
int
_convert_timespec_to_timeval(const int dirfd,
const std::string &path,
const struct timespec ts[2],
struct timeval tv[2],
struct timeval *&tvp,
const int flags)
{
int rv;
if(_should_be_set_to_now(ts))
return (tvp=NULL,0);
TIMESPEC_TO_TIMEVAL(&tv[0],&ts[0]);
TIMESPEC_TO_TIMEVAL(&tv[1],&ts[1]);
rv = _set_utime_omit_to_current_value(dirfd,path,ts,tv,flags);
if(rv == -1)
return -1;
rv = _set_utime_now_to_now(ts,tv);
if(rv == -1)
return -1;
return (tvp=tv,0);
}
static
inline
int
_convert_timespec_to_timeval(const int fd,
const struct timespec ts[2],
struct timeval tv[2],
struct timeval *&tvp)
{
int rv;
if(_should_be_set_to_now(ts))
return (tvp=NULL,0);
TIMESPEC_TO_TIMEVAL(&tv[0],&ts[0]);
TIMESPEC_TO_TIMEVAL(&tv[1],&ts[1]);
rv = _set_utime_omit_to_current_value(fd,ts,tv);
if(rv == -1)
return -1;
rv = _set_utime_now_to_now(ts,tv);
if(rv == -1)
return -1;
return (tvp=tv,0);
}
namespace fs
{
static
inline
int
utime(const int dirfd,
const std::string &path,
const struct timespec ts[2],
const int flags)
{
int rv;
struct timeval tv[2];
struct timeval *tvp;
if(_flags_invalid(flags))
return (errno=EINVAL,-1);
if(_timespec_invalid(ts))
return (errno=EINVAL,-1);
if(_should_ignore(ts))
return 0;
rv = _convert_timespec_to_timeval(dirfd,path,ts,tv,tvp,flags);
if(rv == -1)
return -1;
if((flags & AT_SYMLINK_NOFOLLOW) == 0)
return ::futimesat(dirfd,path.c_str(),tvp);
if(_can_call_lutimes(dirfd,path,flags))
return ::lutimes(path.c_str(),tvp);
return (errno=ENOTSUP,-1);
}
static
inline
int
utime(const int fd,
const struct timespec ts[2])
{
int rv;
struct timeval tv[2];
struct timeval *tvp;
if(_timespec_invalid(ts))
return (errno=EINVAL,-1);
if(_should_ignore(ts))
return 0;
rv = _convert_timespec_to_timeval(fd,ts,tv,tvp);
if(rv == -1)
return -1;
return ::futimes(fd,tvp);
}
}
+45
View File
@@ -0,0 +1,45 @@
/*
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 <fcntl.h>
#include <sys/stat.h>
namespace fs
{
static
inline
int
utime(const int dirfd,
const std::string &path,
const struct timespec times[2],
const int flags)
{
return ::utimensat(dirfd,path.c_str(),times,flags);
}
static
inline
int
utime(const int fd,
const struct timespec times[2])
{
return ::futimens(fd,times);
}
}
+43
View File
@@ -0,0 +1,43 @@
/*
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 <unistd.h>
namespace fs
{
static
inline
ssize_t
write(const int fd,
const void *buf,
const size_t count)
{
return ::write(fd,buf,count);
}
static
inline
ssize_t
pwrite(const int fd,
const void *buf,
const size_t count,
const off_t offset)
{
return ::pwrite(fd,buf,count,offset);
}
}
+222
View File
@@ -0,0 +1,222 @@
/*
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 <fcntl.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include "errno.hpp"
#include "fs_attr.hpp"
#include "fs_base_chmod.hpp"
#include "fs_base_chown.hpp"
#include "fs_base_close.hpp"
#include "fs_base_lseek.hpp"
#include "fs_base_mkdir.hpp"
#include "fs_base_open.hpp"
#include "fs_base_read.hpp"
#include "fs_base_stat.hpp"
#include "fs_base_utime.hpp"
#include "fs_base_write.hpp"
#include "fs_fadvise.hpp"
#include "fs_fallocate.hpp"
#include "fs_sendfile.hpp"
#include "fs_xattr.hpp"
#ifndef O_LARGEFILE
# define O_LARGEFILE 0
#endif
#ifndef O_NOATIME
# define O_NOATIME 0
#endif
using std::string;
using std::vector;
int
writen(const int fd,
const char *buf,
const size_t count)
{
size_t nleft;
ssize_t nwritten;
nleft = count;
while(nleft > 0)
{
nwritten = fs::write(fd,buf,nleft);
if(nwritten == -1)
{
if(errno == EINTR)
continue;
return -1;
}
nleft -= nwritten;
buf += nwritten;
}
return count;
}
static
int
copyfile_rw(const int fdin,
const int fdout,
const size_t count,
const size_t blocksize)
{
ssize_t nr;
ssize_t nw;
ssize_t bufsize;
size_t totalwritten;
vector<char> buf;
bufsize = (blocksize * 16);
buf.resize(bufsize);
fs::lseek(fdin,0,SEEK_SET);
totalwritten = 0;
while(totalwritten < count)
{
nr = fs::read(fdin,&buf[0],bufsize);
if(nr == -1)
{
if(errno == EINTR)
continue;
return -1;
}
nw = writen(fdout,&buf[0],nr);
if(nw == -1)
return -1;
totalwritten += nw;
}
return count;
}
static
int
copydata(const int fdin,
const int fdout,
const size_t count,
const size_t blocksize)
{
int rv;
fs::fadvise(fdin,0,count,POSIX_FADV_WILLNEED);
fs::fadvise(fdin,0,count,POSIX_FADV_SEQUENTIAL);
fs::fallocate(fdout,0,0,count);
rv = fs::sendfile(fdin,fdout,count);
if((rv == -1) && ((errno == EINVAL) || (errno == ENOSYS)))
return ::copyfile_rw(fdin,fdout,count,blocksize);
return rv;
}
static
bool
ignorable_error(const int err)
{
switch(err)
{
case ENOTTY:
case ENOTSUP:
#if ENOTSUP != EOPNOTSUPP
case EOPNOTSUPP:
#endif
return true;
}
return false;
}
namespace fs
{
int
clonefile(const int fdin,
const int fdout)
{
int rv;
struct stat stin;
rv = fs::fstat(fdin,stin);
if(rv == -1)
return -1;
rv = ::copydata(fdin,fdout,stin.st_size,stin.st_blksize);
if(rv == -1)
return -1;
rv = fs::attr::copy(fdin,fdout);
if((rv == -1) && !ignorable_error(errno))
return -1;
rv = fs::xattr::copy(fdin,fdout);
if((rv == -1) && !ignorable_error(errno))
return -1;
rv = fs::fchown(fdout,stin);
if(rv == -1)
return -1;
rv = fs::fchmod(fdout,stin);
if(rv == -1)
return -1;
rv = fs::utime(fdout,stin);
if(rv == -1)
return -1;
return 0;
}
int
clonefile(const string &in,
const string &out)
{
int rv;
int fdin;
int fdout;
int error;
fdin = fs::open(in,O_RDONLY|O_NOFOLLOW);
if(fdin == -1)
return -1;
const int flags = O_CREAT|O_LARGEFILE|O_NOATIME|O_NOFOLLOW|O_TRUNC|O_WRONLY;
const mode_t mode = S_IWUSR;
fdout = fs::open(out,flags,mode);
if(fdout == -1)
return -1;
rv = fs::clonefile(fdin,fdout);
error = errno;
fs::close(fdin);
fs::close(fdout);
errno = error;
return rv;
}
}
+25
View File
@@ -0,0 +1,25 @@
/*
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>
namespace fs
{
int clonefile(const int fdin,
const int fdout);
int clonefile(const std::string &from,
const std::string &to);
}
+108
View File
@@ -0,0 +1,108 @@
/*
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 "errno.h"
#include "fs_attr.hpp"
#include "fs_base_chmod.hpp"
#include "fs_base_chown.hpp"
#include "fs_base_mkdir.hpp"
#include "fs_base_stat.hpp"
#include "fs_base_utime.hpp"
#include "fs_path.hpp"
#include "fs_xattr.hpp"
using std::string;
static
bool
ignorable_error(const int err)
{
switch(err)
{
case ENOTTY:
case ENOTSUP:
#if ENOTSUP != EOPNOTSUPP
case EOPNOTSUPP:
#endif
return true;
}
return false;
}
namespace fs
{
int
clonepath(const string &fromsrc,
const string &tosrc,
const char *relative)
{
int rv;
struct stat st;
string topath;
string frompath;
string dirname;
dirname = relative;
fs::path::dirname(dirname);
if(!dirname.empty())
{
rv = fs::clonepath(fromsrc,tosrc,dirname.c_str());
if(rv == -1)
return -1;
}
fs::path::make(&fromsrc,relative,frompath);
rv = fs::stat(frompath,st);
if(rv == -1)
return -1;
else if(!S_ISDIR(st.st_mode))
return (errno=ENOTDIR,-1);
fs::path::make(&tosrc,relative,topath);
rv = fs::mkdir(topath,st.st_mode);
if(rv == -1)
{
if(errno != EEXIST)
return -1;
rv = fs::chmod(topath,st.st_mode);
if(rv == -1)
return -1;
}
// It may not support it... it's fine...
rv = fs::attr::copy(frompath,topath);
if((rv == -1) && !ignorable_error(errno))
return -1;
rv = fs::xattr::copy(frompath,topath);
if((rv == -1) && !ignorable_error(errno))
return -1;
rv = fs::chown(topath,st);
if(rv == -1)
return -1;
rv = fs::utime(topath,st);
if(rv == -1)
return -1;
return 0;
}
}
+24
View File
@@ -0,0 +1,24 @@
/*
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>
namespace fs
{
int clonepath(const std::string &from,
const std::string &to,
const char *relative);
}
+23
View File
@@ -0,0 +1,23 @@
/*
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 <fcntl.h>
#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
# include "fs_fadvise_posix.icpp"
#else
# include "fs_fadvise_unsupported.icpp"
#endif
+53
View File
@@ -0,0 +1,53 @@
/*
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.
*/
#ifndef __FS_FADVISE_HPP__
#define __FS_FADVISE_HPP__
#ifndef POSIX_FADV_NORMAL
# define POSIX_FADV_NORMAL 0
#endif
#ifndef POSIX_FADV_RANDOM
# define POSIX_FADV_RANDOM 1
#endif
#ifndef POSIX_FADV_SEQUENTIAL
# define POSIX_FADV_SEQUENTIAL 2
#endif
#ifndef POSIX_FADV_WILLNEED
# define POSIX_FADV_WILLNEED 3
#endif
#ifndef POSIX_FADV_DONTNEED
# define POSIX_FADV_DONTNEED 4
#endif
#ifndef POSIX_FADV_NOREUSE
# define POSIX_FADV_NOREUSE 5
#endif
namespace fs
{
int
fadvise(const int fd,
const off_t offset,
const off_t len,
const int advice);
}
#endif // __FS_FADVISE_HPP__
+29
View File
@@ -0,0 +1,29 @@
/*
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 "errno.hpp"
namespace fs
{
int
fadvise(const int fd,
const off_t offset,
const off_t len,
const int advice)
{
return ::posix_fadvise(fd,offset,len,advice);
}
}
+29
View File
@@ -0,0 +1,29 @@
/*
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 "errno.hpp"
namespace fs
{
int
fadvise(const int fd,
const off_t offset,
const off_t len,
const int advice)
{
return (errno=EOPNOTSUPP,-1);
}
}
+27
View File
@@ -0,0 +1,27 @@
/*
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 <fcntl.h>
#ifdef __linux__
# include "fs_fallocate_linux.icpp"
#elif _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
# include "fs_fallocate_posix.icpp"
#elif __APPLE__
# include "fs_fallocate_osx.icpp"
#else
# include "fs_fallocate_unsupported.icpp"
#endif
+31
View File
@@ -0,0 +1,31 @@
/*
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.
*/
#ifndef __FS_FALLOCATE_HPP__
#define __FS_FALLOCATE_HPP__
#include <fcntl.h>
namespace fs
{
int
fallocate(const int fd,
const int mode,
const off_t offset,
const off_t len);
}
#endif // __FS_FALLOCATE_HPP__
+32
View File
@@ -0,0 +1,32 @@
/*
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 <fcntl.h>
#include "errno.hpp"
#include "fs_fallocate.hpp"
namespace fs
{
int
fallocate(const int fd,
const int mode,
const off_t offset,
const off_t len)
{
return ::fallocate(fd,mode,offset,len);
}
}
+57
View File
@@ -0,0 +1,57 @@
/*
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 <fcntl.h>
#include "errno.hpp"
#include "fs_fallocate.hpp"
namespace fs
{
static
int
_fallocate_core(const int fd,
const off_t offset,
const off_t len)
{
int rv;
fstore_t store = {F_ALLOCATECONTIG,F_PEOFPOSMODE,offset,len,0};
rv = ::fcntl(fd,F_PREALLOCATE,&store);
if(rv == -1)
{
store.fst_flags = F_ALLOCATEALL;
rv = ::fcntl(fd,F_PREALLOCATE,&store);
}
if(rv == -1)
return rv;
return ::ftruncate(fd,(offset+len));
}
int
fallocate(const int fd,
const int mode,
const off_t offset,
const off_t len)
{
if(mode)
return (errno=EOPNOTSUPP,-1);
return ::_fallocate_core(fd,offset,len);
}
}
+34
View File
@@ -0,0 +1,34 @@
/*
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 <fcntl.h>
#include "errno.hpp"
#include "fs_fallocate.hpp"
namespace fs
{
int
fallocate(const int fd,
const int mode,
const off_t offset,
const off_t len)
{
return (mode ?
(errno=EOPNOTSUPP,-1) :
(::posix_fallocate(fd,offset,len)));
}
}
+30
View File
@@ -0,0 +1,30 @@
/*
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 "errno.hpp"
#include "fs_fallocate.hpp"
namespace fs
{
int
fallocate(const int fd,
const int mode,
const off_t offset,
const off_t len)
{
return (errno=EOPNOTSUPP,-1);
}
}
+114
View File
@@ -0,0 +1,114 @@
/*
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 <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <string>
#include <vector>
#include "fs.hpp"
#include "fs_base_open.hpp"
#include "fs_base_close.hpp"
#include "fs_base_unlink.hpp"
#include "fs_base_stat.hpp"
#include "fs_clonefile.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
using std::string;
using std::vector;
namespace fs
{
int
movefile(const vector<string> &basepaths,
const char *fusepath,
const size_t additional_size,
int &origfd)
{
int rv;
int fdin;
int fdout;
int fdin_flags;
string fusedir;
string fdin_path;
string fdout_path;
struct stat fdin_st;
fdin = origfd;
rv = fs::fstat(fdin,fdin_st);
if(rv == -1)
return -1;
fdin_flags = fs::getfl(fdin);
if(rv == -1)
return -1;
rv = fs::findonfs(basepaths,fusepath,fdin,fdin_path);
if(rv == -1)
return -1;
fdin_st.st_size += additional_size;
rv = fs::mfs(basepaths,fdin_st.st_size,fdout_path);
if(rv == -1)
return -1;
fusedir = fusepath;
fs::path::dirname(fusedir);
rv = fs::clonepath(fdin_path,fdout_path,fusedir.c_str());
if(rv == -1)
return -1;
fs::path::append(fdin_path,fusepath);
fdin = fs::open(fdin_path,O_RDONLY);
if(fdin == -1)
return -1;
fs::path::append(fdout_path,fusepath);
fdout = fs::open(fdout_path,fdin_flags|O_CREAT,fdin_st.st_mode);
if(fdout == -1)
return -1;
rv = fs::clonefile(fdin,fdout);
if(rv == -1)
{
fs::close(fdin);
fs::close(fdout);
fs::unlink(fdout_path.c_str());
return -1;
}
rv = fs::unlink(fdin_path);
if(rv == -1)
{
fs::close(fdin);
fs::close(fdout);
fs::unlink(fdout_path);
return -1;
}
fs::close(fdin);
fs::close(origfd);
origfd = fdout;
return 0;
}
}
+32
View File
@@ -0,0 +1,32 @@
/*
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.
*/
#ifndef __FS_MOVEFILE_HPP__
#define __FS_MOVEFILE_HPP__
#include <string>
#include <vector>
namespace fs
{
int
movefile(const vector<string> &basepaths,
const char *fusepath,
const size_t additional_size,
int &origfd);
}
#endif
+58
View File
@@ -0,0 +1,58 @@
/*
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 <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <string>
#include "fs_path.hpp"
using std::string;
namespace fs
{
namespace path
{
void
dirname(string &path)
{
string::reverse_iterator i;
string::reverse_iterator bi;
bi = path.rend();
i = path.rbegin();
while(*i == '/' && i != bi)
i++;
while(*i != '/' && i != bi)
i++;
while(*i == '/' && i != bi)
i++;
path.erase(i.base(),path.end());
}
string
basename(const string &path)
{
return path.substr(path.find_last_of('/')+1);
}
}
}
+53
View File
@@ -0,0 +1,53 @@
/*
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.
*/
#ifndef __FS_PATH_HPP__
#define __FS_PATH_HPP__
#include <string>
#include <vector>
namespace fs
{
namespace path
{
using std::string;
void dirname(string &path);
string basename(const string &path);
inline
void
append(string &base,
const char *suffix)
{
base += suffix;
}
inline
void
make(const string *base,
const char *suffix,
string &output)
{
output = *base;
output += suffix;
}
}
};
#endif // __FS_PATH_HPP__
+21
View File
@@ -0,0 +1,21 @@
/*
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.
*/
#ifdef __linux__
# include "fs_sendfile_linux.icpp"
#else
# include "fs_sendfile_unsupported.icpp"
#endif
+28
View File
@@ -0,0 +1,28 @@
/*
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.
*/
#ifndef __FS_SENDFILE_HPP__
#define __FS_SENDFILE_HPP__
namespace fs
{
ssize_t
sendfile(const int fdin,
const int fdout,
const size_t count);
}
#endif // __FS_SENDFILE_HPP__
+32
View File
@@ -0,0 +1,32 @@
/*
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 <sys/sendfile.h>
#include "errno.hpp"
namespace fs
{
ssize_t
sendfile(const int fdin,
const int fdout,
const size_t count)
{
off_t offset = 0;
return ::sendfile(fdout,fdin,&offset,count);
}
}

Some files were not shown because too many files have changed in this diff Show More