mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A proper fix for the mangling in /proc/mounts
This commit is contained in:
parent
af73248fab
commit
58bf0140a7
@ -376,13 +376,14 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
|
||||
def node_mountpoint(self, node):
|
||||
|
||||
def de_octal(raw):
|
||||
return re.sub(r'\\0\d+', lambda m: chr(int(m.group()[1:], 8)), raw)
|
||||
def de_mangle(raw):
|
||||
return raw.replace('\\040', ' ').replace('\\011', '\t').replace('\\012',
|
||||
'\n').replace('\\0134', '\\')
|
||||
|
||||
for line in open('/proc/mounts').readlines():
|
||||
line = line.split()
|
||||
if line[0] == node:
|
||||
return de_octal(line[1])
|
||||
return de_mangle(line[1])
|
||||
return None
|
||||
|
||||
def find_largest_partition(self, path):
|
||||
|
Loading…
x
Reference in New Issue
Block a user