From e17d7aabfc512537a696319e425fe0bcda25cbde Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Tue, 1 Apr 2014 21:41:37 -0700 Subject: [PATCH] portage/util/writeable_check.py: Reverse order of RO check (bug 505428) The read only check is falsely detecting readonly filesystems while in the chroot. Reversing the search order should solve the problem. Apply Douglas Freeds improvements. dgdfgdf --- pym/portage/util/writeable_check.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pym/portage/util/writeable_check.py b/pym/portage/util/writeable_check.py index e6ddce6..eefac63 100644 --- a/pym/portage/util/writeable_check.py +++ b/pym/portage/util/writeable_check.py @@ -43,16 +43,18 @@ def linux_ro_checker(dir_list): 1. A list of filesystems which are both set to be written to and are mounted read-only, may be empty. """ + mounted_filesystems = set() ro_filesystems = set() try: - with io.open("/proc/mounts", mode='r', encoding=_encodings['content'], - errors='replace') as f: - roregex = re.compile(r'(\A|,)ro(\Z|,)') - for line in f: - if roregex.search(line.split(" ")[3].strip()) is not None: - romount = line.split(" ")[1].strip() - ro_filesystems.add(romount) + roregex = re.compile(r'(\A|,)ro(\Z|,)') + with io.open("/proc/mounts", mode='r', encoding=_encodings['content'],errors='replace') as f: + for line in f.readlines().reverse(): + path, options = map(str.strip, line.split(" ")[0:4:3]) + if path not in mounted_filesystems: + mounted_filesystems.add(path) + if roregex.search(path) is not None: + ro_filesystems.add(path) # If /proc/mounts can't be read, assume that there are no RO # filesystems and return. -- 1.8.5.3