15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/snapsync/remote_pathname.rb', line 15
def findmnt
cached = Snapsync._mountpointCache.fetch(self.to_s, nil)
cached = Snapsync._mountpointCache.fetch(self.parent.to_s, nil) unless cached
cached = Snapsync._mountpointCache.fetch(self.parent.parent.to_s, nil) unless cached
return cached.dup if cached
Snapsync.debug "Pathname ('#{self}').findmnt"
proc = IO.popen(Shellwords.join ['findmnt','-n','-o','TARGET','-T', self.to_s])
path = proc.read.strip
proc.close
if not $?.success?
raise NonZeroExitCode, "findmnt failed for #{self}"
end
raise "findmnt failed" unless path
p = Pathname.new path
p2 = self.dup
while p != p2
Snapsync._mountpointCache[p2.to_s] = p
p2 = p2.parent
end
p
end
|