diff options
-rwxr-xr-x | transfugdrake | 21 | ||||
-rw-r--r-- | transfugdrake.pm | 73 |
2 files changed, 47 insertions, 47 deletions
diff --git a/transfugdrake b/transfugdrake index 9dc3bd6..8e0ea74 100755 --- a/transfugdrake +++ b/transfugdrake @@ -77,30 +77,17 @@ $::Wizard_no_previous = 1; step_0: if($debug) { print "- Starting Transfugdrake\n"; } -my %windows_config = get_windows_config(); -my %linux_config = get_linux_config(); +#my %linux_config = transfugdrake::get_linux_config(); $::direct or $in->ask_okcancel(_("Transfugdrake"), _("Welcome to Transfugdrake! I will help you to ease the step windows-linux by migrating your documents, mails and address books"), 1) or quit_global($in, 0); #- ********************************** -#- * 1st step: Which partition do we use? +#- * 1st step: Windows configuration step_1: -# Detect windows partitions -if($debug) { print "- Detecting Partitions\n"; } -my @mnt_win_folder = detect_partition(); - -# If we have only one partition, goto the user chooser page -if(@mnt_win_folder[1] eq "") { goto step_2; } - -my $chosen_partition = $in->ask_from_list_(_("Select your windows partition"), - _("Please specify your windows partition from the following list"), - [ @mnt_win_folder ], - @mnt_win_folder[0]) or - quit_global($in, 0); - -if($debug) { print "-- Chosen Partition = $chosen_partition"; } +if($debug) { print "-Getting Windows Configuration\n"; } +my %windows_config = transfugdrake::get_windows_config($in); #- ********************************** #- * 2nd step: Windows User Chooser diff --git a/transfugdrake.pm b/transfugdrake.pm index eccec52..1027186 100644 --- a/transfugdrake.pm +++ b/transfugdrake.pm @@ -13,39 +13,41 @@ sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\ # From pixel and gc sub typeFromMagic { my $f = shift; - local *F; sysopen F, $f, 0 or return; - my $tmp; + my @partitions_signatures = ( + # [ 0x8e, 0, "HM\1\0" ], + # [ 0x83, 0x438, "\x53\xEF" ], + #[ 0x183, 0x10034, "ReIsErFs" ], + #[ 0x183, 0x10034, "ReIsEr2Fs" ], + #[ 0x283, 0, 'XFSB', 0x200, 'XAGF', 0x400, 'XAGI' ], + #[ 0x383, 0x8000, 'JFS1' ], + #[ 0x82, 4086, "SWAP-SPACE" ], + #[ 0x82, 4086, "SWAPSPACE2" ], + [ 0x7, 0x1FE, "\x55\xAA", 0x3, "NTFS" ], + [ 0xc, 0x1FE, "\x55\xAA", 0x52, "FAT32" ], + arch() !~ /^sparc/ ? ( [ 0x6, 0x1FE, "\x55\xAA", 0x36, "FAT" ],) : (), + ); + + local *F; + sysopen F, $f, 0 or return; + M: foreach (@partitions_signatures) { my ($name, @l) = @$_; + while (@l) { my ($offset, $signature) = splice(@l, 0, 2); sysseek(F, $offset, 0) or next M; sysread(F, $tmp, length $signature); - $tmp eq $signature or next M; + if($tmp ne $signature) { next M; } } - return $name; + return $name; } return -1; } sub get_windows_partition { - my $in = $_; + my $in = $_[0]; - my @partitions_signatures = ( - [ 0x8e, 0, "HM\1\0" ], - [ 0x83, 0x438, "\x53\xEF" ], - [ 0x183, 0x10034, "ReIsErFs" ], - [ 0x183, 0x10034, "ReIsEr2Fs" ], - [ 0x283, 0, 'XFSB', 0x200, 'XAGF', 0x400, 'XAGI' ], - [ 0x383, 0x8000, 'JFS1' ], - [ 0x82, 4086, "SWAP-SPACE" ], - [ 0x82, 4086, "SWAPSPACE2" ], - [ 0x7, 0x1FE, "\x55\xAA", 0x3, "NTFS" ], - [ 0xc, 0x1FE, "\x55\xAA", 0x52, "FAT32" ], - arch() !~ /^sparc/ ? ( [ 0x6, 0x1FE, "\x55\xAA", 0x36, "FAT" ],) : (), - ); - my %type2name = ( 0x1 => 'DOS 12-bit FAT', 0x4 => 'DOS 16-bit FAT (up to 32M)', @@ -68,27 +70,34 @@ sub get_windows_partition { ); my (undef, undef, @parts) = cat_('/proc/partitions'); - my %fat_parts; + my @fat_parts; + my $i = 0; P: foreach (@parts) { my (undef, undef, $blocks, $dev) = split or next; - my %skip_conditions = ( + + my %skip_conditions = ( "Skipping <$dev> because too little blocks ($blocks)" => ($blocks <= 1), "Skipping <$dev> because doesn't end with a number (e.g. seems to not be a partition)" => ($dev !~ /\d$/), ); $skip_conditions{$_} and ($verbose and print(STDERR $_, "\n")), next P foreach keys %skip_conditions; my $type = typeFromMagic("/dev/$dev"); - if($type eq "NTFS" || $type eq "FAT32" || $type eq "FAT") { - # printf "$dev: type <0x%0x> (%s)\n", $type, $type2name{$type}; - $fat_parts->{$dev} = $type; + + if($type2name{$type} =~ /NTFS/ || $type2name{$type} =~ /FAT32/ || $type2name{$type} =~ /FAT/) { + printf "$dev: type <0x%0x> (%s)\n", $type, $type2name{$type}; + $fat_parts[$i] = "$dev ($type2name{$type})"; + $i++; } } - return $in->ask_from_list_(_("Select your windows partition"), - _("Please specify your windows partition from the following list"), - [ %fat_parts ], - $fat_parts->{$dev}) - or quit_global($in, 0); + my $win_part = $in->ask_from_list_(_("Select your windows partition"), + _("Please specify your windows partition from the following list"), + [ @fat_parts ], + $fat_parts[0]) + or quit_global($in, 0); + if($fat_parts[1] eq "") { $in->ask_warn(_("Your Windows Partition"), _("$fat_parts[0] is your Windows partition")); } + + return $win_part; } sub get_windows_version { @@ -97,8 +106,12 @@ sub get_windows_version { sub get_windows_config { my %config; - $config->{'partitions'} = get_windows_partition(); + my $in = $_[0]; + + $config->{'partitions'} = get_windows_partition($in); + print $config->{'partitions'} . '\n'; } sub get_linux_config { } +1; |