utils.c: fix file_exists_at musl compatibility.

utils.c: file_exists_at: fallback to `fstatat` when `faccessat` fails with `EINVAL` (on musl).
.travis.yml: alpine test added.
main.c: reallocate path before appending.

Closes #174.

Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
This commit is contained in:
Max Goltzsche 2020-08-24 23:07:48 +02:00
parent 519ce4df6f
commit d5b725b6f1
No known key found for this signature in database
GPG Key ID: F8B5AF50344BB503
7 changed files with 60 additions and 6 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
*
!lib
!m4
!*.sh
!*.ac
!*.am
!*.md
!*.h
!*.c

View File

@ -26,7 +26,6 @@ addons:
- parallel
before_install:
- docker pull fedora &
- docker build -t alpine-build -f Dockerfile.alpine .
- (wget https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz && tar xf go1.13.7.linux-amd64.tar.gz && sudo mv go /usr/local)
- sudo mkdir -p /lower /upper /mnt
- (cd /; sudo git clone https://github.com/amir73il/unionmount-testsuite.git)
@ -44,6 +43,6 @@ script:
- (cd /unionmount-testsuite; sudo FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 unshare -m ./run --ov --fuse=fuse-overlayfs --xdev) || travis_terminate 1;
- sudo tests/fedora-installs.sh || travis_terminate 1;
- sudo tests/unlink.sh || travis_terminate 1;
- sudo tests/alpine.sh || travis_terminate 1;
- (cd $GOPATH/src/github.com/containers/storage/tests; sudo JOBS=1 STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
- (cd $GOPATH/src/github.com/containers/storage/tests; sudo JOBS=1 FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
- docker run --rm -v $(pwd):/fuse-overlayfs alpine-build sh -c 'cd /fuse-overlayfs; ./autogen.sh && ./configure && make clean && make'

View File

@ -1,2 +1,23 @@
FROM alpine
RUN apk add make gcc fuse3-dev libc-dev go-md2man linux-headers automake autoconf gettext
WORKDIR /build
RUN apk add git make gcc libc-dev musl-dev glib-static gettext eudev-dev \
linux-headers automake autoconf cmake meson ninja clang go-md2man
RUN git clone https://github.com/libfuse/libfuse && \
cd libfuse && \
mkdir build && \
cd build && \
LDFLAGS="-lpthread -s -w -static" meson --prefix /usr -D default_library=static .. && \
ninja && \
ninja install
COPY . /build/fuse-overlayfs
RUN cd fuse-overlayfs && \
./autogen.sh && \
LIBS="-ldl" LDFLAGS="-s -w -static" ./configure --prefix /usr && \
make clean && \
make && \
make install
USER nobody
ENTRYPOINT ["/usr/bin/fuse-overlayfs","-f"]

3
main.c
View File

@ -5231,6 +5231,9 @@ main (int argc, char *argv[])
if (path == NULL)
goto err_out1;
mkdir (path, 0700);
path = realloc(path, strlen(path)+strlen("/work")+1);
if (!path)
error (EXIT_FAILURE, errno, "allocating workdir path");
strcat (path, "/work");
mkdir (path, 0700);
free (lo.workdir);

11
tests/alpine.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
cd "$(dirname "$0")"
set -ex
docker build -t fuse-overlayfs:alpine -f ../Dockerfile.alpine ..
docker run --privileged --rm --entrypoint /unlink.sh -w /tmp \
-e EXPECT_UMOUNT_STATUS=1 \
-v "$(pwd)/unlink.sh:/unlink.sh" fuse-overlayfs:alpine

View File

@ -1,6 +1,11 @@
#!/bin/sh
rm -rf lower upper workdir merged
set -ex
rm -rf unlink-test
mkdir unlink-test
cd unlink-test
mkdir lower upper workdir merged
@ -21,4 +26,4 @@ echo world >> merged/foo2
grep hello merged/foo
grep world merged/foo
umount merged
umount merged || [ $? -eq "${EXPECT_UMOUNT_STATUS:-0}" ]

View File

@ -103,7 +103,12 @@ safe_openat (int dirfd, const char *pathname, int flags, mode_t mode)
int
file_exists_at (int dirfd, const char *pathname)
{
return faccessat (dirfd, pathname, F_OK, AT_SYMLINK_NOFOLLOW|AT_EACCESS);
int ret = faccessat (dirfd, pathname, F_OK, AT_SYMLINK_NOFOLLOW|AT_EACCESS);
if (ret < 0 && errno == EINVAL) {
struct stat buf;
return fstatat (dirfd, pathname, &buf, AT_SYMLINK_NOFOLLOW);
}
return ret;
}
#ifdef HAVE_STATX