From cb2f72a0e2e5fe230bca2a4861aa95bda415a0ca Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 27 Jan 2010 14:12:40 -0800 Subject: [PATCH] Support for creating ext4 filesystems --- fdisk/CHANGELOG | 2 ++ fdisk/fdisk-lib.pl | 29 +++++++++++++++++------------ lvm/CHANGELOG | 2 ++ lvm/lvm-lib.pl | 2 +- raid/CHANGELOG | 2 ++ raid/mkfs.cgi | 2 +- raid/raid-lib.pl | 13 ++++++++++++- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/fdisk/CHANGELOG b/fdisk/CHANGELOG index de40d8517..5e9bc787b 100644 --- a/fdisk/CHANGELOG +++ b/fdisk/CHANGELOG @@ -23,3 +23,5 @@ Changed the module's main page so that it only lists disks, with links to a sepa Re-wrote all code to use the new Webmin user interface library, for a more consistent look. ---- Changes since 1.490 ---- Added support for new SCSI device information files under /sys, as seen in 2.6.30+ kernels. +---- Changes since 1.500 ---- +Added support for creating EXT4 filesystems. diff --git a/fdisk/fdisk-lib.pl b/fdisk/fdisk-lib.pl index 8211f197b..33a4ca7bc 100755 --- a/fdisk/fdisk-lib.pl +++ b/fdisk/fdisk-lib.pl @@ -572,7 +572,7 @@ local @rv; if ($_[0] eq "4" || $_[0] eq "6" || $_[0] eq "1" || $_[0] eq "e") { @rv = ( "msdos" ); } elsif ($_[0] eq "b" || $_[0] eq "c") { @rv = ( "vfat" ); } -elsif ($_[0] eq "83") { @rv = ( "ext3", "ext2" ); } +elsif ($_[0] eq "83") { @rv = ( "ext3", "ext4", "ext2" ); } elsif ($_[0] eq "82") { @rv = ( "swap" ); } elsif ($_[0] eq "81") { @rv = ( "minix" ); } else { return ( ); } @@ -630,7 +630,7 @@ elsif ($_[0] eq "reiserfs") { [ [ "", $text{'default'} ], [ "rupasov", "tea" ] ])); } -elsif ($_[0] eq "ext3") { +elsif ($_[0] =~ /^ext\d+$/) { &opt_input("ext2_b", $text{'bytes'}, 1); &opt_input("ext2_f", $text{'bytes'}, 0); &opt_input("ext2_i", "", 1); @@ -705,15 +705,19 @@ elsif ($_[0] eq "reiserfs") { $cmd .= " -h $in{'reiserfs_h'}" if ($in{'reiserfs_h'}); $cmd .= " $_[1]"; } -elsif ($_[0] eq "ext3") { - if (&has_command("mkfs.ext3")) { - $cmd = "mkfs -t ext3"; +elsif ($_[0] =~ /^ext\d+$/) { + if (&has_command("mkfs.$_[0]")) { + $cmd = "mkfs -t $_[0]"; $cmd .= &opt_check("ext3_j", '\d+', "-j"); } - elsif (&has_command("mke3fs")) { + elsif ($_[0] eq "ext3" && &has_command("mke3fs")) { $cmd = "mke3fs"; $cmd .= &opt_check("ext3_j", '\d+', "-j"); } + elsif ($_[0] eq "ext4" && &has_command("mke4fs")) { + $cmd = "mke4fs"; + $cmd .= &opt_check("ext3_j", '\d+', "-j"); + } else { $cmd = "mkfs.ext2 -j"; if (!$in{'ext3_j_def'}) { @@ -755,14 +759,14 @@ return $cmd; # Returns 1 if this filesystem type can be tuned sub can_tune { -return $_[0] eq "ext2" || $_[0] eq "ext3"; +return $_[0] =~ /^ext\d+$/; } # tunefs_options(type) # Output HTML for tuning options for some filesystem type sub tunefs_options { -if ($_[0] eq "ext2" || $_[0] eq "ext3") { +if ($_[0] =~ /^ext\d+$/) { # Gaps between checks &opt_input("tunefs_c", "", 1); @@ -801,7 +805,7 @@ if ($_[0] eq "ext2" || $_[0] eq "ext3") { # Returns the tuning command based on user inputs sub tunefs_parse { -if ($_[0] eq "ext2" || $_[0] eq "ext3") { +if ($_[0] =~ /^ext\d+$/) { $cmd = "tune2fs"; $cmd .= &opt_check("tunefs_c", '\d+', "-c"); $cmd .= $in{'tunefs_e_def'} ? "" : " -e$in{'tunefs_e'}"; @@ -872,8 +876,7 @@ return (); # Returns 1 if some filesystem type can fsck'd sub can_fsck { -return ($_[0] eq "ext2" && &has_command("fsck.ext2") || - $_[0] eq "ext3" && &has_command("fsck.ext3") || +return ($_[0] =~ /^ext\d+$/ && &has_command("fsck.$_[0]") || $_[0] eq "minix" && &has_command("fsck.minix")); } @@ -881,7 +884,7 @@ return ($_[0] eq "ext2" && &has_command("fsck.ext2") || # Returns the fsck command to unconditionally check a filesystem sub fsck_command { -if ($_[0] eq "ext2" || $_[0] eq "ext3") { +if ($_[0] =~ /^ext\d+$/) { return "fsck -t $_[0] -p $_[1]"; } elsif ($_[0] eq "minix") { @@ -1172,6 +1175,8 @@ local @fstypes = ( "ext2" ); push(@fstypes, "ext3") if (&has_command("mkfs.ext3") || &has_command("mke3fs") || `mkfs.ext2 -h 2>&1` =~ /\[-j\]/); +push(@fstypes, "ext4") if (&has_command("mkfs.ext4") || + &has_command("mke4fs")); push(@fstypes, "reiserfs") if (&has_command("mkreiserfs")); push(@fstypes, "xfs") if (&has_command("mkfs.xfs")); push(@fstypes, "jfs") if (&has_command("mkfs.jfs")); diff --git a/lvm/CHANGELOG b/lvm/CHANGELOG index f3b07d54e..e6744b191 100644 --- a/lvm/CHANGELOG +++ b/lvm/CHANGELOG @@ -20,3 +20,5 @@ When creating a logical volume, size can now be specified as a fraction of the v ---- Changes since 1.480 ---- Added an option to force addition of a physical volume to a group. Cleaned up code to use quotemeta instead of manual quoting. +---- Changes since 1.500 ---- +Added support for creating EXT4 filesystems. diff --git a/lvm/lvm-lib.pl b/lvm/lvm-lib.pl index 7e0aeb9f7..f0320767e 100755 --- a/lvm/lvm-lib.pl +++ b/lvm/lvm-lib.pl @@ -436,7 +436,7 @@ return $? ? $out : undef; # 0 = no, 1 = enlarge only, 2 = enlarge or shrink sub can_resize_filesystem { -if ($_[0] eq "ext2" || $_[0] eq "ext3") { +if ($_[0] =~ /^ext\d+$/) { if (&has_command("e2fsadm")) { return 2; # Can extend and reduce } diff --git a/raid/CHANGELOG b/raid/CHANGELOG index 087a98e98..5ac01c6ed 100644 --- a/raid/CHANGELOG +++ b/raid/CHANGELOG @@ -28,3 +28,5 @@ Added an option to skip initialization of metadata when creating a RAID device. RAID 6 devices can now have spares, thanks to Caspar Smit. ---- Changes since 1.490 ---- Added a button to remove a detached partition, thanks to Caspar Smit. +---- Changes since 1.500 ---- +Added support for creating EXT4 filesystems. diff --git a/raid/mkfs.cgi b/raid/mkfs.cgi index ff39be93e..f170c84dd 100755 --- a/raid/mkfs.cgi +++ b/raid/mkfs.cgi @@ -13,7 +13,7 @@ $cmd = &fdisk::mkfs_parse($in{'fs'}, $raid->{'value'}); $lvl = &find_value('raid-level', $raid->{'members'}); $chunk = &find_value('chunk-size', $raid->{'members'}); -if ($lvl >= 4 && ($in{'fs'} eq 'ext2' || $in{'fs'} eq 'ext3')) { +if ($lvl >= 4 && $in{'fs'} =~ /^ext\d+$/ { $bs = $in{'ext2_b_def'} ? 4096 : $in{'ext2_b'}; } diff --git a/raid/raid-lib.pl b/raid/raid-lib.pl index 4ba8321a9..2b103b4d7 100755 --- a/raid/raid-lib.pl +++ b/raid/raid-lib.pl @@ -239,7 +239,8 @@ else { local $lref = &read_file_lines($config{'mdadm'}); local $lvl = &find_value('raid-level', $_[0]->{'members'}); $lvl = $lvl =~ /^\d+$/ ? "raid$lvl" : $lvl; - push(@$lref, "DEVICE ".join(" ", @devices)); + push(@$lref, "DEVICE ". + join(" ", map { &device_to_volid($_) } @devices)); push(@$lref, "ARRAY $_[0]->{'value'} level=$lvl devices=". join(",", @devices). ($sg ? " spare-group=$sg" : "")); @@ -301,6 +302,16 @@ else { } } +# device_to_volid(device) +# Given a device name like /dev/sda1, convert it to a volume ID if possible. +# Otherwise return the device name. +sub device_to_volid +{ +local ($dev) = @_; +return $dev; +#return &fdisk::get_volid($dev) || $dev; +} + # make_raid(&raid, force, [missing], [assume-clean]) # Call mkraid or mdadm to make a raid set for real sub make_raid