#!/usr/local/bin/perl # edit_hdparm.cgi # Edit an IDE parameters for some disk require './fdisk-lib.pl'; &ReadParse(); @dlist = &list_disks_partitions(); $d = $dlist[$in{'disk'}]; &can_edit_disk($d->{'device'}) || &error($text{'edit_ecannot'}); &ui_print_header(undef, $text{'hdparm_title'}, ""); if ( ! &has_command( "hdparm" ) ) { print "

$text{ 'edit_ehdparm' }

\n"; &ui_print_footer( "", $text{ 'index_return' } ); exit; } %hdparm = ( 'A', "1", 'K', "0", 'P', "0", 'X', "0", 'W', "0", 'S', "0" ); @yesno = ( "1", $text{ 'hdparm_on' }, "0", $text{ 'hdparm_off' } ); foreach $argument ( 'a', 'd', 'r', 'k', 'u', 'm', 'c' ) { $out = `hdparm -$argument $d->{'device'}`; if ($out =~ /\s+=\s+(\S+)/) { $hdparm{ $argument } = $1; } #( $_, $line ) = split( /=/, `hdparm -$argument $d->{'device'}` ); #$line =~ s/ {1,}//; #( $hdparm{ $argument } ) = split( / /, $line ); } print( " "); print( "

", "", "", "", "", "
", $d->{'desc'}," (",$d->{'device'}.") : ",$text{ 'hdparm_label' }, "
", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "
", &hlink( "". $text{ 'hdparm_conf_X' }. "", 'X' ), &p_select_wdl( "X", $hdparm{ 'X' }, ( "0", $text{ 'hdparm_conf_X_defaut' }, "1", $text{ 'hdparm_conf_X_disable' }, "9", "PIO mode 1", "10", "PIO mode 2", "11", "PIO mode 3", "12", "PIO mode 4", "32", "Multimode DMA 0", "33", "Multimode DMA 1", "34", "Multimode DMA 2", "64", "Ultra DMA 0", "65", "Ultra DMA 1", "66", "Ultra DMA 2" ) ), "", &l_radio( $text{ 'hdparm_conf_d' }, 'd', @yesno ), "
", &hlink( "". $text{ 'hdparm_conf_a' }. "", "a" ), " ", &p_entry( "a", 2, $hdparm{ 'a' } ), "", &l_radio( $text{ 'hdparm_conf_A' }, 'A', @yesno ), "
", &l_radio( $text{ 'hdparm_conf_W' }, 'W', @yesno ), "", &l_radio( $text{ 'hdparm_conf_u' }, 'u', @yesno ), "
", &l_radio( $text{ 'hdparm_conf_k' }, 'k', @yesno ), "", &l_radio( $text{ 'hdparm_conf_K' }, 'K', @yesno ), "
", &l_radio( $text{ 'hdparm_conf_r' }, 'r', @yesno ), "", &l_radio( $text{ 'hdparm_conf_P' }, 'P', @yesno ), "
", &hlink( "". $text{ 'hdparm_conf_S' }. "", "S" ), "", &p_slider( "S", 0, 251, 0), "
", "", "", "
", &l_radio( $text{ 'hdparm_conf_c' }, 'c', ( "0", $text{ 'hdparm_disable' }, "1", $text{ 'hdparm_enable' }, "3", $text{ 'hdparm_enable_special' } ) ), "
", &l_radio( $text{ 'hdparm_conf_m' }, 'm', ( "0", $text{ 'hdparm_disable' }, "2", "2", "4", "4", "8", "8", "16", "16", "32", "32" ) ), "
", "", "", "", "", "
" ); &ui_print_footer( "", $text{ 'index_return' } ); sub l_radio { my ( $label, $flag, @items ) = @_; return &hlink( "".$label."", $flag )." ". &p_radio( $flag, $hdparm{ $flag }, @items ); } sub p_radio { my ( $name, $checked, @list ) = @_; local $out, $size = @list, $i = 0; do { $out .= " "; $out .= ""; $out .= ""; return $out; } sub p_entry { my ( $name, $size, $value ) = @_; $size ? return " " : return " "; } sub p_select_wdl { my ( $name, $selected, @list ) = @_; local $size = @list, $i = 0, $out = "