~ubuntu-branches/ubuntu/trusty/os-prober/trusty

« back to all changes in this revision

Viewing changes to linux-boot-probes/common/50mounted-tests

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-04-10 00:36:21 UTC
  • Revision ID: james.westby@ubuntu.com-20110410003621-q22v5zqanw1l7bm5
Tags: 1.44ubuntu1
* Cherry-pick from trunk:
  - Use grub-mount if it exists.  This lets us do true read-only mounts,
    and works better on journalling filesystems that were mounted
    uncleanly (LP: #683355).
  - Attempt to load the fuse module, to improve the chances of grub-mount
    working.
* Depend on grub-mount-udeb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        mkdir "$tmpmnt"
34
34
fi
35
35
 
36
 
for type in $types; do
 
36
mounted=
 
37
if which grub-mount >/dev/null 2>&1 && \
 
38
   grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
 
39
        mounted=1
 
40
        type=fuseblk
 
41
else
37
42
        ro_partition "$partition"
38
 
        if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
39
 
                linux_mount_boot "$partition" "$tmpmnt"
40
 
                bootpart="${mountboot%% *}"
41
 
                mounted="${mountboot#* }"
42
 
                
43
 
                for test in /usr/lib/linux-boot-probes/mounted/*; do
44
 
                        if [ -f "$test" ] && [ -x "$test" ]; then
45
 
                                debug "running $test $partition $bootpart $tmpmnt $type"
46
 
                                if $test "$partition" "$bootpart" "$tmpmnt" "$type"; then
47
 
                                        debug "$test succeeded"
48
 
                                        umount "$tmpmnt/boot" 2>/dev/null || true       
49
 
                                        if ! umount "$tmpmnt"; then
50
 
                                                warn "failed to umount $tmpmnt"
51
 
                                        fi
52
 
                                        rmdir "$tmpmnt" || true
53
 
                                        exit 0
 
43
        for type in $types; do
 
44
                if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
 
45
                        mounted=1
 
46
                        break
 
47
                fi
 
48
        done
 
49
fi
 
50
 
 
51
if [ "$mounted" ]; then
 
52
        linux_mount_boot "$partition" "$tmpmnt"
 
53
        bootpart="${mountboot%% *}"
 
54
        mounted="${mountboot#* }"
 
55
 
 
56
        for test in /usr/lib/linux-boot-probes/mounted/*; do
 
57
                if [ -f "$test" ] && [ -x "$test" ]; then
 
58
                        debug "running $test $partition $bootpart $tmpmnt $type"
 
59
                        if $test "$partition" "$bootpart" "$tmpmnt" "$type"; then
 
60
                                debug "$test succeeded"
 
61
                                umount "$tmpmnt/boot" 2>/dev/null || true       
 
62
                                if ! umount "$tmpmnt"; then
 
63
                                        warn "failed to umount $tmpmnt"
54
64
                                fi
 
65
                                rmdir "$tmpmnt" || true
 
66
                                exit 0
55
67
                        fi
56
 
                done
57
 
                
58
 
                umount "$tmpmnt/boot" 2>/dev/null || true       
59
 
                if ! umount "$tmpmnt"; then
60
 
                        warn "failed to umount $tmpmnt"
61
68
                fi
 
69
        done
62
70
 
63
 
                break
 
71
        umount "$tmpmnt/boot" 2>/dev/null || true       
 
72
        if ! umount "$tmpmnt"; then
 
73
                warn "failed to umount $tmpmnt"
64
74
        fi
65
 
done
 
75
fi
66
76
 
67
77
rmdir "$tmpmnt" || true
68
78