Changed the IDE standby timeout to use a slider, thanks to Jean-Christophe Dubois.
---- Changes since 1.390 ----
Changed the module's main page so that it only lists disks, with links to a separate page for showing the partitions.
+Re-wrote all code to use the new Webmin user interface library, for a more consistent look.
print "<b>$text{'disk_none'}</b><p>\n";
}
print &ui_links_row(\@edlinks);
-print "<p>\n";
+
+# Buttons for IDE params and SMART
+print "<hr>\n";
+print &ui_buttons_start();
+if (&supports_hdparm($d)) {
+ print &ui_buttons_row("edit_hdparm.cgi", $text{'index_hdparm'},
+ $text{'index_hdparmdesc'},
+ &ui_hidden("disk", $d->{'index'}));
+ }
+if (&supports_smart($d)) {
+ print &ui_buttons_row("../smart-status/index.cgi", $text{'index_smart'},
+ $text{'index_smartdesc'},
+ &ui_hidden("drive", $d->{'device'}));
+ }
+print &ui_buttons_end();
&ui_print_footer("", $text{'index_return'});
sub tunefs_options
{
if ($_[0] eq "ext2" || $_[0] eq "ext3") {
+ # Gaps between checks
&opt_input("tunefs_c", "", 1);
- print "<td align=right><b>$text{'tunefs_e'}</b></td> <td>\n";
- print "<input type=radio name=tunefs_e_def value=1 checked> ",
- "$text{'opt_default'}\n";
- print " <input type=radio name=tunefs_e_def value=0>\n";
- print "<select name=tunefs_e>\n";
- print "<option value=continue> $text{'tunefs_continue'}\n";
- print "<option value=remount-ro> $text{'tunefs_remount'}\n";
- print "<option value=panic> $text{'tunefs_panic'}\n";
- print "</select></td> </tr>\n";
+ # Action on error
+ print &ui_table_row($text{'tunefs_e'},
+ &ui_radio("tunefs_e_def", 1,
+ [ [ 1, $text{'opt_default'} ],
+ [ 0, &ui_select("tunefs_e", undef,
+ [ [ "continue", $text{'tunefs_continue'} ],
+ [ "remount-ro", $text{'tunefs_remount'} ],
+ [ "panic", $text{'tunefs_panic'} ] ]) ] ]));
- print "<tr> <td align=right><b>$text{'tunefs_u'}</b></td> <td>\n";
- print "<input type=radio name=tunefs_u_def value=1 checked> ",
- "$text{'opt_default'}\n";
- print " <input type=radio name=tunefs_u_def value=0>\n";
- print "<input name=tunefs_u size=8> ",
- &user_chooser_button("tunefs_u", 0),"</td>\n";
+ # Reserved user
+ print &ui_table_row($text{'tunefs_u'},
+ &ui_opt_textbox("tunefs_u", undef, 13, $text{'opt_default'})." ".
+ &user_chooser_button("tunefs_u", 0));
- print "<td align=right><b>$text{'tunefs_g'}</b></td> <td>\n";
- print "<input type=radio name=tunefs_g_def value=1 checked> ",
- "$text{'opt_default'}\n";
- print " <input type=radio name=tunefs_g_def value=0>\n";
- print "<input name=tunefs_g size=8> ",
- &group_chooser_button("tunefs_g", 0),"</td> </tr>\n";
+ # Reserved group
+ print &ui_table_row($text{'tunefs_g'},
+ &ui_opt_textbox("tunefs_g", undef, 13, $text{'opt_default'})." ".
+ &group_chooser_button("tunefs_g", 0));
+ # Reserved blocks
&opt_input("tunefs_m", "%", 1);
- $tsel = "<select name=tunefs_i_unit>\n".
- "<option value=d> $text{'tunefs_days'}\n".
- "<option value=w> $text{'tunefs_weeks'}\n".
- "<option value=m> $text{'tunefs_months'}\n".
- "</select>\n";
+
+ # Time between checks
+ $tsel = &ui_select("tunefs_i_unit", undef,
+ [ [ "d", $text{'tunefs_days'} ],
+ [ "w", $text{'tunefs_weeks'} ],
+ [ "m", $text{'tunefs_months'} ] ]);
&opt_input("tunefs_i", $tsel, 0);
}
}
}
return 0;
}
+
+# supports_hdparm(&disk)
+sub supports_hdparm
+{
+local ($d) = @_;
+return $d->{'type'} eq 'ide' || $d->{'type'} eq 'scsi' && $d->{'model'} =~ /ATA/;
+}
+
+# supports_smart(&disk)
+sub supports_smart
+{
+return &foreign_installed("smart-status") &&
+ &foreign_available("smart-status");
+}
+
&can_edit_disk($in{'dev'}) || &error($text{'fsck_ecannot'});
&ui_print_unbuffered_header(undef, $text{'fsck_title'}, "");
+$cmd = &fsck_command($in{'type'}, $in{'dev'});
print "<b>",&text('fsck_exec', "<tt>$cmd</tt>"),"</b>\n";
print "<pre>\n";
&foreign_call("proc", "safe_process_exec_logged",
- $in{'cmd'}, 0, 0, STDOUT, undef, 1);
+ $cmd, 0, 0, STDOUT, undef, 1);
print "</pre>\n";
print "<b>... ",&fsck_error($?/256),"</b><p>\n";
&webmin_log("fsck", undef, $in{'dev'}, \%in);
$cmd = &fsck_command($stat[1], $in{dev});
print &text('fsck_desc2', "<tt>$cmd</tt>", "<tt>fsck</tt>"),"<p>\n";
-print "<form action=fsck.cgi>\n";
-print "<input type=hidden name=cmd value=\"$cmd\">\n";
-print "<input type=hidden name=dev value=\"$in{'dev'}\">\n";
-print "<input type=hidden name=type value=\"$in{'type'}\">\n";
-print "<center><input type=submit value=\"$text{'fsck_repair'}\"></center>\n";
-print "</form>\n";
+print &ui_form_start("fsck.cgi");
+print &ui_hidden("dev", $in{'dev'});
+print &ui_hidden("type", $stat[1]);
+print &ui_form_end([ [ undef, $text{'fsck_repair'} ] ]);
&ui_print_footer("", $text{'index_return'});
require './fdisk-lib.pl';
&error_setup($text{'index_err'});
&check_fdisk();
+
+# Work out which disks are accessible
+@disks = &list_disks_partitions();
+@disks = grep { $access{'view'} || &can_edit_disk($_->{'device'}) } @disks;
+if (@disks == 1 && &can_edit_disk($disks[0]->{'device'})) {
+ # Just one .. go direct to it's page
+ &redirect("edit_disk.cgi?device=$disks[0]->{'device'}");
+ edit;
+ }
+
&ui_print_header(undef, $module_info{'desc'}, "", undef, 0, 1, 0,
&help_search_link("fdisk", "man", "doc", "howto"));
$extwidth = 250;
# Show a table of just disks
-$smart = &foreign_installed("smart-status") &&
- &foreign_available("smart-status");
-@disks = &list_disks_partitions();
-@disks = grep { $access{'view'} || &can_edit_disk($_->{'device'}) } @disks;
@disks = sort { $a->{'device'} cmp $b->{'device'} } @disks;
if (@disks) {
($hasctrl) = grep { defined($d->{'scsiid'}) ||
$text{'index_dacts'} ]);
foreach $d (@disks) {
$ed = &can_edit_disk($d->{'device'});
+ $smart = &supports_smart($d);
@links = ( );
@ctrl = ( );
if (defined($d->{'scsiid'}) && defined($d->{'controller'})) {
if ($d->{'raid'}) {
push(@ctrl, &text('index_draid', $d->{'raid'}));
}
- if (($d->{'type'} eq 'ide' ||
- $d->{'type'} eq 'scsi' && $d->{'model'} =~ /ATA/) && $ed) {
+ if ($ed && &supports_hdparm($d)) {
# Display link to IDE params form
push(@links, "<a href='edit_hdparm.cgi?".
"disk=$d->{'index'}'>$text{'index_dhdparm'}</a>");
}
- if ($smart) {
+ if (&supports_smart($d)) {
# Display link to smart module
push(@links, "<a href='../smart-status/index.cgi?".
"drive=$d->{'device'}'>$text{'index_dsmart'}</a>");
index_addpri=Add primary partition.
index_addlog=Add logical partition.
index_addext=Add extended partition.
-index_hdparm=Edit IDE parameters.
-index_smart=Show SMART status.
+index_hdparm=Edit IDE parameters
+index_hdparmdesc=Change settings for an IDE drive, such as the DMA mode, standby timeout and number of sectors read.
+index_smart=Show SMART status
+index_smartdesc=Displays the status reported by this drive, including temperature and error rates.
index_use=Use
index_free=Free
index_return=disk list
&ui_print_header(undef, $text{'tunefs_title'}, "");
&ReadParse();
-print "<form action=tunefs.cgi>\n";
-print "<input type=hidden name=dev value=\"$in{dev}\">\n";
-print "<input type=hidden name=type value=\"$in{type}\">\n";
-
@stat = &device_status($in{dev});
print &text('tunefs_desc', &fstype_name($in{type}), "<tt>$in{dev}</tt>",
"<tt>$stat[1]</tt>"),"<p>\n";
-print "<table border>\n";
-print "<tr $tb><td><b>$text{'tunefs_params'}</b></td> </tr>\n";
-print "<tr $cb><td><table cellpadding=5>\n";
+print &ui_form_start("tunefs.cgi");
+print &ui_hidden("dev", $in{'dev'});
+print &ui_hidden("type", $in{'type'});
+print &ui_table_start($text{'tunefs_params'}, "width=100%", 4);
&tunefs_options($in{type});
-print "</table></td></tr></table><br>\n";
-
-print "<input type=submit value=\"$text{'tunefs_tune'}\"></form>\n";
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'tunefs_tune'} ] ]);
&ui_print_footer("", $text{'index_return'});