From 17957a163a16836c3539cc1ef2830a2c5cc0e2d1 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Fri, 4 Jan 2019 17:32:01 +0100 Subject: [PATCH] btrbk: trigger autofs mount while resolving mountpoints If resolved mount point has fs_type=autofs, trigger automount by calling "btrfs subvolume show" on the mount point, and check mountinfo again. --- ChangeLog | 1 + btrbk | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22407e6..6581c74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ btrbk-master * Bump dependency >= btrfs-progs-4.12 (as of btrbk-0.27.0). + * Trigger autofs mount while resolving mountpoints (close #259). btrbk-0.27.1 diff --git a/btrbk b/btrbk index 30023da..b4acb95 100755 --- a/btrbk +++ b/btrbk @@ -1847,9 +1847,10 @@ sub system_mkdir($) } -sub btrfs_mountpoint($) +sub btrfs_mountpoint { my $vol = shift // die; + my $autofs_retry = shift; DEBUG "Resolving btrfs mount point for: $vol->{PRINT}"; @@ -1891,7 +1892,19 @@ sub btrfs_mountpoint($) return undef; } TRACE "resolved mount point (mount_source=$mountpoint->{mount_source}, subvolid=" . ($mountpoint->{MNTOPS}->{subvolid} // '') . "): $mountpoint->{mount_point}"; - unless($mountpoint->{fs_type} eq 'btrfs') { + + # handle autofs + if($mountpoint->{fs_type} eq 'autofs') { + if($autofs_retry) { + DEBUG "non-btrfs autofs mount point for: $vol->{PRINT}"; + return undef; + } + DEBUG "autofs mount point found, triggering automount on $mountpoint->{mount_point} for: $vol->{PRINT}"; + btrfs_subvolume_show(vinfo($vol->{URL_PREFIX} . $mountpoint->{mount_point}, $vol->{CONFIG})); + $mountinfo_cache{$host} = undef; + return btrfs_mountpoint($vol, 1); + } + elsif($mountpoint->{fs_type} ne 'btrfs') { DEBUG "No btrfs mount point found for: $vol->{PRINT}"; return undef; }