Lines 43-58
def linux_ro_checker(dir_list):
Link Here
|
43 |
1. A list of filesystems which are both set to be written to and are mounted |
43 |
1. A list of filesystems which are both set to be written to and are mounted |
44 |
read-only, may be empty. |
44 |
read-only, may be empty. |
45 |
""" |
45 |
""" |
|
|
46 |
mounted_filesystems = set() |
46 |
ro_filesystems = set() |
47 |
ro_filesystems = set() |
47 |
|
48 |
|
48 |
try: |
49 |
try: |
49 |
with io.open("/proc/mounts", mode='r', encoding=_encodings['content'], |
50 |
roregex = re.compile(r'(\A|,)ro(\Z|,)') |
50 |
errors='replace') as f: |
51 |
with io.open("/proc/mounts", mode='r', encoding=_encodings['content'],errors='replace') as f: |
51 |
roregex = re.compile(r'(\A|,)ro(\Z|,)') |
52 |
for line in f.readlines().reverse(): |
52 |
for line in f: |
53 |
path, options = map(str.strip, line.split(" ")[0:4:3]) |
53 |
if roregex.search(line.split(" ")[3].strip()) is not None: |
54 |
if path not in mounted_filesystems: |
54 |
romount = line.split(" ")[1].strip() |
55 |
mounted_filesystems.add(path) |
55 |
ro_filesystems.add(romount) |
56 |
if roregex.search(path) is not None: |
|
|
57 |
ro_filesystems.add(path) |
56 |
|
58 |
|
57 |
# If /proc/mounts can't be read, assume that there are no RO |
59 |
# If /proc/mounts can't be read, assume that there are no RO |
58 |
# filesystems and return. |
60 |
# filesystems and return. |
59 |
- |
|
|