This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the fs_filesystem fsmount(2) type calls. Signed-off-by: Richard Haines <richard_c_haines@xxxxxxxxxxxxxx> --- README.md | 3 +++ defconfig | 4 ++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 10 +++++++++- tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ travis-ci/run-testsuite.sh | 1 + 9 files changed, 32 insertions(+), 2 deletions(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfs diff --git a/README.md b/README.md index 4a22389..6134270 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ similar dependencies): * e2fsprogs _(used by the ext4 filesystem tests)_ * jfsutils _(used by the jfs filesystem tests)_ * dosfstools _(used by the vfat filesystem tests)_ +* btrfs-progs _(used by the btrfs filesystem tests)_ * nftables _(used by inet_socket and sctp tests if ver >= 9.3 for secmark testing )_ On a modern Fedora system you can install these dependencies with the @@ -87,6 +88,7 @@ following command (NOTE: On Fedora 32 and below you need to remove e2fsprogs \ jfsutils \ dosfstools \ + btrfs-progs \ nftables \ kernel-devel-$(uname -r) \ kernel-modules-$(uname -r) @@ -134,6 +136,7 @@ command: e2fsprogs \ jfsutils \ dosfstools \ + btrfs-progs \ nftables On Debian, you need to build and install netlabel_tools manually since diff --git a/defconfig b/defconfig index 46eb673..5a8fb1a 100644 --- a/defconfig +++ b/defconfig @@ -117,3 +117,7 @@ CONFIG_VFAT_FS=m # They are not required for SELinux operation itself. CONFIG_WATCH_QUEUE=y CONFIG_KEY_NOTIFICATIONS=y + +# Test BTRFS filesystem. +# This is not required for SELinux operation itself. +CONFIG_BTRFS_FS=y diff --git a/tests/Makefile b/tests/Makefile index b441031..3920380 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,7 +4,7 @@ SBINDIR ?= $(PREFIX)/sbin POLDEV ?= $(PREFIX)/share/selinux/devel INCLUDEDIR ?= $(PREFIX)/include SELINUXFS ?= /sys/fs/selinux -FILESYSTEMS ?= ext4 xfs jfs vfat +FILESYSTEMS ?= ext4 xfs jfs vfat btrfs export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE diff --git a/tests/filesystem/Filesystem.pm b/tests/filesystem/Filesystem.pm index c14e760..55e3d75 100644 --- a/tests/filesystem/Filesystem.pm +++ b/tests/filesystem/Filesystem.pm @@ -122,10 +122,18 @@ sub attach_dev { sub make_fs { my ( $mk_type, $mk_dev, $mk_dir ) = @_; + + # BTRFS requires a larger minimum size that takes >2x longer to generate + if ( $mk_type eq "btrfs" ) { + $count = "28000"; + } + else { + $count = "4096"; + } print "Create $mk_dir/fstest with dd\n"; $result = system( - "dd if=/dev/zero of=$mk_dir/fstest bs=4096 count=4096 2>/dev/null"); + "dd if=/dev/zero of=$mk_dir/fstest bs=4096 count=$count 2>/dev/null"); if ( $result != 0 ) { print "dd failed to create $mk_dir/fstest\n"; } diff --git a/tests/filesystem/btrfs b/tests/filesystem/btrfs new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/filesystem/btrfs @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/filesystem/test b/tests/filesystem/test index c94deda..dcd4704 100755 --- a/tests/filesystem/test +++ b/tests/filesystem/test @@ -78,6 +78,12 @@ BEGIN { $test_count = 55; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 55; + $quota_checks = 0; + } else { $test_count = 69; } diff --git a/tests/fs_filesystem/btrfs b/tests/fs_filesystem/btrfs new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/tests/fs_filesystem/btrfs @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/tests/fs_filesystem/test b/tests/fs_filesystem/test index e706e42..59f7ea3 100755 --- a/tests/fs_filesystem/test +++ b/tests/fs_filesystem/test @@ -81,6 +81,12 @@ BEGIN { $test_count = 54; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 54; + $quota_checks = 0; + } else { $test_count = 68; } diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh index bd9073c..ed3813f 100755 --- a/travis-ci/run-testsuite.sh +++ b/travis-ci/run-testsuite.sh @@ -41,6 +41,7 @@ dnf install -y \ e2fsprogs \ jfsutils \ dosfstools \ + btrfs-progs \ kernel-devel-"$(uname -r)" \ kernel-modules-"$(uname -r)" -- 2.28.0