mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
snapshot: Check that / is a btrfs subvolume before setup
Skip setup the snapshots app if the filesystem type is btrfs but / is not a btrfs subvolume. For example, this may happen in containers where / is a bind mounted btrfs filesystem. Closes #1994 Tests performed: - Install freedombox on a lxc container inside Pioneer-FreedomBox. (In a container, / is a bind mounted btrfs filesystem). The snapshot app setup is skipped. - Install freedombox inside dev container (which uses btrfs filesystem image). The snapshot app setup succeeds. - Install freedombox inside container that uses a host directory as a base and the filesystem is ext4. The snapshot app setup is skipped. Signed-off-by: Veiko Aasa <veiko17@disroot.org> [sunil: Add comment explaining the check, fix a flake8 message] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
8a7a4a97d1
commit
b447627ec8
@ -4,6 +4,7 @@ FreedomBox app to manage filesystem snapshots.
|
||||
"""
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
import augeas
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@ -64,7 +65,11 @@ class SnapshotApp(app_module.App):
|
||||
def is_supported():
|
||||
"""Return whether snapshots are support on current setup."""
|
||||
fs_type = storage.get_filesystem_type()
|
||||
return fs_type in fs_types_supported
|
||||
# Check that / is not a bind mounted btrfs filesystem similar to how
|
||||
# snapper does the check: https://github.com/openSUSE/snapper/blob/
|
||||
# 77eb6565d3d8df95a06cd52ce31174d98994939c/snapper/BtrfsUtils.cc#L61
|
||||
root_inode_number = pathlib.Path('/').stat().st_ino
|
||||
return fs_type in fs_types_supported and root_inode_number == 256
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user