Handle hostnames with upper-case letters
[webmin.git] / fdisk / apply_hdparm.cgi
1 #!/usr/local/bin/perl
2
3 require "./fdisk-lib.pl";
4 &ReadParse();
5 &can_edit_disk($in{'drive'}) || &error($text{'edit_ecannot'});
6
7 if( $in{ 'action' } eq $text{ 'hdparm_apply' } ) 
8 {
9         &ui_print_header(undef,  $text{ 'hdparm_apply' }, "");
10
11         local $command = "hdparm ";
12         local $key;
13         foreach $key ( 'a', 'd', 'r', 'k', 'u', 'm', 'c', 'A', 'K', 'P', 'X', 'W', 'S' )
14         {
15                 $command .= "-".$key." ".$in{ $key }." " if( $in{ $key } ne "" );
16         }
17         $command .= $in{ 'drive' }."\n";
18
19         local $out = "<p>". $text{ 'hdparm_performing' }. " : <b>". $command. "</b><i>". &backquote_logged($command). "</i><p>";
20         $out =~ s/\n/<br>/g;
21         &webmin_log("hdparm", undef, $in{'drive'}, \%in);
22
23         print( $out );
24 } else {
25         &ui_print_header(undef,  $text{'hdparm_speed'}, "");
26
27         local ( $_, $_, $buffered, $buffer_cache ) = split( /\n/, `hdparm -t -T $in{ 'drive' }` );
28         ( $_, $buffered ) = split( /=/, $buffered );
29         ( $_, $buffer_cache ) = split( /=/, $buffer_cache );
30
31         print &ui_table_start($text{'hdparm_speedres'}, undef, 2,[ "width=30%" ]);
32         print &ui_table_row($text{'hdparm_buf1'}, $buffered);
33         print &ui_table_row($text{'hdparm_buf2'}, $buffer_cache);
34         print &ui_table_end();
35 }
36
37 &ui_print_footer( "", $text{ 'index_return' } );
38