1 |
On Friday 10 January 2014 22:07:52 Chris Reffett wrote: |
2 |
> Attached is a patch to test if Portage is going to write to a |
3 |
> read-only filesystem and print out the list of filesystems that need |
4 |
> to be remounted RW. This leaves ${D} intact rather than having some |
5 |
> files moved before hitting the RO filesystem. Fixes bug 378869. Since |
6 |
> git.overlays.gentoo.org is down, I haven't had the chance to rebase |
7 |
> this against latest, but I can resubmit if it doesn't cleanly apply. |
8 |
> This is my first patch to the list, so I apologize if I didn't submit |
9 |
> correctly. |
10 |
|
11 |
please use `git send-email` to post patches. attaching them makes things |
12 |
harder to review. |
13 |
|
14 |
> --- /dev/null |
15 |
> +++ b/pym/portage/util/checkwriteable.py |
16 |
> |
17 |
> + with open("/proc/mounts") as procmounts: |
18 |
|
19 |
this won't work on non-Linux systems |
20 |
|
21 |
also, as a general style thing, unless there's a real need for the var to have |
22 |
a "full" name, just use "f" or "fp" |
23 |
|
24 |
> + roregex = re.compile(r'(\A|,)ro(\Z|,)') |
25 |
> + for line in procmounts: |
26 |
> + if roregex.search(line.split(" ")[3].strip()) is not None: |
27 |
> + romount = line.split(" ")[1].strip() |
28 |
> + ro_filesystems.add(romount) |
29 |
|
30 |
ad hoc parsing of /proc/mounts isn't a good thing. at the risk of over |
31 |
engineering, there should be a func that would take care of expanding the |
32 |
mount paths into a list of namedcollections (one per mount). then you simply |
33 |
walk it looking at its options. |
34 |
|
35 |
> + for directory in dir_list: |
36 |
> + for filesystem in ro_filesystems: |
37 |
> + if re.match(filesystem, directory): |
38 |
> + ro_filesystems_written.add(filesystem) |
39 |
|
40 |
there's no need to use re and in fact you don't want to. you're looking at |
41 |
wrong strings here, not regexes. |
42 |
-mike |