updated git and svn scripts
[xrzperl.git] / diskimg-fstype
blob733d8c82774ecca23fc697a631c24b4a66be5d51
1 #!/usr/bin/perl -w
2 ###APPNAME: diskimg-fstype
3 ###APPAUTHOR: root
4 ###APPDATE: Sun Oct 7 01:36:57 2007
5 ###APPVER: 0.1
6 ###APPDESC: check fstype for partition of disk image.
7 ###APPUSAGE: (disk image file) (partition NUM)
8 ###APPEXAMPLE: diskimg-fstype disk.img 1
9 ###APPOPTION:
10 use strict;
11 $ARGV[0]="-h" unless(@ARGV);
12 foreach(@ARGV){
13 exit(system("plhelp",$0,@ARGV)) if($_ eq "-h" || $_ eq "--help");
15 my $disk=shift;
16 my $num=shift;
18 die("File not exists\n") unless(-f $disk);
19 $num=1 unless($num);
21 my $name=$disk;
23 my %fstype=(
24 "1"=>"vfat",
25 "83"=>"ext2",
26 "82"=>"swap",
27 "4"=>"msdos",
28 "5"=>"",
29 "6"=>"msdos",
30 "b"=>"vfat",
31 "c"=>"vfat",
34 open(TABLE,"/sbin/fdisk -ul $disk 2>/dev/null |") or die("$!\n");
36 while(<TABLE>) {
37 if(m{$name$num\s+\*?\s+(\d+)\s+(\d+)\s+(\d+)\s+([a-z0-9]+)\s+([a-zA-z0-9]+)$}) {
38 print $fstype{$4};
39 last;
42 close TABLE;