diff options
author | carlosgc <carlosgc> | 2004-11-05 17:03:26 +0000 |
---|---|---|
committer | carlosgc <carlosgc> | 2004-11-05 17:03:26 +0000 |
commit | 3e5afdee8079fa8b7cdb03aed894c214bb59fde8 (patch) | |
tree | dad844d43b3145a10143653126d8478a0bfb11e5 | |
parent | e4b4e3de8b08d9e720bf889edd10cf090e3c4d3e (diff) |
2004-11-05 Carlos Garcia Campos <carlosgc@gnome.org>
* disks-conf.in, partition.pl.in: added DVD support
-rw-r--r-- | ChangeLog | 4 | ||||
-rwxr-xr-x | disks-conf.in | 120 | ||||
-rw-r--r-- | partition.pl.in | 109 |
3 files changed, 194 insertions, 39 deletions
@@ -1,3 +1,7 @@ +2004-11-05 Carlos Garcia Campos <carlosgc@gnome.org> + + * disks-conf.in, partition.pl.in: added DVD support + 2004-11-05 Link Dupont <link.dupont@gmail.com> * platform.pl.in: Added archlinux to the list diff --git a/disks-conf.in b/disks-conf.in index 9dca42d..cce72ec 100755 --- a/disks-conf.in +++ b/disks-conf.in @@ -853,51 +853,77 @@ sub get_fs_type my ($filesys); # if mounted get fs - $line = `mount | grep "$device"`; - if ($line ne "") { + if (&gst_partition_is_mounted ($device)) + { + #$line = `mount | grep "$device"`; + #if ($line ne "") { # already mounted ($filesys) = $line =~ /^$device on .* type (.*) .*$/; - if ($filesys) { + if ($filesys) + { return $filesys; - } else { + } + else + { return "unknown"; } } # Not already mounted # Try to mount it - my ($dev) = ($device =~ /\/dev\/(.*)/); - my $point = "/tmp/disks-conf-$dev"; + my $ret = &gst_partition_mount_temp ($device); + + #my ($dev) = ($device =~ /\/dev\/(.*)/); + #my $point = "/tmp/disks-conf-$dev"; - mkdir ($point); + #mkdir ($point); - $cmd = "mount $device $point"; + #$cmd = "mount $device $point"; - $fd = &gst_file_run_pipe_read_with_stderr ($cmd); + #$fd = &gst_file_run_pipe_read_with_stderr ($cmd); - if (!$fd) { - my $err = `umount $device`; - rmdir ($point); - return "unknown"; - } + #if (!$fd) { + # my $err = `umount $device`; + #rmdir ($point); + #return "unknown"; + #} # Not mounted: not supported or unformatted - while (<$fd>) { - if (/not supported/) { - ($filesys) = ($_ =~ /^mount: fs type (.*) not supported by kernel$/); - } elsif (/looks like swapspace/) { - $filesys = "swap"; - } elsif (/you must specify the filesystem type/) { - $filesys = "none"; - } - } - - &gst_file_close ($fd); - - if ($filesys) { - rmdir ($point); + #while (<$fd>) { + # if (/not supported/) { +# ($filesys) = ($_ =~ /^mount: fs type (.*) not supported by kernel$/); +# } elsif (/looks like swapspace/) { +# $filesys = "swap"; +# } elsif (/you must specify the filesystem type/) { +# $filesys = "none"; +# } +# } + +# &gst_file_close ($fd); + + if ($ret eq "error") + { + return "unknown"; + } + elsif ($ret =~ /not_supported/) + { + my ($msg) = ($ret =~ /^not_supported::(.*)/); + ($filesys) = ($msg =~ /^mount: fs type (.*) not supported by kernel$/); return $filesys; } + elsif ($ret eq "swap") + { + return "swap"; + } + elsif ($ret eq "none") + { + return "none"; + } + + #if ($filesys) { + # rmdir ($point); + #return $filesys; + #} # Mounted by me $line = `mount | grep "$device"`; @@ -905,8 +931,9 @@ sub get_fs_type ($filesys) = ($line =~ /^$device on .* type (.*) .*$/); } - my $err = `umount $device`; - rmdir ($point); + &gst_partition_umount_temp ($device, $ret); + #my $err = `umount $device`; + #rmdir ($point); if ($filesys) { return $filesys; @@ -1327,12 +1354,39 @@ sub get_cdrom_disc_info return; } + my ($mp, $umount); my $cdtype; my $disctype = ioctl (RD, $CDROM_DISC_STATUS, 0); if ($disctype eq $CDS_AUDIO) { - $cdtype = "audio"; - } elsif (($disctype eq $CDS_DATA_1) || ($disctype eq $CDS_DATA_2) || - ($disctype eq $CDS_XA_2_1) || ($disctype eq $CDS_XA_2_2)) { + $cdtype = "audio"; + } elsif ($disctype eq $CDS_DATA_1) { + # Chack if it's a DVD + if (! &gst_partition_is_mounted ($device)) { + $umount = 1; + $mp = &gst_partition_mount_temp ($device); + } else { + $umount = 0; + $mp = &gst_partition_get_mount_point ($device); + } + + if (($mp =~ /^\/.*$/) && (-d $mp)) { + my $audio_ts = "audio_ts"; + my $video_ts = "video_ts"; + if ((-d "$mp/$audio_ts") || (-d "$mp/$video_ts") || + (-d "$mp/" . uc ($audio_ts)) || (-d "$mp/" . uc ($video_ts))) { + $cdtype = "dvd"; + } else { + $cdtype = "data"; + } + } else { + $cdtype = "data"; + } + + if ($umount) { + &gst_partition_umount_temp ($device, $mp); + } + } elsif (($disctype eq $CDS_DATA_2) || ($disctype eq $CDS_XA_2_1) || + ($disctype eq $CDS_XA_2_2)) { $cdtype = "data"; } elsif ($disctype eq $CDS_MIXED) { $cdtype = "mixed"; diff --git a/partition.pl.in b/partition.pl.in index 4b8450c..92f4e59 100644 --- a/partition.pl.in +++ b/partition.pl.in @@ -555,7 +555,6 @@ sub get_fdisk # fs type #%parts->{'type'} = $type; %parts->{'type'} = &get_fs_type ($device); - #print ("DBG: tipo " . &get_fs_type ($device) . "\n"); push (@fdisk_hash, \%parts); } } @@ -649,28 +648,126 @@ sub get_fdisk } } +## Mount functions +sub gst_partition_is_mounted +{ + my ($device) = @_; + + my $line = `mount | grep "$device"`; + + if ($line ne "") + { + return 1; + } + else + { + return 0; + } +} + +sub gst_partition_get_mount_point +{ + my ($device) = @_; + + my ($point) = `mount | grep $device` =~ /^$device on (.*) type .*$/; + if ($point) + { + return $point; + } + else + { + return undef; + } +} + +sub gst_partition_mount_temp +{ + my ($device) = @_; + my ($filesys); + + my ($dev) = ($device =~ /\/dev\/(.*)/); + my $point = "/tmp/disks-conf-$dev"; + + mkdir ($point); + + $cmd = "mount $device $point"; + $fd = &gst_file_run_pipe_read_with_stderr ($cmd); + + if (!$fd) + { + my $err = `umount $device`; + rmdir ($point); + return "error"; + } + + # Not mounted: not supported or unformatted + while (<$fd>) + { + if (/not supported/) + { + #($filesys) = ($_ =~ /^mount: fs type (.*) not supported by kernel$/); + &gst_file_close ($fd); + rmdir ($point); + return "not_supported::$_"; + } + elsif (/looks like swapspace/) + { + #$filesys = "swap"; + &gst_file_close ($fd); + rmdir ($point); + return "swap"; + } + elsif (/you must specify the filesystem type/) + { + #$filesys = "none"; + &gst_file_close ($fd); + rmdir ($point); + return "none"; + } + } + + &gst_file_close ($fd); + + return $point; +} + +sub gst_partition_umount_temp +{ + my ($device, $point) = @_; + + my $err = `umount $device`; + rmdir ($point); +} + sub gst_format_partition { my ($command, $device, $type, $options) = @_; my ($cmd, $fd); - if ($type eq "reiserfs") { + if ($type eq "reiserfs") + { $options = "$options -f -f"; #-f specified twice, do not ask for confirmation - } elsif ($type eq "xfs") { + } + elsif ($type eq "xfs") + { $options = "$options -f"; - } elsif ($type eq "xfs") { + } + elsif ($type eq "xfs") + { $options = "$options -q"; } $cmd = "$command $device $options"; $fd = &gst_file_run_pipe_read_with_stderr ($cmd); - if (!$fd) { + if (!$fd) + { # TODO return; } - while (<$fd>) { + while (<$fd>) + { # print"DBG: $_\n"; } |