Browse Source

Add podman release build tooling + misc build fixes (#1455)

pull/1456/head
trapexit 2 days ago
committed by GitHub
parent
commit
fa3266ca7f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 48
      Makefile
  2. 49
      buildtools/build-mergerfs
  3. 101
      buildtools/build-release
  4. 9
      buildtools/containerfiles/debian.10.amd64
  5. 9
      buildtools/containerfiles/debian.10.arm64
  6. 9
      buildtools/containerfiles/debian.10.armhf
  7. 9
      buildtools/containerfiles/debian.10.i386
  8. 9
      buildtools/containerfiles/debian.11.amd64
  9. 9
      buildtools/containerfiles/debian.11.arm64
  10. 9
      buildtools/containerfiles/debian.11.armhf
  11. 9
      buildtools/containerfiles/debian.11.i386
  12. 9
      buildtools/containerfiles/debian.12.amd64
  13. 9
      buildtools/containerfiles/debian.12.arm64
  14. 9
      buildtools/containerfiles/debian.12.armhf
  15. 9
      buildtools/containerfiles/debian.12.i386
  16. 9
      buildtools/containerfiles/debian.9.amd64
  17. 9
      buildtools/containerfiles/debian.9.arm64
  18. 9
      buildtools/containerfiles/debian.9.armhf
  19. 9
      buildtools/containerfiles/debian.9.i386
  20. 9
      buildtools/containerfiles/fedora.37.amd64
  21. 9
      buildtools/containerfiles/fedora.37.arm64
  22. 9
      buildtools/containerfiles/fedora.37.armhf
  23. 9
      buildtools/containerfiles/fedora.37.i386
  24. 9
      buildtools/containerfiles/fedora.38.amd64
  25. 9
      buildtools/containerfiles/fedora.38.arm64
  26. 9
      buildtools/containerfiles/fedora.38.armhf
  27. 9
      buildtools/containerfiles/fedora.38.i386
  28. 9
      buildtools/containerfiles/fedora.39.amd64
  29. 9
      buildtools/containerfiles/fedora.40.amd64
  30. 9
      buildtools/containerfiles/fedora.41.amd64
  31. 9
      buildtools/containerfiles/fedora.42.amd64
  32. 9
      buildtools/containerfiles/rockylinux.8.amd64
  33. 9
      buildtools/containerfiles/rockylinux.8.arm64
  34. 9
      buildtools/containerfiles/rockylinux.8.armhf
  35. 9
      buildtools/containerfiles/rockylinux.8.i386
  36. 9
      buildtools/containerfiles/rockylinux.9.amd64
  37. 9
      buildtools/containerfiles/rockylinux.9.arm64
  38. 9
      buildtools/containerfiles/rockylinux.9.armhf
  39. 9
      buildtools/containerfiles/rockylinux.9.i386
  40. 13
      buildtools/containerfiles/static.amd64
  41. 13
      buildtools/containerfiles/static.arm64
  42. 13
      buildtools/containerfiles/static.armhf
  43. 13
      buildtools/containerfiles/static.i386
  44. 10
      buildtools/containerfiles/static.installer
  45. 13
      buildtools/containerfiles/tarball
  46. 9
      buildtools/containerfiles/ubuntu.18.04.amd64
  47. 9
      buildtools/containerfiles/ubuntu.18.04.arm64
  48. 9
      buildtools/containerfiles/ubuntu.18.04.armhf
  49. 9
      buildtools/containerfiles/ubuntu.18.04.i386
  50. 9
      buildtools/containerfiles/ubuntu.20.04.amd64
  51. 9
      buildtools/containerfiles/ubuntu.20.04.arm64
  52. 9
      buildtools/containerfiles/ubuntu.20.04.armhf
  53. 9
      buildtools/containerfiles/ubuntu.20.04.i386
  54. 9
      buildtools/containerfiles/ubuntu.22.04.amd64
  55. 9
      buildtools/containerfiles/ubuntu.22.04.arm64
  56. 9
      buildtools/containerfiles/ubuntu.22.04.armhf
  57. 9
      buildtools/containerfiles/ubuntu.22.04.i386
  58. 9
      buildtools/containerfiles/ubuntu.24.04.amd64
  59. 9
      buildtools/containerfiles/ubuntu.24.04.arm64
  60. 9
      buildtools/containerfiles/ubuntu.24.04.armhf
  61. 9
      buildtools/containerfiles/ubuntu.24.04.i386
  62. 2
      buildtools/git2debcl
  63. 31
      buildtools/install-build-pkgs
  64. 9
      libfuse/Makefile
  65. 30
      libfuse/lib/fuse.cpp
  66. 6
      libfuse/lib/helper.c
  67. 1
      libfuse/util/fusermount.c
  68. 3384
      man/mergerfs.1
  69. 4
      src/enum.hpp
  70. 4
      src/fs_attr.cpp
  71. 4
      src/fs_copy_file_range.cpp
  72. 4
      src/fs_fadvise.cpp
  73. 4
      src/fs_ficlone.cpp
  74. 6
      src/fs_futimens.hpp
  75. 4
      src/fs_futimesat.cpp
  76. 4
      src/fs_sendfile.cpp
  77. 6
      src/fs_statx.hpp
  78. 6
      src/fs_utimensat.hpp
  79. 191
      src/fuse_statx.cpp
  80. 186
      src/fuse_statx_supported.icpp
  81. 21
      src/fuse_statx_unsupported.icpp
  82. 8
      src/mergerfs.cpp
  83. 18
      src/num.cpp
  84. 17
      src/policy_eprand.cpp
  85. 18
      src/policy_rand.cpp
  86. 18
      src/procfs_get_name.cpp
  87. 19
      src/rnd.hpp
  88. 14
      src/to_string.cpp
  89. 8
      src/tofrom_wrapper.hpp
  90. 4
      src/ugid.hpp

48
Makefile

@ -23,9 +23,7 @@ FIND = find
INSTALL = install
MKTEMP = mktemp
STRIP = strip
PANDOC = pandoc
SED = sed
RPMBUILD = rpmbuild
GIT2DEBCL = ./buildtools/git2debcl
PKGCONFIG = pkg-config
@ -39,10 +37,10 @@ endif
USE_XATTR = 1
UGID_USE_RWLOCK = 0
ifeq ($(DEBUG),1)
OPT_FLAGS := -O0 -g -fsanitize=undefined
else
ifeq ($(NDEBUG),1)
OPT_FLAGS := -O2 -DNDEBUG
else
OPT_FLAGS := -O0 -DDEBUG -g -fsanitize=undefined
endif
ifeq ($(STATIC),1)
@ -187,7 +185,7 @@ install-mount-tools: install-base
$(MKDIR) -p "$(INSTALLBINDIR)"
$(MAKE) -C libfuse install
install-man: $(MANPAGE)
install-man: man/$(MANPAGE)
$(MKDIR) -p "$(INSTALLMAN1DIR)"
$(INSTALL) -v -m 0644 "man/$(MANPAGE)" "$(INSTALLMAN1DIR)/$(MANPAGE)"
@ -210,17 +208,8 @@ uninstall-mount.mergerfs:
uninstall-man:
$(RM) -f "$(INSTALLMAN1DIR)/$(MANPAGE)"
$(MANPAGE): README.md
ifneq ($(shell $(PANDOC) --version 2> /dev/null),)
$(PANDOC) -s -t man -o "man/$(MANPAGE)" README.md
else
$(warning "pandoc does not appear available: unable to build manpage")
endif
man: $(MANPAGE)
.PHONY: tarball
tarball: man changelog version
tarball: changelog version
$(eval VERSION := $(shell cat VERSION))
$(eval VERSION := $(subst -,_,$(VERSION)))
$(eval FILENAME := mergerfs-$(VERSION))
@ -260,7 +249,7 @@ rpm: tarball
$(SED) 's/__VERSION__/$(VERSION)/g' mergerfs.spec > \
rpmbuild/SOURCES/mergerfs.spec
cp -ar mergerfs-$(VERSION).tar.gz rpmbuild/SOURCES
$(RPMBUILD) -ba rpmbuild/SOURCES/mergerfs.spec \
rpmbuild -ba rpmbuild/SOURCES/mergerfs.spec \
--define "_topdir $(CURDIR)/rpmbuild"
.PHONY: install-build-pkgs
@ -269,6 +258,29 @@ install-build-pkgs:
.PHONY: libfuse
libfuse:
$(MAKE) DEBUG=$(DEBUG) -C libfuse
$(MAKE) NDEBUG=$(NDEBUG) -C libfuse
.PHONY: release release-amd64
release:
./buildtools/build-release \
--target=all \
--cleanup \
--branch=$(shell git branch --show-current)
release-amd64:
./buildtools/build-release \
--target=amd64 \
--cleanup \
--branch=$(shell git branch --show-current)
release-arm64:
./buildtools/build-release \
--target=arm64 \
--cleanup \
--branch=$(shell git branch --show-current)
release-static:
./buildtools/build-release \
--target=static \
--cleanup \
--branch=$(shell git branch --show-current)
-include $(DEPS)

49
buildtools/build-mergerfs

@ -0,0 +1,49 @@
#!/bin/sh
BRANCH="${1:-master}"
SRCDIR="/tmp/mergerfs"
git clone https://github.com/trapexit/mergerfs "${SRCDIR}" -b "${BRANCH}"
cd "${SRCDIR}"
git log HEAD^1..
mkdir /build
if [ -e /usr/bin/apt-get ]; then
make deb
if [ $? -ne 0 ]; then
. /etc/lsb-release
cp -v /etc/lsb-release "/build/${DISTRIB_ID}.${DISTRIB_CODENAME}.${DISTRIB_RELEASE}.$(arch).FAILED"
fi
find /tmp/ \
-type f \
-name "*.deb" \
-not -name "*dbgsym*" \
-exec cp -v {} /build/ \;
elif [ -e /usr/bin/dnf ]; then
make rpm
if [ $? -ne 0 ]; then
. /etc/lsb-release
cp -v /etc/lsb-release "/build/${DISTRIB_ID}.${DISTRIB_CODENAME}.${DISTRIB_RELEASE}.$(arch).FAILED"
fi
find /tmp/ \
-type f \
-name "*.rpm" \
-not -name "*sym*" \
-not -name "*src.rpm" \
-exec cp -v {} /build/ \;
elif [ -e /usr/bin/yum ]; then
. /opt/rh/devtoolset-9/enable
make rpm
find /tmp/ \
-type f \
-name "*.rpm" \
-not -name "*sym*" \
-not -name "*src.rpm" \
-exec cp -v {} /build/ \;
elif [ -e /sbin/apk ]; then
echo "NOT YET SUPPORTED"
elif [ -e /usr/sbin/pkg ]; then
echo "NOT YET SUPPORTED"
fi

101
buildtools/build-release

@ -0,0 +1,101 @@
#!/usr/bin/env python3
import subprocess
import sys
import os
import argparse
import time
def build(containerfile,
pkgdirpath,
branch):
timestamp = time.time_ns()
args = ['podman',
'build',
'--pull=always',
'--force-rm',
'-o',pkgdirpath,
'-f',containerfile,
f'--build-arg=BRANCH={branch}',
f'--build-arg=BUILD_TIMESTAMP={timestamp}',
'buildtools/']
print(args)
subprocess.run(args)
def setup():
args = ['sudo',
'apt-get',
'install',
'-fy',
'qemu-user-static',
'qemu-user-binfmt']
print(args)
subprocess.run(args)
def podman_cleanup():
args = ['podman',
'system',
'prune',
'-af']
print(args)
subprocess.run(args)
def parse_args():
p = argparse.ArgumentParser()
p.add_argument('--target',
default='debian.12.amd64')
p.add_argument('--pkgdirpath',
default='build/pkgs/')
p.add_argument('--branch',
default='master')
p.add_argument('--setup',
required=False,
action='store_true')
p.add_argument('--cleanup',
required=False,
action='store_true')
return p.parse_args()
def main():
args = parse_args()
print(args)
if args.setup:
setup()
sys.exit(0)
containerfiles = []
basepath = 'buildtools/containerfiles'
if os.path.exists(f'{basepath}/{args.target}'):
containerfiles.append(f'{basepath}/{args.target}')
elif args.target == 'all':
for root,dirnames,filenames in os.walk(basepath):
for filename in filenames:
containerfile = f'buildtools/containerfiles/{filename}'
containerfiles.append(containerfile)
else:
for root,dirnames,filenames in os.walk(basepath):
for filename in filenames:
if args.target not in filename:
continue
containerfile = f'buildtools/containerfiles/{filename}'
containerfiles.append(containerfile)
for containerfile in containerfiles:
if args.cleanup:
podman_cleanup()
build(containerfile,
args.pkgdirpath,
args.branch)
sys.exit(0)
if __name__ == '__main__':
main()

9
buildtools/containerfiles/debian.10.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 debian:10 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.10.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 debian:10 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.10.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf debian:10 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.10.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 debian:10 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.11.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 debian:11 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.11.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 debian:11 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.11.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf debian:11 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.11.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 debian:11 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.12.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 debian:12 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.12.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 debian:12 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.12.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf debian:12 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.12.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 debian:12 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.9.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 debian:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.9.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 debian:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.9.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf debian:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/debian.9.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 debian:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.37.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 fedora:37 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.37.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 fedora:37 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.37.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf fedora:37 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.37.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 fedora:37 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.38.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 fedora:38 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.38.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 fedora:38 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.38.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf fedora:38 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.38.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 fedora:38 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.39.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 fedora:39 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.40.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 fedora:40 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.41.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 fedora:41 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/fedora.42.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 fedora:42 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.8.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 rockylinux:8 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.8.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 rockylinux:8 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.8.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf rockylinux:8 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.8.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 rockylinux:8 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.9.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 rockylinux:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.9.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 rockylinux:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.9.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf rockylinux:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/rockylinux.9.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 rockylinux:9 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

13
buildtools/containerfiles/static.amd64

@ -0,0 +1,13 @@
ARG BUILD_TIMESTAMP=0
FROM --platform=linux/amd64 alpine:latest as build
COPY install-build-pkgs /tmp/
RUN /tmp/install-build-pkgs
ARG BRANCH=master
RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}"
WORKDIR /tmp/mergerfs
RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install
RUN mkdir /build
RUN tar cvfz /build/mergerfs-static-linux_amd64.tar.gz --directory=/tmp usr sbin
FROM scratch
COPY --from=build /build/ /

13
buildtools/containerfiles/static.arm64

@ -0,0 +1,13 @@
ARG BUILD_TIMESTAMP=0
FROM --platform=linux/arm64 alpine:latest as build
COPY install-build-pkgs /tmp/
RUN /tmp/install-build-pkgs
ARG BRANCH=master
RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}"
WORKDIR /tmp/mergerfs
RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install
RUN mkdir /build
RUN tar cvfz /build/mergerfs-static-linux_arm64.tar.gz --directory=/tmp usr sbin
FROM scratch
COPY --from=build /build/ /

13
buildtools/containerfiles/static.armhf

@ -0,0 +1,13 @@
ARG BUILD_TIMESTAMP=0
FROM --platform=linux/armhf alpine:latest as build
COPY install-build-pkgs /tmp/
RUN /tmp/install-build-pkgs
ARG BRANCH=master
RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}"
WORKDIR /tmp/mergerfs
RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install
RUN mkdir /build
RUN tar cvfz /build/mergerfs-static-linux_armhf.tar.gz --directory=/tmp usr sbin
FROM scratch
COPY --from=build /build/ /

13
buildtools/containerfiles/static.i386

@ -0,0 +1,13 @@
ARG BUILD_TIMESTAMP=0
FROM --platform=linux/i386 alpine:latest as build
COPY install-build-pkgs /tmp/
RUN /tmp/install-build-pkgs
ARG BRANCH=master
RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}"
WORKDIR /tmp/mergerfs
RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install
RUN mkdir /build
RUN tar cvfz /build/mergerfs-static-linux_i386.tar.gz --directory=/tmp usr sbin
FROM scratch
COPY --from=build /build/ /

10
buildtools/containerfiles/static.installer

@ -0,0 +1,10 @@
ARG BUILD_TIMESTAMP=0
FROM --platform=linux/amd64 ubuntu:latest as build
RUN apt-get update && apt-get install -y makeself
RUN mkdir -p /tmp/mergerfs/
RUN --mount=type=bind,src=pkgs,dst=/pkgs ls -lhd /pkgs
RUN --mount=type=bind,src=pkgs,dst=/pkgs cp -v /pkg/*static*.gz /tmp/mergerfs/
RUN makeself /tmp/mergerfs/ /build/mergerfs-installer.run "mergerfs" echo "foo"
FROM scratch
COPY --from=build /build/ /

13
buildtools/containerfiles/tarball

@ -0,0 +1,13 @@
FROM debian:buster as tarball
COPY install-build-pkgs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}"
RUN cd /tmp/mergerfs && make version tarball
RUN mkdir /build
RUN cp -v /tmp/mergerfs/*.tar.gz /build/
FROM scratch
COPY --from=tarball /build/ /

9
buildtools/containerfiles/ubuntu.18.04.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 ubuntu:18.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.18.04.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 ubuntu:18.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.18.04.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf ubuntu:18.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.18.04.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 ubuntu:18.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.20.04.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 ubuntu:20.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.20.04.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 ubuntu:20.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.20.04.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf ubuntu:20.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.20.04.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 ubuntu:20.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.22.04.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 ubuntu:22.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.22.04.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 ubuntu:22.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.22.04.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf ubuntu:22.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.22.04.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 ubuntu:22.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.24.04.amd64

@ -0,0 +1,9 @@
FROM --platform=linux/amd64 ubuntu:24.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.24.04.arm64

@ -0,0 +1,9 @@
FROM --platform=linux/arm64 ubuntu:24.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.24.04.armhf

@ -0,0 +1,9 @@
FROM --platform=linux/armhf ubuntu:24.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

9
buildtools/containerfiles/ubuntu.24.04.i386

@ -0,0 +1,9 @@
FROM --platform=linux/i386 ubuntu:24.04 as build
COPY install-build-pkgs build-mergerfs /tmp/
RUN /tmp/install-build-pkgs
ARG BUILD_TIMESTAMP=0
ARG BRANCH=master
RUN /tmp/build-mergerfs $BRANCH
FROM scratch
COPY --from=build /build/ /

2
buildtools/git2debcl

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>

31
buildtools/install-build-pkgs

@ -7,34 +7,37 @@ if [ -e /usr/bin/apt-get ]; then
install \
ca-certificates \
build-essential \
dpkg \
git \
g++ \
debhelper \
automake \
fakeroot \
libtool \
lsb-release
apt-get -qy --no-install-suggests --no-install-recommends install python
apt-get -qy --no-install-suggests --no-install-recommends install python3
lsb-release \
fakeroot
apt-get -qy --force-yes --no-install-suggests --no-install-recommends install python
apt-get -qy --force-yes --no-install-suggests --no-install-recommends install python3
elif [ -e /usr/bin/dnf ]; then
dnf -y update
dnf -y install \
git rpm-build gcc-c++ make which python3 automake \
libtool gettext-devel
git rpm-build gcc-c++ make which python3
elif [ -e /usr/bin/yum ]; then
yum -y update
yum -y install \
git rpm-build gcc-c++ make which \
python python-argparse \
automake libtool gettext-devel
python python-argparse
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc\*
elif [ -e /usr/bin/zypper ]; then
zypper update -y
zypper install -y \
git rpm-build gcc-c++ make which \
python
elif [ -e /sbin/apk ]; then
apk add \
abuild git gcc g++ make autoconf \
automake libtool gettext-dev linux-headers
abuild git gcc g++ make \
linux-headers
elif [ -e /usr/sbin/pkg ]; then
pkg install \
git gmake gcc autoconf automake libtool \
gettext-tools
git gmake gcc
fi
if [ ! -e /usr/bin/python ]; then

9
libfuse/Makefile

@ -9,10 +9,10 @@ UTILS :=
INSTALLUTILS :=
endif
ifeq ($(DEBUG),1)
OPT_FLAGS := -O0 -g -fsanitize=undefined
ifeq ($(NDEBUG),1)
OPT_FLAGS := -O2 -DNDEBUG
else
OPT_FLAGS := -O2
OPT_FLAGS := -O0 -DDEBUG -g -fsanitize=undefined
endif
ifeq ($(LTO),1)
@ -41,7 +41,6 @@ SRC_C = \
lib/buffer.c \
lib/crc32b.c \
lib/debug.c \
lib/fuse.c \
lib/fuse_dirents.c \
lib/fuse_lowlevel.c \
lib/node.c \
@ -52,6 +51,7 @@ SRC_C = \
lib/helper.c \
lib/mount.c
SRC_CPP = \
lib/fuse.cpp \
lib/cpu.cpp \
lib/fuse_config.cpp \
lib/fuse_loop.cpp \
@ -87,7 +87,6 @@ FUSE_FLAGS = \
-Ibuild \
-D_REENTRANT \
-D_FILE_OFFSET_BITS=64 \
-DPACKAGE_VERSION=\"$(VERSION)\" \
-DFUSERMOUNT_DIR=\"$(FUSERMOUNT_DIR)\"
LDFLAGS := \
${LDFLAGS} \

30
libfuse/lib/fuse.cpp

@ -1617,6 +1617,14 @@ fuse_lib_lookup(fuse_req_t req,
reply_entry(req,&e,err);
}
static
void
fuse_lib_lseek(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
fuse_reply_err(req_,ENOSYS);
}
static
void
fuse_lib_forget(fuse_req_t req,
@ -2179,6 +2187,24 @@ fuse_lib_rename(fuse_req_t req,
fuse_reply_err(req,err);
}
static
void
fuse_lib_rename2(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
fuse_reply_err(req_,ENOSYS);
}
static
void
fuse_lib_retrieve_reply(fuse_req_t req_,
void *cookie_,
uint64_t ino_,
off_t offset_)
{
}
static
void
fuse_lib_link(fuse_req_t req,
@ -3694,6 +3720,7 @@ static struct fuse_lowlevel_ops fuse_path_ops =
.link = fuse_lib_link,
.listxattr = fuse_lib_listxattr,
.lookup = fuse_lib_lookup,
.lseek = fuse_lib_lseek,
.mkdir = fuse_lib_mkdir,
.mknod = fuse_lib_mknod,
.open = fuse_lib_open,
@ -3708,7 +3735,8 @@ static struct fuse_lowlevel_ops fuse_path_ops =
.removemapping = fuse_lib_removemapping,
.removexattr = fuse_lib_removexattr,
.rename = fuse_lib_rename,
.retrieve_reply = NULL,
.rename2 = fuse_lib_rename2,
.retrieve_reply = fuse_lib_retrieve_reply,
.rmdir = fuse_lib_rmdir,
.setattr = fuse_lib_setattr,
.setlk = fuse_lib_setlk,

6
libfuse/lib/helper.c

@ -77,11 +77,6 @@ static void helper_help(void)
);
}
static void helper_version(void)
{
fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
}
static int fuse_helper_opt_proc(void *data, const char *arg, int key,
struct fuse_args *outargs)
{
@ -97,7 +92,6 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key,
return fuse_opt_add_arg(outargs, "-h");
case KEY_VERSION:
helper_version();
return 1;
case FUSE_OPT_KEY_NONOPT:

1
libfuse/util/fusermount.c

@ -1165,7 +1165,6 @@ static void usage(void)
static void show_version(void)
{
printf("fusermount version: %s\n", PACKAGE_VERSION);
exit(0);
}

3384
man/mergerfs.1
File diff suppressed because it is too large
View File

4
src/enum.hpp

@ -30,11 +30,11 @@ public:
typedef E ENUM;
public:
Enum<ENUM>()
Enum()
{
}
Enum<ENUM>(const ENUM data_)
Enum(const ENUM data_)
: _data(data_)
{
}

4
src/fs_attr.cpp

@ -15,9 +15,9 @@
*/
#ifdef __linux__
#warning "using fs_attr_linux.icpp"
#pragma message "using fs_attr_linux.icpp"
#include "fs_attr_linux.icpp"
#else
#warning "using fs_attr_unsupported.icpp"
#pragma message "using fs_attr_unsupported.icpp"
#include "fs_attr_unsupported.icpp"
#endif

4
src/fs_copy_file_range.cpp

@ -17,9 +17,9 @@
*/
#ifdef __linux__
#warning "using fs_copy_file_range_linux.icpp"
#pragma message "using fs_copy_file_range_linux.icpp"
#include "fs_copy_file_range_linux.icpp"
#else
#warning "using fs_copy_file_range_unsupported.icpp"
#pragma message "using fs_copy_file_range_unsupported.icpp"
#include "fs_copy_file_range_unsupported.icpp"
#endif

4
src/fs_fadvise.cpp

@ -17,10 +17,10 @@
#include <fcntl.h>
#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
#warning "using fs_fadvise_posix.icpp"
#pragma message "using fs_fadvise_posix.icpp"
#include "fs_fadvise_posix.icpp"
#else
#warning "using fs_fadvise_unsupported.icpp"
#pragma message "using fs_fadvise_unsupported.icpp"
#include "fs_fadvise_unsupported.icpp"
#endif

4
src/fs_ficlone.cpp

@ -17,9 +17,9 @@
*/
#ifdef __linux__
#warning "using fs_ficlone_linux.icpp"
#pragma message "using fs_ficlone_linux.icpp"
#include "fs_ficlone_linux.icpp"
#else
#warning "using fs_ficlone_unsupported.icpp"
#pragma message "using fs_ficlone_unsupported.icpp"
#include "fs_ficlone_unsupported.icpp"
#endif

6
src/fs_futimens.hpp

@ -23,13 +23,13 @@
#include <sys/stat.h>
#ifdef __linux__
#warning "using fs_futimens_linux.hpp"
#pragma message "using fs_futimens_linux.hpp"
#include "fs_futimens_linux.hpp"
#elif __FreeBSD__ >= 11
#warning "using fs_futimens_freebsd_11.hpp"
#pragma message "using fs_futimens_freebsd_11.hpp"
#include "fs_futimens_freebsd_11.hpp"
#else
#warning "using fs_futimens_generic.hpp"
#pragma message "using fs_futimens_generic.hpp"
#include "fs_futimens_generic.hpp"
#endif

4
src/fs_futimesat.cpp

@ -17,9 +17,9 @@
*/
#if __APPLE__
#warning "using fs_futimesat_osx.icpp"
#pragma message "using fs_futimesat_osx.icpp"
#include "fs_futimesat_osx.icpp"
#else
#warning "using fs_futimesat_generic.icpp"
#pragma message "using fs_futimesat_generic.icpp"
#include "fs_futimesat_generic.icpp"
#endif

4
src/fs_sendfile.cpp

@ -15,9 +15,9 @@
*/
#ifdef __linux__
#warning "using fs_sendfile_linux.icpp"
#pragma message "using fs_sendfile_linux.icpp"
#include "fs_sendfile_linux.icpp"
#else
#warning "using fs_sendfile_unsupported.icpp"
#pragma message "using fs_sendfile_unsupported.icpp"
#include "fs_sendfile_unsupported.icpp"
#endif

6
src/fs_statx.hpp

@ -11,6 +11,10 @@
#include <fcntl.h>
#include <sys/stat.h>
#ifdef STATX_TYPE
#define MERGERFS_STATX_SUPPORTED
#endif
namespace fs
{
static
@ -22,7 +26,7 @@ namespace fs
const unsigned int mask_,
struct fuse_statx *st_)
{
#ifdef STATX_TYPE
#ifdef MERGERFS_STATX_SUPPORTED
int rv;
rv = ::statx(dirfd_,

6
src/fs_utimensat.hpp

@ -19,12 +19,12 @@
#pragma once
#ifdef __linux__
#warning "using fs_utimensat_linux.hpp"
#pragma message "using fs_utimensat_linux.hpp"
#include "fs_utimensat_linux.hpp"
#elif __FreeBSD__
#warning "using fs_utimensat_freebsd.hpp"
#pragma message "using fs_utimensat_freebsd.hpp"
#include "fs_utimensat_freebsd.hpp"
#else
#warning "using fs_utimensat_generic.hpp"
#pragma message "using fs_utimensat_generic.hpp"
#include "fs_utimensat_generic.hpp"
#endif

191
src/fuse_statx.cpp

@ -1,186 +1,9 @@
#include "fuse_statx.hpp"
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_inode.hpp"
#include "fs_path.hpp"
#include "fs_statx.hpp"
#include "symlinkify.hpp"
#include "ugid.hpp"
#include "fmt/core.h"
#include "fuse.h"
#include <string>
static
void
_set_stat_if_leads_to_dir(const std::string &path_,
struct fuse_statx *st_)
{
int rv;
struct fuse_statx st;
rv = fs::statx(AT_FDCWD,path_,AT_SYMLINK_FOLLOW,STATX_TYPE,st_);
if(rv < 0)
return;
if(S_ISDIR(st.mode))
*st_ = st;
return;
}
static
void
_set_stat_if_leads_to_reg(const std::string &path_,
struct fuse_statx *st_)
{
int rv;
struct fuse_statx st;
rv = fs::statx(AT_FDCWD,path_,AT_SYMLINK_FOLLOW,STATX_TYPE,st_);
if(rv < 0)
return;
if(S_ISREG(st.mode))
*st_ = st;
return;
}
static
int
_statx_controlfile(struct fuse_statx *st_)
{
static const uid_t uid = ::getuid();
static const gid_t gid = ::getgid();
static const time_t now = ::time(NULL);
st_->ino = 0;
st_->mode = (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
st_->nlink = 1;
st_->uid = uid;
st_->gid = gid;
st_->size = 0;
st_->blocks = 0;
st_->atime.tv_sec = now;
st_->mtime.tv_sec = now;
st_->ctime.tv_sec = now;
return 0;
}
static
int
_statx(const Policy::Search &searchFunc_,
const Branches &branches_,
const char *fusepath_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
const bool symlinkify_,
const time_t symlinkify_timeout_,
FollowSymlinks followsymlinks_)
{
int rv;
std::string fullpath;
StrVec basepaths;
rv = searchFunc_(branches_,fusepath_,&basepaths);
if(rv == -1)
return -errno;
fullpath = fs::path::make(basepaths[0],fusepath_);
switch(followsymlinks_)
{
case FollowSymlinks::ENUM::NEVER:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
break;
case FollowSymlinks::ENUM::DIRECTORY:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
if((rv >= 0) && S_ISLNK(st_->mode))
::_set_stat_if_leads_to_dir(fullpath,st_);
break;
case FollowSymlinks::ENUM::REGULAR:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
if((rv >= 0) && S_ISLNK(st_->mode))
::_set_stat_if_leads_to_reg(fullpath,st_);
break;
case FollowSymlinks::ENUM::ALL:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_FOLLOW,mask_,st_);
if(rv < 0)
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
break;
}
if(rv < 0)
return rv;
if(symlinkify_ && symlinkify::can_be_symlink(*st_,symlinkify_timeout_))
symlinkify::convert(fullpath,st_);
fs::inode::calc(basepaths[0],fusepath_,st_);
return 0;
}
static
int
_statx(const char *fusepath_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
int rv;
Config::Read cfg;
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
rv = ::_statx(cfg->func.getattr.policy,
cfg->branches,
fusepath_,
flags_,
mask_,
st_,
cfg->symlinkify,
cfg->symlinkify_timeout,
cfg->follow_symlinks);
timeout_->entry = ((rv >= 0) ?
cfg->cache_entry :
cfg->cache_negative_entry);
timeout_->attr = cfg->cache_attr;
return rv;
}
int
FUSE::statx(const char *fusepath_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
if(fusepath_ == CONTROLFILE)
return ::_statx_controlfile(st_);
return ::_statx(fusepath_,flags_|AT_STATX_DONT_SYNC,mask_,st_,timeout_);
}
int
FUSE::statx_fh(const uint64_t fh_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
FileInfo *fi = reinterpret_cast<FileInfo*>(fh_);
return ::_statx(fi->fusepath.c_str(),flags_,mask_,st_,timeout_);
}
#ifdef MERGERFS_STATX_SUPPORTED
#pragma message "statx supported"
# include "fuse_statx_supported.icpp"
#else
#pragma message "statx NOT supported"
# include "fuse_statx_unsupported.icpp"
#endif

186
src/fuse_statx_supported.icpp

@ -0,0 +1,186 @@
#include "fuse_statx.hpp"
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_inode.hpp"
#include "fs_path.hpp"
#include "fs_statx.hpp"
#include "symlinkify.hpp"
#include "ugid.hpp"
#include "fmt/core.h"
#include "fuse.h"
#include <string>
static
void
_set_stat_if_leads_to_dir(const std::string &path_,
struct fuse_statx *st_)
{
int rv;
struct fuse_statx st;
rv = fs::statx(AT_FDCWD,path_,AT_SYMLINK_FOLLOW,STATX_TYPE,st_);
if(rv < 0)
return;
if(S_ISDIR(st.mode))
*st_ = st;
return;
}
static
void
_set_stat_if_leads_to_reg(const std::string &path_,
struct fuse_statx *st_)
{
int rv;
struct fuse_statx st;
rv = fs::statx(AT_FDCWD,path_,AT_SYMLINK_FOLLOW,STATX_TYPE,st_);
if(rv < 0)
return;
if(S_ISREG(st.mode))
*st_ = st;
return;
}
static
int
_statx_controlfile(struct fuse_statx *st_)
{
static const uid_t uid = ::getuid();
static const gid_t gid = ::getgid();
static const time_t now = ::time(NULL);
st_->ino = 0;
st_->mode = (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
st_->nlink = 1;
st_->uid = uid;
st_->gid = gid;
st_->size = 0;
st_->blocks = 0;
st_->atime.tv_sec = now;
st_->mtime.tv_sec = now;
st_->ctime.tv_sec = now;
return 0;
}
static
int
_statx(const Policy::Search &searchFunc_,
const Branches &branches_,
const char *fusepath_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
const bool symlinkify_,
const time_t symlinkify_timeout_,
FollowSymlinks followsymlinks_)
{
int rv;
std::string fullpath;
StrVec basepaths;
rv = searchFunc_(branches_,fusepath_,&basepaths);
if(rv == -1)
return -errno;
fullpath = fs::path::make(basepaths[0],fusepath_);
switch(followsymlinks_)
{
case FollowSymlinks::ENUM::NEVER:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
break;
case FollowSymlinks::ENUM::DIRECTORY:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
if((rv >= 0) && S_ISLNK(st_->mode))
::_set_stat_if_leads_to_dir(fullpath,st_);
break;
case FollowSymlinks::ENUM::REGULAR:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
if((rv >= 0) && S_ISLNK(st_->mode))
::_set_stat_if_leads_to_reg(fullpath,st_);
break;
case FollowSymlinks::ENUM::ALL:
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_FOLLOW,mask_,st_);
if(rv < 0)
rv = fs::statx(AT_FDCWD,fullpath,flags_|AT_SYMLINK_NOFOLLOW,mask_,st_);
break;
}
if(rv < 0)
return rv;
if(symlinkify_ && symlinkify::can_be_symlink(*st_,symlinkify_timeout_))
symlinkify::convert(fullpath,st_);
fs::inode::calc(basepaths[0],fusepath_,st_);
return 0;
}
static
int
_statx(const char *fusepath_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
int rv;
Config::Read cfg;
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
rv = ::_statx(cfg->func.getattr.policy,
cfg->branches,
fusepath_,
flags_,
mask_,
st_,
cfg->symlinkify,
cfg->symlinkify_timeout,
cfg->follow_symlinks);
timeout_->entry = ((rv >= 0) ?
cfg->cache_entry :
cfg->cache_negative_entry);
timeout_->attr = cfg->cache_attr;
return rv;
}
int
FUSE::statx(const char *fusepath_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
if(fusepath_ == CONTROLFILE)
return ::_statx_controlfile(st_);
return ::_statx(fusepath_,flags_|AT_STATX_DONT_SYNC,mask_,st_,timeout_);
}
int
FUSE::statx_fh(const uint64_t fh_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
FileInfo *fi = reinterpret_cast<FileInfo*>(fh_);
return ::_statx(fi->fusepath.c_str(),flags_,mask_,st_,timeout_);
}

21
src/fuse_statx_unsupported.icpp

@ -0,0 +1,21 @@
#include "fuse_statx.hpp"
int
FUSE::statx(const char *fusepath_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
return -ENOSYS;
}
int
FUSE::statx_fh(const uint64_t fh_,
const uint32_t flags_,
const uint32_t mask_,
struct fuse_statx *st_,
fuse_timeouts_t *timeout_)
{
return -ENOSYS;
}

8
src/mergerfs.cpp

@ -269,8 +269,8 @@ namespace l
if(uid == 0)
return;
char const *s = "mergerfs is not running as root and may not work correctly\n";
fprintf(stderr,"warning: %s",s);
const char s[] = "mergerfs is not running as root and may not work correctly\n";
fmt::print(stderr,"warning: {}",s);
SysLog::warning(s);
}
@ -287,8 +287,6 @@ namespace l
SysLog::open();
SysLog::info("mergerfs v{} started",MERGERFS_VERSION);
l::warn_if_not_root();
memset(&ops,0,sizeof(fuse_operations));
args.argc = argc_;
@ -311,6 +309,8 @@ namespace l
return 1;
}
l::warn_if_not_root();
l::setup_resources(cfg->scheduling_priority);
l::setup_signal_handlers();
l::get_fuse_operations(ops,cfg->nullrw);

18
src/num.cpp

@ -16,6 +16,8 @@
#include "ef.hpp"
#include "fmt/core.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
@ -114,21 +116,17 @@ namespace num
std::string
humanize(const uint64_t bytes_)
{
char buf[64];
if(bytes_ < KB)
sprintf(buf,"%" PRIu64 "",bytes_);
return fmt::format("{}",bytes_);
ef(((bytes_ / TB) * TB) == bytes_)
sprintf(buf,"%" PRIu64 "T",bytes_ / TB);
return fmt::format("{}T",bytes_ / TB);
ef(((bytes_ / GB) * GB) == bytes_)
sprintf(buf,"%" PRIu64 "G",bytes_ / GB);
return fmt::format("{}G",bytes_ / GB);
ef(((bytes_ / MB) * MB) == bytes_)
sprintf(buf,"%" PRIu64 "M",bytes_ / MB);
return fmt::format("{}M",bytes_ / MB);
ef(((bytes_ / KB) * KB) == bytes_)
sprintf(buf,"%" PRIu64 "K",bytes_ / KB);
else
sprintf(buf,"%" PRIu64 "",bytes_);
return fmt::format("{}K",bytes_ / KB);
return std::string(buf);
return fmt::format("{}",bytes_);
}
}

17
src/policy_eprand.cpp

@ -18,8 +18,8 @@
#include "policies.hpp"
#include "policy.hpp"
#include "policy_eprand.hpp"
#include "rnd.hpp"
#include <algorithm>
int
Policy::EPRand::Action::operator()(const Branches::CPtr &branches_,
@ -30,10 +30,7 @@ Policy::EPRand::Action::operator()(const Branches::CPtr &branches_,
rv = Policies::Action::epall(branches_,fusepath_,paths_);
if(rv == 0)
{
std::random_shuffle(paths_->begin(),paths_->end());
paths_->resize(1);
}
RND::shrink_to_rand_elem(*paths_);
return rv;
}
@ -47,10 +44,7 @@ Policy::EPRand::Create::operator()(const Branches::CPtr &branches_,
rv = Policies::Create::epall(branches_,fusepath_,paths_);
if(rv == 0)
{
std::random_shuffle(paths_->begin(),paths_->end());
paths_->resize(1);
}
RND::shrink_to_rand_elem(*paths_);
return rv;
}
@ -64,10 +58,7 @@ Policy::EPRand::Search::operator()(const Branches::CPtr &branches_,
rv = Policies::Search::epall(branches_,fusepath_,paths_);
if(rv == 0)
{
std::random_shuffle(paths_->begin(),paths_->end());
paths_->resize(1);
}
RND::shrink_to_rand_elem(*paths_);
return rv;
}

18
src/policy_rand.cpp

@ -18,8 +18,7 @@
#include "policy.hpp"
#include "policy_rand.hpp"
#include "policies.hpp"
#include <algorithm>
#include "rnd.hpp"
int
Policy::Rand::Action::operator()(const Branches::CPtr &branches_,
@ -30,10 +29,7 @@ Policy::Rand::Action::operator()(const Branches::CPtr &branches_,
rv = Policies::Action::all(branches_,fusepath_,paths_);
if(rv == 0)
{
std::random_shuffle(paths_->begin(),paths_->end());
paths_->resize(1);
}
RND::shrink_to_rand_elem(*paths_);
return rv;
}
@ -47,10 +43,7 @@ Policy::Rand::Create::operator()(const Branches::CPtr &branches_,
rv = Policies::Create::all(branches_,fusepath_,paths_);
if(rv == 0)
{
std::random_shuffle(paths_->begin(),paths_->end());
paths_->resize(1);
}
RND::shrink_to_rand_elem(*paths_);
return rv;
}
@ -64,10 +57,7 @@ Policy::Rand::Search::operator()(const Branches::CPtr &branches_,
rv = Policies::Search::all(branches_,fusepath_,paths_);
if(rv == 0)
{
std::random_shuffle(paths_->begin(),paths_->end());
paths_->resize(1);
}
RND::shrink_to_rand_elem(*paths_);
return rv;
}

18
src/procfs_get_name.cpp

@ -10,10 +10,14 @@
#include "fs_openat.hpp"
#include "fs_read.hpp"
#include "fmt/core.h"
#include <array>
#include <pthread.h>
static int g_PROCFS_DIR_FD = -1;
const char PROCFS_PATH[] = "/proc";
constexpr const char PROCFS_PATH[] = "/proc";
int
procfs::init()
@ -33,15 +37,17 @@ procfs::get_name(const int tid_)
{
int fd;
int rv;
char commpath[256];
std::array<char,256> commpath;
fmt::format_to_n_result<char*> frv;
snprintf(commpath,sizeof(commpath),"%d/comm",tid_);
frv = fmt::format_to_n(commpath.data(),commpath.size()-1,"{}/comm",tid_);
frv.out[0] = '\0';
fd = fs::openat(g_PROCFS_DIR_FD,commpath,O_RDONLY);
fd = fs::openat(g_PROCFS_DIR_FD,commpath.data(),O_RDONLY);
if(fd < 0)
return {};
rv = fs::read(fd,commpath,sizeof(commpath));
rv = fs::read(fd,commpath.data(),commpath.size());
if(rv == -1)
return {};
@ -50,5 +56,5 @@ procfs::get_name(const int tid_)
fs::close(fd);
return commpath;
return commpath.data();
}

19
src/rnd.hpp

@ -19,7 +19,7 @@
#pragma once
#include <cstdint>
#include <random>
class RND
{
@ -31,4 +31,21 @@ public:
static uint64_t rand64(const uint64_t max_);
static uint64_t rand64(const uint64_t min_,
const uint64_t max_);
template<typename T>
static
void
shrink_to_rand_elem(std::vector<T> &v_)
{
static std::mt19937 gen(std::random_device{}());
if(v_.size() <= 1)
return;
std::uniform_int_distribution<> dist(0,(v_.size() - 1));
std::swap(v_[0],v_[dist(gen)]);
v_.resize(1);
}
};

14
src/to_string.cpp

@ -18,6 +18,8 @@
#include "to_string.hpp"
#include "fmt/core.h"
#include <cstdint>
#include <string>
@ -35,21 +37,13 @@ namespace str
std::string
to(const int int_)
{
char buf[24];
sprintf(buf,"%d",int_);
return buf;
return fmt::format("{}",int_);
}
std::string
to(const uint64_t uint64_)
{
char buf[64];
sprintf(buf,"%llu",(unsigned long long)uint64_);
return buf;
return fmt::format("{}",uint64_);
}
std::string

8
src/tofrom_wrapper.hpp

@ -41,11 +41,11 @@ public:
}
public:
ToFromWrapper<T>()
ToFromWrapper()
{
}
ToFromWrapper<T>(const T data_)
ToFromWrapper(const T data_)
: _data(data_)
{
}
@ -112,11 +112,11 @@ public:
}
public:
ROToFromWrapper<T>()
ROToFromWrapper()
{
}
ROToFromWrapper<T>(const T data_)
ROToFromWrapper(const T data_)
: _data(data_)
{
}

4
src/ugid.hpp

@ -28,9 +28,9 @@ namespace ugid
}
#if defined __linux__ and UGID_USE_RWLOCK == 0
#warning "using ugid_linux.hpp"
#pragma message "using ugid_linux.hpp"
#include "ugid_linux.hpp"
#else
#warning "using ugid_rwlock.hpp"
#pragma message "using ugid_rwlock.hpp"
#include "ugid_rwlock.hpp"
#endif
Loading…
Cancel
Save