1 |
commit: 733c692eca0ad50591ccf11cfcf89e317291f35f |
2 |
Author: Peter Levine <plevine457 <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri Oct 8 01:13:01 2021 +0000 |
4 |
Commit: Ben Kohler <bkohler <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Oct 8 11:12:16 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=733c692e |
7 |
|
8 |
sys-boot/os-prober: replace os-prober-1.78-btrfsfix.patch |
9 |
|
10 |
Replace os-prober-1.78-btrfsfix.patch with changes from OpenSUSE's |
11 |
os-prober-btrfs-always-detect-default.patch to fix OS detection issues. |
12 |
|
13 |
Closes: https://bugs.gentoo.org/790434 |
14 |
Package-Manager: Portage-3.0.26, Repoman-3.0.3 |
15 |
Signed-off-by: Peter Levine <plevine457 <AT> gmail.com> |
16 |
Signed-off-by: Ben Kohler <bkohler <AT> gentoo.org> |
17 |
|
18 |
.../os-prober-1.79-btrfs-subvolume-detection.patch | 505 +++++++++++++++++++++ |
19 |
sys-boot/os-prober/os-prober-9999.ebuild | 2 +- |
20 |
2 files changed, 506 insertions(+), 1 deletion(-) |
21 |
|
22 |
diff --git a/sys-boot/os-prober/files/os-prober-1.79-btrfs-subvolume-detection.patch b/sys-boot/os-prober/files/os-prober-1.79-btrfs-subvolume-detection.patch |
23 |
new file mode 100644 |
24 |
index 00000000000..14cd794530e |
25 |
--- /dev/null |
26 |
+++ b/sys-boot/os-prober/files/os-prober-1.79-btrfs-subvolume-detection.patch |
27 |
@@ -0,0 +1,505 @@ |
28 |
+Fixes detection of multiple linux installations on different subvolumes of the |
29 |
+same partition. Also contains changes from |
30 |
+https://build.opensuse.org/package/view_file/openSUSE:Factory/os-prober/os-prober-btrfs-always-detect-default.patch |
31 |
+to fix https://bugs.gentoo.org/790434. |
32 |
+ |
33 |
+Bug: https://bugs.gentoo.org/790434 |
34 |
+ https://bugs.debian.org/688336 |
35 |
+ https://bugzilla.redhat.com/888341 |
36 |
+ |
37 |
+--- a/common.sh |
38 |
++++ b/common.sh |
39 |
+@@ -155,6 +155,7 @@ |
40 |
+ done |
41 |
+ } |
42 |
+ |
43 |
++# add forth parameter to pickup btrfs subvol info |
44 |
+ parsefstab () { |
45 |
+ while read -r line; do |
46 |
+ case "$line" in |
47 |
+@@ -165,12 +166,22 @@ |
48 |
+ set -f |
49 |
+ set -- $line |
50 |
+ set +f |
51 |
+- printf '%s %s %s\n' "$1" "$2" "$3" |
52 |
++ printf '%s %s %s %s\n' "$1" "$2" "$3" "$4" |
53 |
+ ;; |
54 |
+ esac |
55 |
+ done |
56 |
+ } |
57 |
+ |
58 |
++#check_btrfs_mounted $bootsv $bootuuid) |
59 |
++check_btrfs_mounted () { |
60 |
++ bootsv="$1" |
61 |
++ bootuuid="$2" |
62 |
++ bootdev=$(blkid | grep "$bootuuid" | cut -d ':' -f 1) |
63 |
++ bindfrom=$(grep " btrfs " /proc/self/mountinfo | |
64 |
++ grep " $bootdev " | grep " /$bootsv " | cut -d ' ' -f 5) |
65 |
++ printf "%s" "$bindfrom" |
66 |
++} |
67 |
++ |
68 |
+ unescape_mount () { |
69 |
+ printf %s "$1" | \ |
70 |
+ sed 's/\\011/ /g; s/\\012/\n/g; s/\\040/ /g; s/\\134/\\/g' |
71 |
+--- a/linux-boot-prober |
72 |
++++ b/linux-boot-prober |
73 |
+@@ -5,16 +5,148 @@ |
74 |
+ |
75 |
+ newns "$@" |
76 |
+ require_tmpdir |
77 |
++ERR="n" |
78 |
++ |
79 |
++tmpmnt=/var/lib/os-prober/mount |
80 |
++if [ ! -d "$tmpmnt" ]; then |
81 |
++ mkdir "$tmpmnt" |
82 |
++fi |
83 |
++ |
84 |
++mounted= |
85 |
++bootmnt= |
86 |
++bootsv= |
87 |
++bootuuid= |
88 |
+ |
89 |
+ grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true |
90 |
+ |
91 |
+-partition="$1" |
92 |
++if [ -z "$1" ]; then |
93 |
++ ERR=y |
94 |
++elif [ "$1" = btrfs -a -z "$2" ]; then |
95 |
++ ERR=y |
96 |
++elif [ "$1" = btrfs -a -z "$3" ]; then |
97 |
++ ERR=y |
98 |
++elif [ "$1" = btrfs ]; then |
99 |
++ type=btrfs |
100 |
++ echo "$2" | grep -q "^UUID=" || ERR=y |
101 |
++ echo "$3" | grep -q "^subvol=" || ERR=y |
102 |
++ export "$2" |
103 |
++ export "$3" |
104 |
++ partition=$(blkid | grep "$UUID" | cut -d ':' -f 1 | tr '\n' ' ' | cut -d ' ' -f 1) |
105 |
++ debug "btrfs: partition=$partition, UUID=$UUID, subvol=$subvol" |
106 |
++else |
107 |
++ partition="$1" |
108 |
++ type=other |
109 |
++fi |
110 |
+ |
111 |
+-if [ -z "$partition" ]; then |
112 |
++if [ "x$ERR" != xn ]; then |
113 |
+ echo "usage: linux-boot-prober partition" >&2 |
114 |
++ echo " linux-boot-prober btrfs UUID=<> subvol=<>" >&2 |
115 |
+ exit 1 |
116 |
+ fi |
117 |
+ |
118 |
++if [ "$type" = btrfs ]; then |
119 |
++ # handle all of the btrfs stuff here |
120 |
++ if [ ! -e "/proc/self/mountinfo" ]; then |
121 |
++ warn "/proc/self/mountinfo does not exist, exiting" |
122 |
++ umount "$tmpmnt" 2>/dev/null |
123 |
++ rmdir "$tmpmnt" 2>/dev/null |
124 |
++ exit 1 |
125 |
++ fi |
126 |
++ mpoint=$(grep "btrfs" /proc/self/mountinfo | grep " /$subvol " | grep " $partition " | cut -d ' ' -f 5) |
127 |
++ if [ "$mpoint" = "/" ]; then |
128 |
++ warn "specifying active root not valid, exiting" |
129 |
++ umount "$tmpmnt" 2>/dev/null |
130 |
++ rmdir "$tmpmnt" 2>/dev/null |
131 |
++ exit 1 |
132 |
++ fi |
133 |
++ if [ "$mpoint" = "$tmpmnt" ]; then |
134 |
++ warn "btrfs subvol=$subvool, UUID=$UUID, already mounted on $tmpmnt **ERROR**" |
135 |
++ umount "$tmpmnt" 2>/dev/null |
136 |
++ rmdir "$tmpmnt" 2>/dev/null |
137 |
++ exit 1 |
138 |
++ fi |
139 |
++ if [ -z "$mpoint" ]; then |
140 |
++ # mount the btrfs root |
141 |
++ |
142 |
++ if [ -n "$subvol" ]; then |
143 |
++ opts="-o subvol=$subvol" |
144 |
++ fi |
145 |
++ |
146 |
++ if ! mount $opts -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then |
147 |
++ warn "error mounting btrfs subvol=$subvol UUID=$UUID" |
148 |
++ umount "$tmpmnt/boot" 2>/dev/null |
149 |
++ umount "$tmpmnt" 2>/dev/null |
150 |
++ rmdir "$tmpmnt" 2>/dev/null |
151 |
++ exit 1 |
152 |
++ fi |
153 |
++ else |
154 |
++ # bind-mount |
155 |
++ if ! mount -o bind "$mpoint" "$tmpmnt" 2>/dev/null; then |
156 |
++ warn "error mounting btrfs bindfrom=$mpoint subvol=$subvol UUID=$UUID" |
157 |
++ umount "$tmpmnt/boot" 2>/dev/null |
158 |
++ umount "$tmpmnt" 2>/dev/null |
159 |
++ rmdir "$tmpmnt" 2>/dev/null |
160 |
++ exit 1 |
161 |
++ fi |
162 |
++ fi |
163 |
++ debug "mounted btrfs $partition, subvol=$subvol on $tmpmnt" |
164 |
++ if [ ! -e "$tmpmnt/etc/fstab" ]; then |
165 |
++ warn "btrfs subvol=$subvol not root" |
166 |
++ umount "$tmpmnt" 2>/dev/null |
167 |
++ rmdir "$tmpmnt" 2>/dev/null |
168 |
++ exit 1 |
169 |
++ fi |
170 |
++ bootmnt=$(parsefstab < "$tmpmnt/etc/fstab" | grep " /boot ") || true |
171 |
++ if [ -z "$bootmnt" ]; then |
172 |
++ # /boot is part of the root |
173 |
++ bootpart="$partition" |
174 |
++ bootsv="$subvol" |
175 |
++ elif echo "$bootmnt" | cut -d ' ' -f 3 | grep -q "btrfs"; then |
176 |
++ # separate btrfs /boot subvolume |
177 |
++ bootsv=$(echo "$bootmnt" | cut -d ' ' -f 4 | grep "^subvol=" | sed "s/subvol=//" ) |
178 |
++ bootuuid=$(echo "$bootmnt" | cut -d ' ' -f 1 | grep "^UUID=" | sed "s/UUID=//" ) |
179 |
++ debug "mounting btrfs $tmpmnt/boot UUID=$bootuuid subvol=$bootsv" |
180 |
++ bindfrom=$(check_btrfs_mounted $bootsv $bootuuid) |
181 |
++ if [ -n "$bindfrom" ]; then |
182 |
++ # already mounted some place |
183 |
++ if ! mount -o bind $bindfrom "$tmpmnt/boot" 2>/dev/null; then |
184 |
++ warn "error bind mounting btrfs boot subvol=$bootsv, from=$bindfrom" |
185 |
++ umount "$tmpmnt/boot" 2>/dev/null |
186 |
++ umount "$tmpmnt" 2>/dev/null |
187 |
++ rmdir "$tmpmnt" 2>/dev/null |
188 |
++ exit 1 |
189 |
++ fi |
190 |
++ elif ! mount -o subvol=$bootsv -t btrfs -U $bootuuid "$tmpmnt/boot" 2>/dev/null; then |
191 |
++ warn "error mounting btrfs boot partition subvol=$bootsv, UUID=$bootuuid" |
192 |
++ umount "$tmpmnt/boot" 2>/dev/null |
193 |
++ umount "$tmpmnt" 2>/dev/null |
194 |
++ rmdir "$tmpmnt" 2>/dev/null |
195 |
++ exit 1 |
196 |
++ fi |
197 |
++ bootpart=$(grep " btrfs " /proc/self/mountinfo | grep " /$bootsv " | cut -d ' ' -f 10) |
198 |
++ else |
199 |
++ # non-btrfs partition or logical volume |
200 |
++ linux_mount_boot $partition $tmpmnt |
201 |
++ bootpart="${mountboot%% *}" |
202 |
++ bootsv= |
203 |
++ fi |
204 |
++ |
205 |
++ test="/usr/lib/linux-boot-probes/mounted/40grub2" |
206 |
++ if [ -f $test ] && [ -x $test ]; then |
207 |
++ debug "running $test $partition $bootpart $tmpmnt $type $subvol $bootsv" |
208 |
++ if $test "$partition" "$bootpart" "$tmpmnt" "$type" "$subvol" "$bootsv"; then |
209 |
++ debug "$test succeeded" |
210 |
++ fi |
211 |
++ fi |
212 |
++ umount "$tmpmnt/boot" 2>/dev/null || true |
213 |
++ if ! umount "$tmpmnt" 2>/dev/null; then |
214 |
++ warn "problem umount $tmpmnt" |
215 |
++ fi |
216 |
++ rmdir "$tmpmnt" 2>/dev/null || true |
217 |
++ |
218 |
++ exit 0 |
219 |
++fi |
220 |
++ |
221 |
+ if ! mapped="$(mapdevfs "$partition")"; then |
222 |
+ log "Device '$partition' does not exist; skipping" |
223 |
+ continue |
224 |
+@@ -22,8 +154,8 @@ |
225 |
+ |
226 |
+ if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then |
227 |
+ for test in /usr/lib/linux-boot-probes/*; do |
228 |
+- debug "running $test" |
229 |
+ if [ -x $test ] && [ -f $test ]; then |
230 |
++ debug "running $test" |
231 |
+ if $test "$partition"; then |
232 |
+ debug "linux detected by $test" |
233 |
+ break |
234 |
+--- a/linux-boot-probes/mounted/common/40grub2 |
235 |
++++ b/linux-boot-probes/mounted/common/40grub2 |
236 |
+@@ -2,17 +2,30 @@ |
237 |
+ . /usr/share/os-prober/common.sh |
238 |
+ set -e |
239 |
+ |
240 |
++# add support for btrfs with no separate /boot |
241 |
++# that is, rootsv = bootsv |
242 |
+ partition="$1" |
243 |
+ bootpart="$2" |
244 |
+ mpoint="$3" |
245 |
+ type="$4" |
246 |
++rootsv="$5" |
247 |
++bootsv="$6" |
248 |
+ |
249 |
+ found_item=0 |
250 |
+ |
251 |
+ entry_result () { |
252 |
++ if [ "x$type" = "xbtrfs" -a "$partition" = "$bootpart" ]; then |
253 |
++ # trim off the leading subvol |
254 |
++ kernelfile=$(echo "$kernel" | cut -d '/' -f 2- | cut -d '/' -f 2-) |
255 |
++ if [ "x$rootsv" != "x$bootsv" ]; then |
256 |
++ kernelfile="/boot/$kernelfile" |
257 |
++ fi |
258 |
++ else |
259 |
++ kernelfile=$kernel |
260 |
++ fi |
261 |
+ if [ "$ignore_item" = 0 ] && \ |
262 |
+ [ -n "$kernel" ] && \ |
263 |
+- [ -e "$mpoint/$kernel" ]; then |
264 |
++ [ -e "$mpoint/$kernelfile" ]; then |
265 |
+ result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters" |
266 |
+ found_item=1 |
267 |
+ fi |
268 |
+@@ -108,9 +121,9 @@ |
269 |
+ [ "$mpoint/boot/grub/grub.cfg" -nt "$mpoint/boot/grub/menu.lst" ]); then |
270 |
+ debug "parsing grub.cfg" |
271 |
+ parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.cfg" |
272 |
+-elif [ -e "$mpoint/boot/grub2/grub.cfg" ]; then |
273 |
++elif [ -e "$mpoint/boot/grub/grub.cfg" ]; then |
274 |
+ debug "parsing grub.cfg" |
275 |
+- parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub2/grub.cfg" |
276 |
++ parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.cfg" |
277 |
+ fi |
278 |
+ |
279 |
+ if [ "$found_item" = 0 ]; then |
280 |
+--- a/os-prober |
281 |
++++ b/os-prober |
282 |
+@@ -76,9 +76,12 @@ |
283 |
+ |
284 |
+ # Also detect OSes on LVM volumes (assumes LVM is active) |
285 |
+ if type lvs >/dev/null 2>&1; then |
286 |
+- echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name | |
287 |
++ echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name 2>/dev/null | |
288 |
+ sed "s|-|--|g;s|^[[:space:]]*\(.*\):\(.*\)$|/dev/mapper/\1-\2|")" |
289 |
+ fi |
290 |
++ |
291 |
++ # now lets make sure we got all of the btrfs partitions and disks |
292 |
++ blkid | grep 'TYPE="btrfs"' | cut -d ':' -f 1 |
293 |
+ } |
294 |
+ |
295 |
+ parse_proc_swaps () { |
296 |
+@@ -136,6 +139,8 @@ |
297 |
+ grep "^md" /proc/mdstat | cut -d: -f2- | parse_proc_mdstat >"$OS_PROBER_TMP/raided-map" || true |
298 |
+ fi |
299 |
+ |
300 |
++: >"$OS_PROBER_TMP/btrfs-vols" |
301 |
++ |
302 |
+ for partition in $(partitions); do |
303 |
+ if ! mapped="$(mapdevfs "$partition")"; then |
304 |
+ log "Device '$partition' does not exist; skipping" |
305 |
+@@ -154,7 +159,26 @@ |
306 |
+ continue |
307 |
+ fi |
308 |
+ |
309 |
+- if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then |
310 |
++ # do btrfs processing here; both mounted and unmounted will |
311 |
++ # be handled by 50mounted-tests so we can do a subvol only once. |
312 |
++ type=$(blkid -o value -s TYPE $mapped || true) |
313 |
++ if [ "$type" = btrfs ]; then |
314 |
++ uuid=$(blkid -o value -s UUID $mapped) |
315 |
++ if grep -q "^$uuid" "$OS_PROBER_TMP/btrfs-vols" ; then |
316 |
++ continue |
317 |
++ fi |
318 |
++ debug "btrfs volume uuid=$uuid partition=$partition" |
319 |
++ echo "$uuid" >>"$OS_PROBER_TMP/btrfs-vols" |
320 |
++ test="/usr/lib/os-probes/50mounted-tests" |
321 |
++ if [ -f "$test" ] && [ -x "$test" ]; then |
322 |
++ debug "running $test on btrfs $partition" |
323 |
++ if "$test" btrfs "$uuid" "$partition"; then |
324 |
++ debug "os detected by $test" |
325 |
++ continue |
326 |
++ fi |
327 |
++ fi |
328 |
++ |
329 |
++ elif ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then |
330 |
+ for test in /usr/lib/os-probes/*; do |
331 |
+ if [ -f "$test" ] && [ -x "$test" ]; then |
332 |
+ debug "running $test on $partition" |
333 |
+--- a/os-probes/common/50mounted-tests |
334 |
++++ b/os-probes/common/50mounted-tests |
335 |
+@@ -14,19 +14,31 @@ |
336 |
+ rmdir "$tmpmnt" || true |
337 |
+ } |
338 |
+ |
339 |
+-types="$(fs_type "$partition")" |
340 |
++if [ "x$1" = xbtrfs ]; then |
341 |
++ types=btrfs |
342 |
++ if [ -z "$2" -o -z "$3" ]; then |
343 |
++ debug "missing btrfs parameters, exiting" |
344 |
++ exit 1 |
345 |
++ fi |
346 |
++ UUID="$2" |
347 |
++ BTRFSDEV="$3" |
348 |
++else |
349 |
++ partition="$1" |
350 |
++ types="$(fs_type "$partition")" || types=NOT-DETECTED |
351 |
++fi |
352 |
++ |
353 |
+ if [ "$types" = NOT-DETECTED ]; then |
354 |
+ debug "$1 type not recognised; skipping" |
355 |
+- exit 0 |
356 |
++ exit 1 |
357 |
+ elif [ "$types" = swap ]; then |
358 |
+ debug "$1 is a swap partition; skipping" |
359 |
+- exit 0 |
360 |
++ exit 1 |
361 |
+ elif [ "$types" = crypto_LUKS ]; then |
362 |
+ debug "$1 is a LUKS partition; skipping" |
363 |
+- exit 0 |
364 |
++ exit 1 |
365 |
+ elif [ "$types" = LVM2_member ]; then |
366 |
+ debug "$1 is an LVM member; skipping" |
367 |
+- exit 0 |
368 |
++ exit 1 |
369 |
+ elif [ "$types" = ntfs ]; then |
370 |
+ if type ntfs-3g >/dev/null 2>&1; then |
371 |
+ types='ntfs-3g ntfs' |
372 |
+@@ -35,7 +47,7 @@ |
373 |
+ if type cryptsetup >/dev/null 2>&1 && \ |
374 |
+ cryptsetup luksDump "$partition" >/dev/null 2>&1; then |
375 |
+ debug "$1 is a LUKS partition; skipping" |
376 |
+- exit 0 |
377 |
++ exit 1 |
378 |
+ fi |
379 |
+ for type in $(grep -v nodev /proc/filesystems); do |
380 |
+ # hfsplus filesystems are mountable as hfs. Try hfs last so |
381 |
+@@ -58,6 +70,127 @@ |
382 |
+ fi |
383 |
+ |
384 |
+ mounted= |
385 |
++ |
386 |
++probe_subvol () |
387 |
++{ |
388 |
++ local subvol=$1 |
389 |
++ local partition=$2 |
390 |
++ local UUID=$3 |
391 |
++ local tmpmnt=$4 |
392 |
++ |
393 |
++ mounted= |
394 |
++ mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)" |
395 |
++ ret=1 |
396 |
++ |
397 |
++ if [ -n "$subvol" ]; then |
398 |
++ opts="-o subvol=$subvol" |
399 |
++ fi |
400 |
++ |
401 |
++ if [ -n "$mpoint" ]; then |
402 |
++ if [ "x$mpoint" = "x/" ]; then |
403 |
++ continue # this is the root for the running system |
404 |
++ fi |
405 |
++ mounted=1 |
406 |
++ else |
407 |
++ # again, do not mount btrfs ro |
408 |
++ mount -t btrfs $opts -U "$UUID" "$tmpmnt" |
409 |
++ mpoint="$tmpmnt" |
410 |
++ fi |
411 |
++ test="/usr/lib/os-probes/mounted/90linux-distro" |
412 |
++ if [ -f "$test" ] && [ -x "$test" ]; then |
413 |
++ debug "running subtest $test" |
414 |
++ if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID" "subvol=$subvol"; then |
415 |
++ debug "os found by subtest $test on subvol $subvol" |
416 |
++ ret=0 |
417 |
++ fi |
418 |
++ fi |
419 |
++ if [ -z "$mounted" ]; then |
420 |
++ if ! umount "$tmpmnt"; then |
421 |
++ warn "failed to umount $tmpmnt" |
422 |
++ fi |
423 |
++ fi |
424 |
++ return $ret |
425 |
++} |
426 |
++ |
427 |
++# all btrfs processing here. Handle both unmounted and |
428 |
++# mounted subvolumes. |
429 |
++if [ "$types" = btrfs ]; then |
430 |
++ partition="$BTRFSDEV" |
431 |
++ debug "begin btrfs processing for $UUID" |
432 |
++ # note that the btrfs volume must not be mounted ro |
433 |
++ if mount -t btrfs -U "$UUID" "$tmpmnt" 2>/dev/null; then |
434 |
++ debug "btrfs volume $UUID mounted" |
435 |
++ else |
436 |
++ warn "cannot mount btrfs volume $UUID, exiting" |
437 |
++ rmdir "$tmpmnt" || true |
438 |
++ exit 1 |
439 |
++ fi |
440 |
++ # besides regular subvols, get ro and snapshot so thet can be excluded |
441 |
++ subvols=$(btrfs subvolume list "$tmpmnt" | cut -d ' ' -f 9) |
442 |
++ rosubvols=$(btrfs subvolume list -r "$tmpmnt" | cut -d ' ' -f 9) |
443 |
++ sssubvols=$(btrfs subvolume list -s "$tmpmnt" | cut -d ' ' -f 14) |
444 |
++ if ! umount "$tmpmnt"; then |
445 |
++ warn "failed to umount btrfs volume on $tmpmnt" |
446 |
++ rmdir "$tmpmnt" || true |
447 |
++ exit 1 |
448 |
++ fi |
449 |
++ |
450 |
++ found= |
451 |
++ mounted= |
452 |
++ |
453 |
++ mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | cut -d ' ' -f 5)" |
454 |
++ if [ -n "$mpoint" -a "x$mpoint" = "x/" ]; then |
455 |
++ debug "This is the root for the running system" #running system must be done elsewhere |
456 |
++ else |
457 |
++ #partition was not root of running system, so lets look for bootable subvols |
458 |
++ if [ -n "$mpoint" ] ; then |
459 |
++ mounted=1 #partition was already mounted,so lets not unmount it when done |
460 |
++ else |
461 |
++ # again, do not mount btrfs ro |
462 |
++ mount -t btrfs -U "$UUID" "$tmpmnt" |
463 |
++ mpoint="$tmpmnt" |
464 |
++ fi |
465 |
++ |
466 |
++ test="/usr/libexec/os-probes/mounted/90linux-distro" |
467 |
++ if [ -f "$test" ] && [ -x "$test" ]; then |
468 |
++ debug "running subtest $test" |
469 |
++ if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID"; then |
470 |
++ debug "os found by subtest $test on $partition" |
471 |
++ found=1 |
472 |
++ fi |
473 |
++ fi |
474 |
++ if [ -z "$mounted" ]; then |
475 |
++ if ! umount "$tmpmnt"; then |
476 |
++ warn "failed to umount $tmpmnt" |
477 |
++ fi |
478 |
++ fi |
479 |
++ fi |
480 |
++ found= |
481 |
++ # Always probe subvol or root set as default |
482 |
++ if probe_subvol "$defaultvol" "$partition" "$UUID" "$tmpmnt"; then |
483 |
++ found=1 |
484 |
++ fi |
485 |
++ |
486 |
++ # Probe any other OS on subvol |
487 |
++ for subvol in $subvols; do |
488 |
++ if echo "$rosubvols" | grep -q -x "$subvol" || |
489 |
++ echo "$sssubvols" | grep -q -x "$subvol" || |
490 |
++ echo "$defaultvol" | grep -q -x "$subvol"; then |
491 |
++ continue |
492 |
++ fi |
493 |
++ debug "begin btrfs processing for $UUID subvol=$subvol" |
494 |
++ if probe_subvol "$subvol" "$partition" "$UUID" "$tmpmnt"; then |
495 |
++ found=1 |
496 |
++ fi |
497 |
++ done |
498 |
++ rmdir "$tmpmnt" || true |
499 |
++ if [ "$found" ]; then |
500 |
++ exit 0 |
501 |
++ else |
502 |
++ exit 1 |
503 |
++ fi |
504 |
++fi |
505 |
++ |
506 |
+ if type grub-mount >/dev/null 2>&1 && \ |
507 |
+ type grub-probe >/dev/null 2>&1 && \ |
508 |
+ grub-mount "$partition" "$tmpmnt" 2>/dev/null; then |
509 |
+--- a/os-probes/mounted/common/90linux-distro |
510 |
++++ b/os-probes/mounted/common/90linux-distro |
511 |
+@@ -7,6 +7,8 @@ |
512 |
+ partition="$1" |
513 |
+ dir="$2" |
514 |
+ type="$3" |
515 |
++uuid="$4" |
516 |
++subvol="$5" |
517 |
+ |
518 |
+ # This test is inaccurate, but given separate / and /boot partitions and the |
519 |
+ # fact that only some architectures have ld-linux.so, I can't see anything |
520 |
+@@ -143,7 +145,11 @@ |
521 |
+ fi |
522 |
+ |
523 |
+ label="$(count_next_label "$short")" |
524 |
+- result "$partition:$long:$label:linux" |
525 |
++ if [ "x$type" = "xbtrfs" -a "x$uuid" != "x" -a "x$subvol" != "x" ]; then |
526 |
++ result "$partition:$long:$label:linux:$type:$uuid:$subvol" |
527 |
++ else |
528 |
++ result "$partition:$long:$label:linux" |
529 |
++ fi |
530 |
+ exit 0 |
531 |
+ else |
532 |
+ exit 1 |
533 |
|
534 |
diff --git a/sys-boot/os-prober/os-prober-9999.ebuild b/sys-boot/os-prober/os-prober-9999.ebuild |
535 |
index 4feb1e2b320..5bd9e3b714c 100644 |
536 |
--- a/sys-boot/os-prober/os-prober-9999.ebuild |
537 |
+++ b/sys-boot/os-prober/os-prober-9999.ebuild |
538 |
@@ -27,7 +27,7 @@ QA_MULTILIB_PATHS="usr/lib/os-prober/.*" |
539 |
|
540 |
PATCHES=( |
541 |
"${FILESDIR}"/${PN}-1.79-mdraid-detection.patch |
542 |
- "${FILESDIR}"/${PN}-1.78-btrfsfix.patch |
543 |
+ "${FILESDIR}"/${PN}-1.79-btrfs-subvolume-detection.patch |
544 |
) |
545 |
|
546 |
DOC_CONTENTS=" |