mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-08 23:07:28 -04:00
Merge pull request #45 from giuseppe/fix-leaks
fuse-overlayfs: use autocleanup functions
This commit is contained in:
commit
d76078982e
16
.travis.yml
16
.travis.yml
@ -1,3 +1,5 @@
|
||||
services:
|
||||
- docker
|
||||
language: c
|
||||
sudo: required
|
||||
dist: trusty
|
||||
@ -16,15 +18,17 @@ addons:
|
||||
- g++
|
||||
- python3-setuptools
|
||||
before_install:
|
||||
- docker pull fedora &
|
||||
- sudo mkdir -p /lower /upper /mnt
|
||||
- (cd /; sudo git clone https://github.com/amir73il/unionmount-testsuite.git)
|
||||
- (git clone git://github.com/ninja-build/ninja.git && cd ninja && python3.5 ./bootstrap.py && sudo cp ninja /usr/bin)
|
||||
- (git clone https://github.com/mesonbuild/meson.git; cd meson; sudo python3.5 ./setup.py install)
|
||||
- (wget https://github.com/libfuse/libfuse/releases/download/fuse-3.2.4/fuse-3.2.4.tar.xz; tar xf fuse-3.2.4.tar.xz; cd fuse-3.2.4; mkdir build; cd build; meson .. --prefix /usr && ninja && sudo ninja install)
|
||||
script:
|
||||
- ./autogen.sh
|
||||
- ./configure
|
||||
- make -j $(nproc)
|
||||
- sudo make -j install; sudo cp fuse-overlayfs /sbin
|
||||
- (cd /unionmount-testsuite; sudo ./run --ov --fuse=fuse-overlayfs --xdev)
|
||||
- (cd /unionmount-testsuite; FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 sudo -E ./run --ov --fuse=fuse-overlayfs --xdev)
|
||||
- ./autogen.sh || travis_terminate 1;
|
||||
- ./configure || travis_terminate 1;
|
||||
- make -j $(nproc) || travis_terminate 1;
|
||||
- sudo make -j install; sudo cp fuse-overlayfs /sbin || travis_terminate 1;
|
||||
- (cd /unionmount-testsuite; sudo ./run --ov --fuse=fuse-overlayfs --xdev) || travis_terminate 1;
|
||||
- (cd /unionmount-testsuite; FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 sudo -E ./run --ov --fuse=fuse-overlayfs --xdev) || travis_terminate 1;
|
||||
- sudo tests/fedora-installs.sh
|
||||
|
@ -4,7 +4,7 @@ bin_PROGRAMS = fuse-overlayfs
|
||||
|
||||
ACLOCAL_AMFLAGS = -Im4
|
||||
|
||||
EXTRA_DIST = m4/gnulib-cache.m4 rpm/fuse-overlayfs.spec.template autogen.sh fuse-overlayfs.1.md
|
||||
EXTRA_DIST = m4/gnulib-cache.m4 rpm/fuse-overlayfs.spec.template autogen.sh fuse-overlayfs.1.md utils.h
|
||||
|
||||
CLEANFILES = fuse-overlayfs.1
|
||||
|
||||
|
21
tests/fedora-installs.sh
Executable file
21
tests/fedora-installs.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir lower upper workdir merged
|
||||
|
||||
fuse-overlayfs -o lowerdir=lower,upperdir=upper,workdir=workdir,suid,dev merged
|
||||
|
||||
docker run --rm -ti -v merged:/merged fedora dnf --installroot /merged --releasever 29 install -y glibc-common
|
||||
|
||||
umount merged
|
||||
|
||||
# Make sure workdir is empty, and move the upper layer down
|
||||
rm -rf workdir lower
|
||||
mv upper lower
|
||||
mkdir upper workdir
|
||||
|
||||
fuse-overlayfs -o lowerdir=lower,upperdir=upper,workdir=workdir,suid,dev merged
|
||||
|
||||
# Install some big packages
|
||||
docker run --rm -ti -v merged:/merged fedora dnf --installroot /merged --releasever 29 install -y emacs texlive
|
||||
|
||||
umount merged
|
57
utils.h
Normal file
57
utils.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* fuse-overlayfs: Overlay Filesystem in Userspace
|
||||
|
||||
Copyright (C) 2019 Red Hat Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef UTILS_H
|
||||
# define UTILS_H
|
||||
|
||||
void
|
||||
cleanup_freep (void *p)
|
||||
{
|
||||
void **pp = (void **) p;
|
||||
free (*pp);
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_filep (FILE **f)
|
||||
{
|
||||
FILE *file = *f;
|
||||
if (file)
|
||||
(void) fclose (file);
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_closep (void *p)
|
||||
{
|
||||
int *pp = p;
|
||||
if (*pp >= 0)
|
||||
close (*pp);
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_dirp (DIR **p)
|
||||
{
|
||||
DIR *dir = *p;
|
||||
if (dir)
|
||||
closedir (dir);
|
||||
}
|
||||
|
||||
# define cleanup_file __attribute__((cleanup (cleanup_filep)))
|
||||
# define cleanup_free __attribute__((cleanup (cleanup_freep)))
|
||||
# define cleanup_close __attribute__((cleanup (cleanup_closep)))
|
||||
# define cleanup_dir __attribute__((cleanup (cleanup_dirp)))
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user