@@ -57,10 +57,8 @@ func newSnapperBackend(cfg *types.Config, maxSnapshots int) *snapperBackend {
5757}
5858
5959// Probe tests the given device and returns the found state as a backendStat struct
60- func (s * snapperBackend ) Probe (device , mountpoint string ) (backendStat , error ) {
61- var stat backendStat
62- var err error
63-
60+ func (s * snapperBackend ) Probe (device , mountpoint string ) (stat backendStat , retErr error ) {
61+ snapshots := filepath .Join (mountpoint , snapshotsPath )
6462 // On active or passive we must ensure the actual mountpoint reported by the state
6563 // partition is the actual root, ghw only reports a single mountpoint per device...
6664 if elemental .IsPassiveMode (* s .cfg ) || elemental .IsActiveMode (* s .cfg ) {
@@ -79,7 +77,20 @@ func (s *snapperBackend) Probe(device, mountpoint string) (backendStat, error) {
7977 stat .CurrentID , s .currentID = currentID , currentID
8078 stat .ActiveID = sl .ActiveID
8179 return stat , nil
82- } else if ok , _ := utils .Exists (s .cfg .Fs , filepath .Join (mountpoint , snapperRootConfig )); ok {
80+ } else if ok , _ := utils .Exists (s .cfg .Fs , snapshots ); ok {
81+ // We must mount .snapshots to ensure snapper is capable to list snapshots
82+ if ok , _ := s .cfg .Mounter .IsLikelyNotMountPoint (snapshots ); ok {
83+ err := s .cfg .Mounter .Mount (device , snapshots , "btrfs" , []string {"ro" , fmt .Sprintf ("subvol=%s" , filepath .Join (rootSubvol , snapshotsPath ))})
84+ if err != nil {
85+ return stat , err
86+ }
87+ defer func () {
88+ err = s .cfg .Mounter .Unmount (snapshots )
89+ if err != nil && retErr == nil {
90+ retErr = err
91+ }
92+ }()
93+ }
8394 sl , err := s .ListSnapshots (mountpoint )
8495 if err != nil {
8596 return stat , err
@@ -89,7 +100,7 @@ func (s *snapperBackend) Probe(device, mountpoint string) (backendStat, error) {
89100
90101 stat .RootDir = mountpoint
91102 stat .StateMount = mountpoint
92- return stat , err
103+ return stat , nil
93104}
94105
95106// InitBrfsPartition is the method required to create snapshots structure on just formated partition
0 commit comments