summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-10-18 08:38:20 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-10-18 08:38:20 +0000
commit8f485f147fc9e6e42ab4f3dd1c3a19461c1f9694 (patch)
treee2680eaf2d1452c2af48834010be83d0e3b03c28
parentfd1828130f2a8f64f6ee63e0070246122327338e (diff)
downloaddrakx-8f485f147fc9e6e42ab4f3dd1c3a19461c1f9694.tar
drakx-8f485f147fc9e6e42ab4f3dd1c3a19461c1f9694.tar.gz
drakx-8f485f147fc9e6e42ab4f3dd1c3a19461c1f9694.tar.bz2
drakx-8f485f147fc9e6e42ab4f3dd1c3a19461c1f9694.tar.xz
drakx-8f485f147fc9e6e42ab4f3dd1c3a19461c1f9694.zip
use vol_id to find device type (fs_type and pt_type)
-rw-r--r--perl-install/c/Makefile.PL2
-rw-r--r--perl-install/c/stuff.xs.pl21
-rw-r--r--perl-install/fs/type.pm74
-rw-r--r--perl-install/fsedit.pm8
4 files changed, 34 insertions, 71 deletions
diff --git a/perl-install/c/Makefile.PL b/perl-install/c/Makefile.PL
index ced83836b..0b7b349a1 100644
--- a/perl-install/c/Makefile.PL
+++ b/perl-install/c/Makefile.PL
@@ -6,7 +6,7 @@ use Config;
my $lib = arch() =~ /x86_64/ ? 'lib64' : 'lib';
-my $libs = '-lldetect -lext2fs';
+my $libs = '-lldetect';
my $pcmcia_dir = $Config{archname} =~ /i.86/ ? '../../mdk-stage1/pcmcia_' : '';
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index 5cf4b3801..4830ae8e0 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -48,10 +48,6 @@ typedef __uint8_t u8;
#include <linux/ethtool.h>
-/* for is_ext3 */
-#include <ext2fs/ext2_fs.h>
-#include <ext2fs/ext2fs.h>
-
// for UPS on USB:
# define HID_MAX_USAGES 1024
#include <linux/hiddev.h>
@@ -202,23 +198,6 @@ is_secure_file(filename)
OUTPUT:
RETVAL
-int
-is_ext3(device_name)
- char * device_name
- CODE:
- {
- ext2_filsys fs;
- int retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs);
- if (retval) {
- RETVAL = 0;
- } else {
- RETVAL = fs->super->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL;
- ext2fs_close(fs);
- }
- }
- OUTPUT:
- RETVAL
-
void
init_setlocale()
CODE:
diff --git a/perl-install/fs/type.pm b/perl-install/fs/type.pm
index 5412eb1b8..807da7712 100644
--- a/perl-install/fs/type.pm
+++ b/perl-install/fs/type.pm
@@ -252,25 +252,6 @@ sub set_type_subpart {
}
}
-
-my @partitions_signatures = (
- (map { [ 'Linux Logical Volume Manager', 0x200 * $_ + 0x18, "LVM2" ] } 0 .. 3),
- [ 'Linux Logical Volume Manager', 0, "HM\1\0" ],
- [ 'ext2', 0x438, "\x53\xEF" ],
- [ 'reiserfs', 0x10034, "ReIsErFs" ],
- [ 'reiserfs', 0x10034, "ReIsEr2Fs" ],
- [ 'xfs', 0, 'XFSB', 0x200, 'XAGF', 0x400, 'XAGI' ],
- [ 'jfs', 0x8000, 'JFS1' ],
- [ 'swap', 4086, "SWAP-SPACE" ],
- [ 'swap', 4086, "SWAPSPACE2" ],
- [ 'ntfs', 0x1FE, "\x55\xAA", 0x3, "NTFS" ],
- [ 'FAT32', 0x1FE, "\x55\xAA", 0x52, "FAT32" ],
-if_(arch() !~ /^sparc/,
- [ 'FAT16', 0x1FE, "\x55\xAA", 0x36, "FAT" ],
- [ 'iso9660', 0x8001, "CD001" ],
-),
-);
-
sub fs_type_from_magic {
my ($part) = @_;
if (exists $part->{fs_type_from_magic}) {
@@ -281,33 +262,38 @@ sub fs_type_from_magic {
}
}
+sub call_vol_id {
+ my ($part) = @_;
+
+ my %h = map {
+ if_(/(.*?)=(.*)/, $1 => $2);
+ } run_program::get_stdout('vol_id', devices::make($part->{device}));
+
+ \%h;
+}
+
sub type_subpart_from_magic {
my ($part) = @_;
- my $dev = devices::make($part->{device});
-
- my $check_md = sub {
- my ($F) = @_;
- my $MD_RESERVED_SECTORS = 128;
- my $sector = round_down($part->{size}, $MD_RESERVED_SECTORS) - $MD_RESERVED_SECTORS; #- MD_NEW_SIZE_SECTORS($part->{size})
- if (c::lseek_sector(fileno $F, $sector, 0)) {
- my $tmp;
- my $signature = "\xfc\x4e\x2b\xa9";
- sysread($F, $tmp, length $signature);
- $tmp eq $signature and return "Linux RAID";
- }
- '';
- };
- my $t = typeFromMagic($dev,
- if_($part->{size}, $check_md),
- @partitions_signatures) or return;
-
- my $p = type_name2subpart($t) || fs_type2subpart($t) || internal_error("unknown name/fs $t");
- if ($p->{fs_type} eq 'ext2') {
- #- there is no magic to differentiate ext3 and ext2. Using libext2fs
- #- to check if it has a journal
- $p->{fs_type} = 'ext3' if c::is_ext3($dev);
+ my $ids = call_vol_id($part);
+
+ $part->{LABEL_from_magic} = $ids->{ID_FS_LABEL_SAFE} if $ids->{ID_FS_LABEL_SAFE};
+
+ my $p;
+ if ($ids->{ID_FS_USAGE} eq 'raid') {
+ my $name = {
+ linux_raid_member => "Linux RAID",
+ LVM1_member => 'Linux Logical Volume Manager',
+ LVM2_member => 'Linux Logical Volume Manager',
+ }->{$ids->{ID_FS_TYPE}};
+
+ $p = type_name2subpart($name) if $name;
+ } elsif ($ids->{ID_FS_TYPE}) {
+ $p = fs_type2subpart($ids->{ID_FS_TYPE}) or log::l("unknown filesystem $ids->{ID_FS_TYPE} returned by vol_id");
+ }
+
+ if ($p) {
+ $part->{fs_type_from_magic} = $p->{fs_type};
}
- $part->{fs_type_from_magic} = $p->{fs_type};
$p;
}
@@ -390,3 +376,5 @@ sub carry_root_loopback {
my ($part) = @_;
any { $_->{mntpoint} eq '/' } @{$part->{loopback} || []};
}
+
+1;
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index c06944a13..7c968e915 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -237,7 +237,7 @@ Do you agree to lose all the partitions?
my @parts = partition_table::get_normal_parts($hd);
# checking the magic of the filesystem, do not rely on pt_type
- foreach (grep { member($_->{fs_type}, 'vfat', 'ntfs', 'ext2') || $_->{pt_type} == 0x100 } @parts) {
+ foreach (@parts) {
if (my $type = fs::type::type_subpart_from_magic($_)) {
if ($type->{fs_type}) {
#- keep {pt_type}
@@ -248,11 +248,7 @@ Do you agree to lose all the partitions?
} else {
$_->{bad_fs_type_magic} = 1;
}
- }
-
- foreach (@parts) {
- my $label = run_program::get_stdout('vol_id', '-l', devices::make($_->{device}));
- $_->{device_LABEL} = chomp_($label) if $label;
+ $_->{device_LABEL} = $_->{LABEL_from_magic} if $_->{LABEL_from_magic};
}
if ($hd->{usb_media_type}) {