blob: 72f1c4ceec3795c240058dd58fb7ffc8d0ad95ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/usr/bin/perl
#
# Main author Pascal Rigaux (pixel)
# Put together by Guillaume Cottenceau
#
# Copyright 1999-2005 Mandriva
#
# This software may be freely redistributed under the terms of the GNU
# public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Detects partition types using signatures
#
use lib qw(/usr/lib/libDrakX);
use common;
use fs::type;
use fs::proc_partitions;
my $params = join '', @ARGV;
my $verbose = $params =~ /-v/;
$params =~ /-h/ and die "usage: lsparts [-v]\n";
foreach (fs::proc_partitions::read_raw()) {
if (my $err = $_->{size} <= 1 ?
"Skipping <$_->{dev}> because too little blocks ($_->{size})" :
$_->{dev} !~ /\d$/ ?
"Skipping <$_->{dev}> because doesn't end with a number (e.g. seems to not be a partition)" :
$_->{dev} =~ /^loop\d+$/ ?
"Skipping <$_->{dev}>" :
'') {
print STDERR "$err\n" if $verbose;
} else {
$_->{device} = $_->{dev};
local $::isStandalone = 1; # silent run_program
if (my $type = fs::type::type_subpart_from_magic($_)) {
printf "$_->{dev}: %6s, fs %s (%s) [%s] (%s sectors)\n", formatXiB($_->{size} * 1024), $type->{fs_type}, fs::type::part2type_name($type), $type->{device_LABEL}, $_->{size};
}
}
}
|