Просмотр исходного кода

Mount fstab entries in the correct order.

The entries in fstab used to be mounted in the order they appear in.

This can lead to situations where parent mountpoints later in the file
override child mountpoints earlier in it (e.g. /var/log/mysql can be
overriden by mounting /var/log afterwards)
Nashwan Azhari 5 лет назад
Родитель
Сommit
e2eaa89109
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      coriolis/osmorphing/osmount/base.py

+ 6 - 0
coriolis/osmorphing/osmount/base.py

@@ -4,6 +4,7 @@
 
 
 import abc
 import abc
 import base64
 import base64
+import collections
 import itertools
 import itertools
 import os
 import os
 import re
 import re
@@ -210,6 +211,11 @@ class BaseLinuxOSMountTools(BaseSSHOSMountTools):
                 "device": device,
                 "device": device,
                 "filesystem": match.group(4),
                 "filesystem": match.group(4),
                 "options": match.group(5)}
                 "options": match.group(5)}
+        # NOTE: we sort the mountpoints based on length to ensure
+        # they get mounted in the correct order:
+        mounts = collections.OrderedDict(
+            (mountpoint, mounts[mountpoint])
+            for mountpoint in sorted(mounts, key=len))
 
 
         # regexes for supported fstab device references:
         # regexes for supported fstab device references:
         uuid_char_regex = "[0-9a-fA-F]"
         uuid_char_regex = "[0-9a-fA-F]"