From 72fcfbeaf426f128db816990078cb1608ca86521 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 25 Nov 2004 10:03:19 +0000 Subject: more intelligent sort of fstab to handle loopback files or bind directory (bug anthil #1198) --- perl-install/fs.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'perl-install') diff --git a/perl-install/fs.pm b/perl-install/fs.pm index ea5bc8222..47b290fd5 100644 --- a/perl-install/fs.pm +++ b/perl-install/fs.pm @@ -167,7 +167,7 @@ sub subpart_from_wild_device_name { } return \%part; } elsif ($dev =~ m!^/! && -f "$::prefix$dev") { - #- loopback file + #- loopback file or directory to bind } else { log::l("part_from_wild_device_name: unknown device $dev"); } @@ -307,13 +307,32 @@ sub prepare_write_fstab { $fs_type = 'auto' if $fs_type =~ /:/; } - [ $mntpoint, $_->{comment} . join(' ', $dev, $mntpoint, $fs_type, $options || 'defaults', $freq, $passno) . "\n" ]; + my $file_dep = $options =~ /\b(loop|bind)\b/ ? $dev : ''; + + [ $file_dep, $mntpoint, $_->{comment} . join(' ', $dev, $mntpoint, $fs_type, $options || 'defaults', $freq, $passno) . "\n" ]; } else { (); } } grep { $_->{device} && ($_->{mntpoint} || $_->{real_mntpoint}) && $_->{fs_type} && ($_->{isFormatted} || !$_->{notFormatted}) } @$fstab; - join('', map { $_->[1] } sort { $a->[0] cmp $b->[0] } @l), \@smb_credentials; + sub sort_it { + my (@l) = @_; + + if (my $file_based = find { $_->[0] } @l) { + my ($before, $other) = partition { $file_based->[0] =~ /^\Q$_->[1]/ } @l; + $file_based->[0] = ''; #- all dependencies are now in before + if (@$other && @$before) { + sort_it(@$before), sort_it(@$other); + } else { + sort_it(@l); + } + } else { + sort { $a->[1] cmp $b->[1] } @l; + } + } + @l = sort_it(@l); + + join('', map { $_->[2] } @l), \@smb_credentials; } sub fstab_to_string { -- cgit v1.2.1