Convert more modules to new library
authorJamie Cameron <jcameron@webmin.com>
Fri, 27 Feb 2009 23:01:55 +0000 (23:01 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 27 Feb 2009 23:01:55 +0000 (23:01 +0000)
22 files changed:
fdisk/edit_disk.cgi
fdisk/edit_part.cgi
fdisk/fdisk-lib.pl
lvm/edit_lv.cgi
lvm/edit_lv.cgi.bak [deleted file]
lvm/edit_pv.cgi
lvm/edit_vg.cgi
lvm/lvm-lib.pl
lvm/lvm-lib.pl.bak [deleted file]
lvm/mkfs.cgi
lvm/mkfs_form.cgi
lvm/save_lv.cgi
lvm/save_lv.cgi.bak [deleted file]
mount/freebsd-lib.pl
mount/linux-lib.pl
mount/mount-lib.pl
mount/solaris-lib.pl
raid/mkfs.cgi
raid/raid-lib.pl
raid/raid_form.cgi
raid/view_raid.cgi
web-lib-funcs.pl

index 09301ce..a5da89a 100644 (file)
@@ -65,7 +65,7 @@ if (@parts) {
                                  $text{'disk_end'},
                                  $text{'disk_use'},
                                  $anyfree ? ( $text{'disk_free'} ) : ( ),
-                                ], 100, 1, \@tds);
+                                ], 100, 0, \@tds);
        foreach $p (@parts) {
                $url = "edit_part.cgi?disk=$d->{'index'}&part=$p->{'index'}";
 
index e9d1640..1ae2b7e 100755 (executable)
@@ -239,9 +239,6 @@ if (!$in{'new'} && !$pinfo->{'extended'}) {
        @types = &conv_type($pinfo->{'type'});
        if (!$in{'new'} && !@stat && @types) {
                # Show form to mount filesystem
-               print "<tr> <form action=../mount/edit_mount.cgi>\n";
-               print "<input type=hidden name=newdev value=$dev>\n";
-               print "<td valign=top>\n";
                if ($types[0] eq "swap") {
                        # Swap partition
                        print &ui_buttons_row("../mount/edit_mount.cgi",
@@ -265,7 +262,6 @@ if (!$in{'new'} && !$pinfo->{'extended'}) {
                }
 
        print &ui_buttons_end();
-       print "<p>\n";
        }
 
 &ui_print_footer("", $text{'index_return'});
index 83bf415..dccee6e 100644 (file)
@@ -1,9 +1,9 @@
 # fdisk-lib.pl
 # Functions for disk management under linux
 
-do '../web-lib.pl';
+BEGIN { push(@INC, ".."); };
+use WebminCore;
 &init_config();
-do '../ui-lib.pl';
 &foreign_require("mount", "mount-lib.pl");
 if (&foreign_check("raid")) {
        &foreign_require("raid", "raid-lib.pl");
index d101e5a..81d9ba2 100755 (executable)
@@ -2,7 +2,6 @@
 # Display a form for editing an existing logical volume
 
 require './lvm-lib.pl';
-&foreign_require("fdisk", "fdisk-lib.pl");
 &ReadParse();
 ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
 @lvs = &list_logical_volumes($in{'vg'});
diff --git a/lvm/edit_lv.cgi.bak b/lvm/edit_lv.cgi.bak
deleted file mode 100755 (executable)
index 3eb1c54..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/usr/local/bin/perl
-# Display a form for editing an existing logical volume
-
-require './lvm-lib.pl';
-&foreign_require("fdisk", "fdisk-lib.pl");
-&ReadParse();
-($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
-@lvs = &list_logical_volumes($in{'vg'});
-
-if ($in{'lv'}) {
-       ($lv) = grep { $_->{'name'} eq $in{'lv'} } @lvs;
-       &header($lv->{'is_snap'} ? $text{'lv_edit_snap'}
-                                : $text{'lv_edit'}, "");
-       @stat = &device_status($lv->{'device'});
-       }
-else {
-       &header($in{'snap'} ? $text{'lv_create_snap'} : $text{'lv_create'}, "");
-       $lv = { 'perm' => 'rw',
-               'alloc' => 'n',
-               'is_snap' => $in{'snap'},
-               'size' => ($vg->{'pe_total'} - $vg->{'pe_alloc'})*
-                         $vg->{'pe_size'} };
-       }
-print "<center><font size=+2>",&text('lv_vg', $vg->{'name'}),
-      "</font></center>\n";
-print "<hr>\n";
-
-print "<form action=save_lv.cgi>\n";
-print "<input type=hidden name=vg value='$in{'vg'}'>\n";
-print "<input type=hidden name=lv value='$in{'lv'}'>\n";
-print "<input type=hidden name=snap value='$in{'snap'}'>\n";
-print "<table border width=100%>\n";
-print "<tr $tb> <td><b>$text{'lv_header'}</b></td> </tr>\n";
-print "<tr $cb> <td><table width=100%>\n";
-
-if ($stat[2]) {
-       print "<tr> <td><b>$text{'lv_name'}</b></td>\n";
-       print "<td>$lv->{'name'}</td>\n";
-
-       print "<td><b>$text{'lv_size'}</b></td>\n";
-       print "<td>$lv->{'size'} kB</td> </tr>\n";
-       }
-else {
-       print "<tr> <td><b>$text{'lv_name'}</b></td>\n";
-       print "<td><input name=name size=15 value='$lv->{'name'}'></td>\n";
-
-       print "<td><b>$text{'lv_size'}</b></td>\n";
-       print "<td><input name=size size=8 value='$lv->{'size'}'> kB</td> </tr>\n";
-       }
-
-print "<tr> <td><b>$text{'lv_petotal'}</b></td>\n";
-print "<td>",&text('lv_petotals', $vg->{'pe_alloc'}, $vg->{'pe_total'}),
-      "</td>\n";
-
-print "<td><b>$text{'lv_pesize'}</b></td>\n";
-print "<td>$vg->{'pe_size'} kB</td> </tr>\n";
-
-if ($in{'lv'}) {
-       print "<tr> <td><b>$text{'lv_device'}</b></td>\n";
-       print "<td><tt>$lv->{'device'}</tt></td>\n";
-
-       print "<td><b>$text{'lv_status'}</b></td> <td>\n";
-       if (!@stat) {
-               print $text{'lv_notused'};
-               }
-       else {
-               $msg = &device_message(@stat);
-               print $msg;
-               }
-       print "</td> </tr>\n";
-       }
-
-if ($lv->{'is_snap'}) {
-       print "<tr> <td><b>$text{'lv_snapof'}</b></td> <td>\n";
-       if ($in{'lv'}) {
-               # Show which LV this is a snapshot of
-               local @snapof = grep { $_->{'size'} == $lv->{'size'} &&
-                                      $_->{'has_snap'} } @lvs;
-               if (@snapof == 1) {
-                       print "<tt>$snapof[0]->{'name'}</tt>";
-                       }
-               else {
-                       print "<i>$text{'lv_nosnap'}</i>";
-                       }
-               }
-       else {
-               # Allow selection of snapshot source
-               print "<select name=snapof>\n";
-               foreach $l (@lvs) {
-                       print "<option>$l->{'name'}\n" if (!$l->{'is_snap'});
-                       }
-               print "</select>\n";
-               }
-       print "</td> </tr>\n";
-       }
-elsif ($stat[2]) {
-       # Display current permissons and allocation method
-       print "<tr> <td><b>$text{'lv_perm'}</b></td>\n";
-       print "<td>",$text{"lv_perm".$lv->{'perm'}},"</td>\n";
-
-       print "<td><b>$text{'lv_alloc'}</b></td>\n";
-       print "<td>",$text{"lv_alloc".$lv->{'alloc'}},"</td> </tr>\n";
-       }
-else {
-       # Allow editing of permissons and allocation method
-       print "<tr> <td><b>$text{'lv_perm'}</b></td>\n";
-       printf "<td><input type=radio name=perm value=rw %s> %s\n",
-               $lv->{'perm'} eq 'rw' ? 'checked' : '', $text{'lv_permrw'};
-       printf "<input type=radio name=perm value=r %s> %s</td>\n",
-               $lv->{'perm'} eq 'r' ? 'checked' : '', $text{'lv_permr'};
-
-       print "<td><b>$text{'lv_alloc'}</b></td>\n";
-       printf "<td><input type=radio name=alloc value=y %s> %s\n",
-               $lv->{'alloc'} eq 'y' ? 'checked' : '', $text{'lv_allocy'};
-       printf "<input type=radio name=alloc value=n %s> %s</td> </tr>\n",
-               $lv->{'alloc'} eq 'n' ? 'checked' : '', $text{'lv_allocn'};
-       }
-
-if (!$in{'lv'} && !$lv->{'is_snap'}) {
-       print "<tr> <td><b>$text{'lv_stripe'}</b></td> <td colspan=3>\n";
-       printf "<input type=radio name=stripe_def value=1 checked> %s\n",
-               $text{'lv_nostripe'};
-       print "<input type=radio name=stripe_def value=0>\n";
-       print &text('lv_stripes', "<input name=stripe size=4>"),
-             "</td> </tr>\n";
-       }
-
-print "</table></td></tr></table>\n";
-print "<table width=100%><tr>\n";
-if ($stat[2]) {
-       print "<td><b>$text{'lv_cannot'}</b></td>\n";
-       }
-elsif ($in{'lv'}) {
-       print "<td><input type=submit value='$text{'save'}'></td>\n";
-       print "<td align=right><input type=submit name=delete ",
-             "value='$text{'delete'}'></td>\n";
-       }
-else {
-       print "<td><input type=submit value='$text{'create'}'></td>\n";
-       }
-print "</tr></table></form>\n";
-
-if ($in{'lv'} && !$stat[2] && !$lv->{'is_snap'}) {
-       # Show buttons for creating filesystems
-       print "<hr>\n";
-       print "<table width=100%><tr>\n";
-       print "<form action=mkfs_form.cgi>\n";
-       print "<input type=hidden name=dev value='$lv->{'device'}'>\n";
-       print "<td><input type=submit value='$text{'lv_mkfs'}'>\n";
-       print "<select name=fs>\n";
-       foreach $f (&fdisk::supported_filesystems()) {
-               printf "<option value=%s %s>%s (%s)\n",
-                       $f, $stat[1] eq $f ? "selected" : "",
-                       $fdisk::text{"fs_$f"}, $f;
-               }
-       print "</select></td>\n";
-       print "<td>$text{'lv_mkfsdesc'}</td>\n";
-       print "</form></tr></table>\n";
-       }
-
-print "<hr>\n";
-&footer("", $text{'index_return'});
-
index bac3ce1..7ebb3a7 100755 (executable)
@@ -3,7 +3,6 @@
 # Display a form for editing or creating a physical volume
 
 require './lvm-lib.pl';
-&foreign_require("fdisk", "fdisk-lib.pl");
 &ReadParse();
 ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
 
index c5b544a..8d1397b 100755 (executable)
@@ -3,7 +3,6 @@
 # Display a form for editing or creating a volume group
 
 require './lvm-lib.pl';
-&foreign_require("fdisk", "fdisk-lib.pl");
 &ReadParse();
 
 if ($in{'vg'}) {
index 39c66cc..233ac96 100644 (file)
@@ -1,14 +1,15 @@
 # lvm-lib.pl
 # Common functions for managing VGs, PVs and LVs
 
-do '../web-lib.pl';
+BEGIN { push(@INC, ".."); };
+use WebminCore;
 &init_config();
-do '../ui-lib.pl';
-&foreign_require("mount", "mount-lib.pl");
+&foreign_require("mount");
 if (&foreign_check("raid")) {
-       &foreign_require("raid", "raid-lib.pl");
+       &foreign_require("raid");
        $has_raid++;
        }
+&foreign_require("fdisk");
 
 $lvm_proc = "/proc/lvm";
 $lvm_tab = "/etc/lvmtab";
@@ -447,11 +448,11 @@ else {
 sub resize_filesystem
 {
 if ($_[1] eq "ext2" || $_[1] eq "ext3") {
-       &foreign_require("proc", "proc-lib.pl");
+       &foreign_require("proc");
        if (&has_command("e2fsadm")) {
                # The e2fsadm command can re-size an LVM and filesystem together
                local $cmd = "e2fsadm -v -L $_[2]k '$_[0]->{'device'}'";
-               local ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
+               local ($fh, $fpid) = &proc::pty_process_exec($cmd);
                print $fh "yes\n";
                local $out;
                while(<$fh>) {
@@ -571,13 +572,13 @@ return %rv;
 # Returns an array of  directory, type, mounted
 sub device_status
 {
-@mounted = &foreign_call("mount", "list_mounted") if (!@mounted);
-@mounts = &foreign_call("mount", "list_mounts") if (!@mounts);
-local $label = &fdisk::get_label($_[0]);
+@mounted = &mount::list_mounted() if (!@mounted);
+@mounts = &mount::list_mounts() if (!@mounts);
+my $label = &fdisk::get_label($_[0]);
 
-local ($mounted) = grep { &same_file($_->[1], $_[0]) ||
+my ($mounted) = grep { &same_file($_->[1], $_[0]) ||
                          $_->[1] eq "LABEL=$label" } @mounted;
-local ($mount) = grep { &same_file($_->[1], $_[0]) ||
+my ($mount) = grep { &same_file($_->[1], $_[0]) ||
                        $_->[1] eq "LABEL=$label" } @mounts;
 if ($mounted) { return ($mounted->[0], $mounted->[2], 1,
                        &indexof($mount, @mounts),
@@ -585,9 +586,9 @@ if ($mounted) { return ($mounted->[0], $mounted->[2], 1,
 elsif ($mount) { return ($mount->[0], $mount->[2], 0,
                         &indexof($mount, @mounts)); }
 elsif ($has_raid) {
-       $raidconf = &foreign_call("raid", "get_raidtab") if (!$raidconf);
-       foreach $c (@$raidconf) {
-               foreach $d (raid::find_value('device', $c->{'members'})) {
+       $raidconf = &raid::get_raidtab() if (!$raidconf);
+       foreach my $c (@$raidconf) {
+               foreach my $d (&raid::find_value('device', $c->{'members'})) {
                        return ( $c->{'value'}, "raid", 1 ) if ($d eq $_[0]);
                        }
                }
@@ -634,7 +635,7 @@ foreach $vg (&list_volume_groups()) {
 
 # Show available partitions
 local @opts;
-foreach $d (&foreign_call("fdisk", "list_disks_partitions")) {
+foreach $d (&fdisk::list_disks_partitions()) {
        foreach $p (@{$d->{'parts'}}) {
                next if ($used{$p->{'device'}} || $p->{'extended'});
                local @ds = &device_status($p->{'device'});
@@ -643,7 +644,7 @@ foreach $d (&foreign_call("fdisk", "list_disks_partitions")) {
                        local $label = &fdisk::get_label($p->{'device'});
                        next if ($used{"LABEL=$label"});
                        }
-               local $tag = &foreign_call("fdisk", "tag_name", $p->{'type'});
+               local $tag = &fdisk::tag_name($p->{'type'});
                push(@opts, [ $p->{'device'},
                        $p->{'desc'}.
                        ($tag ? " ($tag)" : "").
@@ -653,7 +654,7 @@ foreach $d (&foreign_call("fdisk", "list_disks_partitions")) {
        }
 
 # Show available RAID devices
-local $conf = &foreign_call("raid", "get_raidtab");
+local $conf = &fdisk::get_raidtab();
 foreach $c (@$conf) {
        next if ($used{$c->{'value'}});
        local @ds = &device_status($c->{'value'});
diff --git a/lvm/lvm-lib.pl.bak b/lvm/lvm-lib.pl.bak
deleted file mode 100644 (file)
index 4354aad..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-# lvm-lib.pl
-# Common functions for managing VGs, PVs and LVs
-
-do '../web-lib.pl';
-&init_config();
-&foreign_require("mount", "mount-lib.pl");
-if (&foreign_check("raid")) {
-       &foreign_require("raid", "raid-lib.pl");
-       $has_raid++;
-       }
-
-$lvm_proc = "/proc/lvm";
-$lvm_tab = "/etc/lvmtab";
-
-# list_physical_volumes(vg)
-# Returns a list of all physical volumes for some volume group
-sub list_physical_volumes
-{
-local @rv;
-opendir(DIR, "$lvm_proc/VGs/$_[0]/PVs");
-foreach $f (readdir(DIR)) {
-       next if ($f eq '.' || $f eq '..');
-       local $pv = { 'name' => $f,
-                     'vg' => $_[0] };
-       local %p = &parse_colon_file("$lvm_proc/VGs/$_[0]/PVs/$f");
-       $pv->{'device'} = $p{'name'};
-       $pv->{'number'} = $p{'number'};
-       $pv->{'size'} = $p{'size'}/2;
-       $pv->{'status'} = $p{'status'};
-       $pv->{'number'} = $p{'number'};
-       $pv->{'pe_size'} = $p{'PE size'};
-       $pv->{'pe_total'} = $p{'PE total'};
-       $pv->{'pe_alloc'} = $p{'PE allocated'};
-       $pv->{'alloc'} = $p{'allocatable'} == 2 ? 'y' : 'n';
-       push(@rv, $pv);
-       }
-closedir(DIR);
-return @rv;
-}
-
-# create_physical_volume(&pv)
-sub create_physical_volume
-{
-local $cmd = "pvcreate -f -y '$_[0]->{'device'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $out if ($?);
-$cmd = "vgextend '$_[0]->{'vg'}' '$_[0]->{'device'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# change_physical_volume(&pv)
-sub change_physical_volume
-{
-local $cmd = "pvchange -x $_[0]->{'alloc'} '$_[0]->{'device'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# delete_physical_volume(&pv)
-sub delete_physical_volume
-{
-if ($_[0]->{'pe_alloc'}) {
-       local $cmd = "(yes | pvmove '$_[0]->{'device'}')";
-       local $out = &backquote_logged("$cmd 2>&1");
-       return $out if ($?);
-       }
-local $cmd = "vgreduce '$_[0]->{'vg'}' '$_[0]->{'device'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-
-# list_volume_groups()
-# Returns a list of all volume groups
-sub list_volume_groups
-{
-local (@rv, $f);
-opendir(DIR, "$lvm_proc/VGs");
-foreach $f (readdir(DIR)) {
-       next if ($f eq '.' || $f eq '..');
-       local $vg = { 'name' => $f };
-       local %g = &parse_colon_file("$lvm_proc/VGs/$f/group");
-       $vg->{'number'} = $g{'number'};
-       $vg->{'size'} = $g{'size'};
-       $vg->{'pe_size'} = $g{'PE size'};
-       $vg->{'pe_total'} = $g{'PE total'};
-       $vg->{'pe_alloc'} = $g{'PE allocated'};
-       push(@rv, $vg);
-       }
-closedir(DIR);
-return @rv;
-}
-
-# delete_volume_group(&vg)
-sub delete_volume_group
-{
-local $cmd = "vgchange -a n '$_[0]->{'name'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $out if ($?);
-$cmd = "vgremove '$_[0]->{'name'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# create_volume_group(&vg, device)
-sub create_volume_group
-{
-&system_logged("vgscan >/dev/null 2>&1 </dev/null");
-local $cmd = "pvcreate -f -y '$_[1]'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $out if ($?);
-$cmd = "vgcreate";
-$cmd .= " -s $_[0]->{'pe_size'}k" if ($_[0]->{'pe_size'});
-$cmd .= " '$_[0]->{'name'}' '$_[1]'";
-$out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# rename_volume_group(&vg, name)
-sub rename_volume_group
-{
-local $cmd = "vgrename '$_[0]->{'name'}' '$_[1]'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $out if ($?);
-$cmd = "vgchange -a n '$_[1]'";
-$out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $out if ($?);
-$cmd = "vgchange -a y '$_[1]'";
-$out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-
-# list_logical_volumes(vg)
-sub list_logical_volumes
-{
-local @rv;
-opendir(DIR, "$lvm_proc/VGs/$_[0]/LVs");
-foreach $f (readdir(DIR)) {
-       next if ($f eq '.' || $f eq '..');
-       local $lv = { 'name' => $f,
-                     'vg' => $_[0] };
-       local %p = &parse_colon_file("$lvm_proc/VGs/$_[0]/LVs/$f");
-       $lv->{'device'} = $p{'name'};
-       $lv->{'number'} = $p{'number'};
-       $lv->{'size'} = $p{'size'}/2;
-       $lv->{'perm'} = $p{'access'} == 3 ? 'rw' : 'r';
-       $lv->{'alloc'} = $p{'allocation'} == 2 ? 'y' : 'n';
-       $lv->{'has_snap'} = $p{'access'} == 11;
-       $lv->{'is_snap'} = $p{'access'} == 5;
-       push(@rv, $lv);
-       }
-closedir(DIR);
-return @rv;
-}
-
-# create_logical_volume(&lv)
-sub create_logical_volume
-{
-local $cmd = "lvcreate -n$_[0]->{'name'} -L$_[0]->{'size'}k";
-if ($_[0]->{'is_snap'}) {
-       $cmd .= " -s '/dev/$_[0]->{'vg'}/$_[0]->{'snapof'}'";
-       }
-else {
-       $cmd .= " -p $_[0]->{'perm'}";
-       $cmd .= " -C $_[0]->{'alloc'}";
-       $cmd .= " -i $_[0]->{'stripe'}" if ($_[0]->{'stripe'});
-       $cmd .= " $_[0]->{'vg'}";
-       }
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# delete_logical_volume(&lv)
-sub delete_logical_volume
-{
-local $cmd = "lvremove -f '$_[0]->{'device'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# resize_logical_volume(&lv, size)
-sub resize_logical_volume
-{
-local $cmd = $_[1] > $_[0]->{'size'} ? "lvextend" : "lvreduce -f";
-$cmd .= " -L$_[1]k";
-$cmd .= " '$_[0]->{'device'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# change_logical_volume(&lv)
-sub change_logical_volume
-{
-local $cmd = "lvchange ";
-$cmd .= " -p $_[0]->{'perm'}";
-$cmd .= " -C $_[0]->{'alloc'}";
-$cmd .= " '$_[0]->{'device'}'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# rename_logical_volume(&lv, name)
-sub rename_logical_volume
-{
-local $cmd = "lvrename '$_[0]->{'device'}' '/dev/$_[0]->{'vg'}/$_[1]'";
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? $out : undef;
-}
-
-# can_resize_filesystem(type)
-sub can_resize_filesystem
-{
-if ($_[0] eq "ext2" || $_[0] eq "ext3") {
-       return &has_command("e2fsadm") ? 2 : 0;
-       }
-# xfs_growfs doesn't work on LVMs
-#elsif ($_[0] eq "xfs") {
-#      return &has_command("xfs_growfs") ? 1 : 0;
-#      }
-else {
-       return 0;
-       }
-}
-
-# resize_filesystem(&lv, type, size)
-sub resize_filesystem
-{
-if ($_[1] eq "ext2" || $_[1] eq "ext3") {
-       &foreign_require("proc", "proc-lib.pl");
-       local $cmd = "e2fsadm -L $_[2]k '$_[0]->{'device'}'";
-       local ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
-       local $out;
-       while(<$fh>) {
-               $out .= $_;
-               }
-       close($fh);
-       waitpid($fpid, 0);
-       &additional_log("exec", undef, $cmd);
-       return $? ? $out : undef;
-       }
-elsif ($_[1] eq "xfs") {
-       # Resize the logical volume first
-
-       # XXX resize the filesystem
-       }
-else {
-       return "???";
-       }
-}
-
-
-# parse_colon_file(file)
-sub parse_colon_file
-{
-local %rv;
-open(FILE, $_[0]);
-while(<FILE>) {
-       if (/^([^:]+):\s*(.*)/) {
-               $rv{$1} = $2;
-               }
-       }
-close(FILE);
-return %rv;
-}
-
-# device_status(device)
-# Returns an array of  directory, type, mounted
-sub device_status
-{
-@mounted = &foreign_call("mount", "list_mounted") if (!@mounted);
-@mounts = &foreign_call("mount", "list_mounts") if (!@mounts);
-local $label = &fdisk::get_label($_[0]);
-
-local ($mounted) = grep { &same_file($_->[1], $_[0]) ||
-                         $_->[1] eq "LABEL=$label" } @mounted;
-local ($mount) = grep { &same_file($_->[1], $_[0]) ||
-                       $_->[1] eq "LABEL=$label" } @mounts;
-print STDERR "for $_[0] : mount = $mount  mounted = $mounted\n";
-if ($mounted) { return ($mounted->[0], $mounted->[2], 1,
-                       &indexof($mount, @mounts),
-                       &indexof($mounted, @mounted)); }
-elsif ($mount) { return ($mount->[0], $mount->[2], 0,
-                        &indexof($mount, @mounts)); }
-elsif ($has_raid) {
-       $raidconf = &foreign_call("raid", "get_raidtab") if (!$raidconf);
-       foreach $c (@$raidconf) {
-               foreach $d (raid::find_value('device', $c->{'members'})) {
-                       return ( $c->{'value'}, "raid", 1 ) if ($d eq $_[0]);
-                       }
-               }
-       }
-return ();
-}
-
-sub device_message
-{
-$msg = $_[2] ? 'lv_mount' : 'lv_umount';
-$msg .= 'vm' if ($_[1] eq 'swap');
-$msg .= 'raid' if ($_[1] eq 'raid');
-return &text($msg, "<tt>$_[0]</tt>", "<tt>$_[1]</tt>");
-}
-
-# list_lvmtab()
-sub list_lvmtab
-{
-local @rv;
-open(TAB, $lvm_tab);
-local $/ = "\0";
-while(<TAB>) {
-       chop;
-       push(@rv, $_) if ($_);
-       }
-close(TAB);
-return @rv;
-}
-
-# device_input()
-sub device_input
-{
-local (%used, $vg, $pv, $d, $p);
-
-# Find partitions that are part of an LVM
-foreach $vg (&list_volume_groups()) {
-       foreach $pv (&list_physical_volumes($vg->{'name'})) {
-               $used{$pv->{'device'}}++;
-               }
-       }
-
-# Show available partitions
-print "<select name=device>\n";
-foreach $d (&foreign_call("fdisk", "list_disks_partitions")) {
-       foreach $p (@{$d->{'parts'}}) {
-               next if ($used{$p->{'device'}} || $p->{'extended'});
-               local @ds = &device_status($p->{'device'});
-               next if (@ds);
-               if ($p->{'type'} eq '83') {
-                       local $label = &fdisk::get_label($p->{'device'});
-                       next if ($used{"LABEL=$label"});
-                       }
-               local $tag = &foreign_call("fdisk", "tag_name", $p->{'type'});
-               printf "<option value='%s'>%s %s\n",
-                       $p->{'device'}, $p->{'desc'},
-                       $tag ? "($tag)" : "";
-               }
-       }
-
-# Show available RAID devices
-local $conf = &foreign_call("raid", "get_raidtab");
-foreach $c (@$conf) {
-       next if ($used{$c->{'value'}});
-       local @ds = &device_status($c->{'value'});
-       next if (@ds);
-       printf "<option value='%s'>%s\n",
-               $c->{'value'}, &text('pv_raid', $c->{'value'} =~ /md(\d+)$/ ? "$1" : $c->{'value'});
-       }
-
-print "<option value=''>$text{'pv_other'}\n";
-print "</select>\n";
-print "<input name=other size=30> ",
-       &file_chooser_button("other"),"<br>\n";
-print "<b>$text{'pv_warn'}</b>\n";
-}
-
-1;
-
index efd8c6c..57679c8 100755 (executable)
@@ -3,19 +3,17 @@
 # Create a new filesystem on a logical volume
 
 require './lvm-lib.pl';
-&foreign_require("proc", "proc-lib.pl");
-&foreign_require("fdisk", "fdisk-lib.pl");
+&foreign_require("proc");
 
 &ReadParse();
 &error_setup($text{'mkfs_err'});
-&foreign_call("fdisk", "error_setup", $text{'mkfs_err'});
-&foreign_call("fdisk", "ReadParse");
-$cmd = &foreign_call("fdisk", "mkfs_parse", $in{'fs'}, $in{'dev'});
+&fdisk::ReadParse();
+$cmd = &fdisk::mkfs_parse($in{'fs'}, $in{'dev'});
 
 &ui_print_unbuffered_header(undef, $text{'mkfs_title'}, "");
 print &text('mkfs_exec', "<tt>$cmd</tt>"),"<p>\n";
 print "<pre>\n";
-&foreign_call("proc", "safe_process_exec_logged", $cmd, 0, 0, STDOUT, undef, 1);
+&proc::safe_process_exec_logged($cmd, 0, 0, STDOUT, undef, 1);
 print "</pre>\n";
 
 if ($?) { print "<b>$text{'mkfs_failed'}</b> <p>\n"; }
index 291531e..2825c95 100755 (executable)
@@ -5,10 +5,9 @@
 require './lvm-lib.pl';
 &ReadParse();
 &ui_print_header(undef, $text{'mkfs_title'}, "");
-&foreign_require("fdisk", "fdisk-lib.pl");
 
 print "<b>",&text('mkfs_desc', "<tt>$in{'fs'}</tt>",
-       &foreign_call("fdisk", "fstype_name", $in{'fs'}),
+       &fdisk::fstype_name($in{'fs'}),
        "<tt>$in{'dev'}</tt>"),"</b><br>\n";
 
 print &ui_form_start("mkfs.cgi");
index 7972793..473a6fa 100755 (executable)
@@ -3,7 +3,6 @@
 # Create, update or delete a logical volume
 
 require './lvm-lib.pl';
-&foreign_require("fdisk", "fdisk-lib.pl");
 &ReadParse();
 
 ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
diff --git a/lvm/save_lv.cgi.bak b/lvm/save_lv.cgi.bak
deleted file mode 100755 (executable)
index 6969502..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/local/bin/perl
-# save_lv.cgi
-# Create, update or delete a logical volume
-
-require './lvm-lib.pl';
-&ReadParse();
-
-($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
-($lv) = grep { $_->{'name'} eq $in{'lv'} } &list_logical_volumes($in{'vg'})
-       if ($in{'lv'});
-
-if ($in{'confirm'}) {
-       # Delete the logical volume
-       &error_setup($text{'lv_err2'});
-       $err = &delete_logical_volume($lv);
-       &error("<pre>$err</pre>") if ($err);
-       &webmin_log("delete", "lv", $in{'lv'}, $lv);
-       &redirect("");
-       }
-elsif ($in{'delete'}) {
-       # Ask the user if he is sure
-       &header($text{'lv_delete'}, "");
-       print "<hr>\n";
-       print "<center><form action=save_lv.cgi>\n";
-       print "<input type=hidden name=vg value='$in{'vg'}'>\n";
-       print "<input type=hidden name=lv value='$in{'lv'}'>\n";
-       print "<b>",&text($lv->{'is_snap'} ? 'lv_rusnap' : 'lv_rusure',
-                         "<tt>$lv->{'device'}</tt>"),"</b><p>\n";
-       print "<input type=submit name=confirm ",
-             "value='$text{'lv_deleteok'}'>\n";
-       print "</center></form>\n";
-       print "<hr>\n";
-       &footer("", $text{'index_return'});
-       }
-else {
-       # Validate inputs
-       &error_setup($text{'lv_err'});
-       $in{'name'} =~ /^[A-Za-z0-9\.\-\_]+$/ || &error($text{'lv_ename'});
-       ($same) = grep { $_->{'name'} eq $in{'name'} }
-                      &list_logical_volumes($in{'vg'});
-       $same && (!$in{'lv'} || $in{'lv'} ne $in{'name'}) &&
-               &error($text{'lv_esame'});
-       $in{'size'} =~ /^\d+$/ || &error($text{'lv_esize'});
-       $in{'snap'} || $in{'lv'} || $in{'stripe_def'} ||
-               $in{'stripe'} =~ /^[1-9]\d*$/ || &error($text{'lv_estripe'});
-
-       if (!$in{'lv'}) {
-               # Just create the logical volume
-               $lv->{'vg'} = $in{'vg'};
-               $lv->{'name'} = $in{'name'};
-               $lv->{'size'} = $in{'size'};
-               if ($in{'snap'}) {
-                       $lv->{'is_snap'} = 1;
-                       $lv->{'snapof'} = $in{'snapof'};
-                       }
-               else {
-                       $lv->{'perm'} = $in{'perm'};
-                       $lv->{'alloc'} = $in{'alloc'};
-                       $lv->{'stripe'} = $in{'stripe'} if (!$in{'stripe_def'});
-                       }
-               $err = &create_logical_volume($lv);
-               &error("<pre>$err</pre>") if ($err);
-               &webmin_log("create", "lv", $in{'name'}, $lv);
-               }
-       elsif ($lv->{'is_snap'}) {
-               # Modifying a snapshot
-               if ($lv->{'size'} != $in{'size'}) {
-                       $err = &resize_logical_volume($lv, $in{'size'});
-                       &error("<pre>$err</pre>") if ($err);
-                       $lv->{'size'} = $in{'size'};
-                       }
-               if ($lv->{'name'} ne $in{'name'}) {
-                       # Need to rename
-                       $err = &rename_logical_volume($lv, $in{'name'});
-                       &error("<pre>$err</pre>") if ($err);
-                       $lv->{'name'} = $in{'name'};
-                       }
-               }
-       else {
-               # Modifying the logical volume
-               @stat = &device_status($lv->{'device'});
-               if ($lv->{'size'} != $in{'size'}) {
-                       # Is the new size too big?
-                       local $nblocks = int($in{'size'} / $vg->{'pe_size'})+1;
-                       local $oblocks = int($lv->{'size'} / $vg->{'pe_size'})+1;
-                       if ($vg->{'pe_alloc'} - $oblocks + $nblocks > $vg->{'pe_total'}) {
-                               #&error(&text('lv_toobig', $nblocks, "$vg->{'pe_size'} kB", $vg->{'pe_total'} - $vg->{'pe_alloc'}));
-                               }
-
-                       if ($in{'sizeconfirm'}) {
-                               # Just resize the logical volume
-                               $err = &resize_logical_volume($lv, $in{'size'});
-                               &error("<pre>$err</pre>") if ($err);
-                               }
-                       else {
-                               if (&can_resize_filesystem($stat[1])) {
-                                       # Attempt to resize properly
-                                       $err = &resize_filesystem($lv, $stat[1], $in{'size'});
-                                       if ($err) {
-                                               $err = &text('resize_fs', $stat[1], "</center><pre>$err</pre><center>");
-                                               }
-                                       }
-                               else {
-                                       # Cannot resize .. ask for confirmation
-                                       $err = @stat ?
-                                               &text('resize_mesg', $stat[1]) :
-                                               $text{'resize_mesg2'};
-                                       }
-                               if ($err) {
-                                       &header($text{'resize_title'}, "");
-                                       print "<hr>\n";
-                                       print "<center><form action=save_lv.cgi>\n";
-                                       foreach $i (keys %in) {
-                                               print "<input type=hidden name=$i value='$in{$i}'>\n";
-                                               }
-                                       print "<b>$err</b> <p>\n";
-                                       print "<input type=submit name=sizeconfirm value='$text{'resize_ok'}'>\n";
-                                       print "</form></center>\n";
-                                       print "<hr>\n";
-                                       &footer("", $text{'index_return'});
-                                       exit;
-                                       }
-                               }
-                       $lv->{'size'} = $in{'size'};
-                       }
-               if ($lv->{'perm'} ne $in{'perm'} ||
-                   $lv->{'alloc'} ne $in{'alloc'}) {
-                       # Need to change options
-                       $lv->{'perm'} = $in{'perm'};
-                       $lv->{'alloc'} = $in{'alloc'};
-                       $err = &change_logical_volume($lv);
-                       &error("<pre>$err</pre>") if ($err);
-                       }
-               if ($lv->{'name'} ne $in{'name'}) {
-                       # Need to rename
-                       $err = &rename_logical_volume($lv, $in{'name'});
-                       &error("<pre>$err</pre>") if ($err);
-                       $lv->{'name'} = $in{'name'};
-                       }
-               &webmin_log("modify", "lv", $in{'lv'}, $lv);
-               }
-       &redirect("");
-       }
-
index c756963..769b3df 100755 (executable)
@@ -237,7 +237,7 @@ elsif ($_[2] eq "smbfs") {
        delete($roptions->{'user'});
        local $opts = &join_options($_[2], $roptions);
        $opts = $opts ne "-" ? " -o $opts" : "";
-       &foreign_require("proc", "proc-lib.pl");
+       &foreign_require("proc");
        local ($fh, $fpid) = &proc::pty_process_exec_logged(
                "mount -t $_[2] $opts $share $_[0]");
        local $got;
index f883959..e897e6a 100644 (file)
@@ -603,15 +603,28 @@ if ($_[2] eq "bind") {
        }
 $opts = @opts ? "-o ".quotemeta(join(",", @opts)) : "";
 &parse_options($_[2], $_[3]);
+
+# Work out args for label or UUID
+local $devargs;
+if ($_[1] =~ /LABEL=(.*)/) {
+       $devargs = "-L ".quotemeta($1);
+       }
+elsif ($_[1] =~ /UUID=(\S+)/) {
+       $devargs = "-U ".quotemeta($1);
+       }
+else {
+       $devargs = quotemeta($_[1]);
+       }
+
 if ($_[2] eq "swap") {
        # Use swapon to add the swap space..
        local $priarg = $options{'pri'} ne "" ? "-p $options{'pri'}" : "";
-       $out = &backquote_logged("swapon $priarg $_[1] 2>&1");
+       $out = &backquote_logged("swapon $priarg $devargs 2>&1");
        if ($out =~ /Invalid argument/) {
                # looks like this swap partition isn't ready yet.. set it up
-               $out = &backquote_logged("mkswap $_[1] 2>&1");
+               $out = &backquote_logged("mkswap $devargs 2>&1");
                if ($?) { return "mkswap failed : <pre>$out</pre>"; }
-               $out = &backquote_logged("swapon $_[1] 2>&1");
+               $out = &backquote_logged("swapon $devargs 2>&1");
                }
        if ($?) { return "<pre>$out</pre>"; }
        }
@@ -653,9 +666,8 @@ elsif ($_[2] eq $smbfs_fs || $_[2] eq "cifs") {
                    ($options{'workgroup'} ? "-W $options{'workgroup'} " : "").
                    ($options{'clientname'} ? "-n $options{'clientname'} " : "").
                    ($options{'machinename'} ? "-I $options{'machinename'} " : "");
-               &foreign_require("proc", "proc-lib.pl");
-               local ($fh, $fpid) = &foreign_call(
-                       "proc", "pty_process_exec_logged",
+               &foreign_require("proc");
+               local ($fh, $fpid) = &proc::pty_process_exec_logged(
                        "sh -c 'smbmount $shar $_[0] -d 0 $opts'");
                if ($options{'passwd'}) {
                        local $w = &wait_for($fh, "word:");
@@ -704,15 +716,7 @@ elsif ($_[2] eq $smbfs_fs || $_[2] eq "cifs") {
 else {
        # some filesystem supported by mount
        local $fs = $_[2] eq "*" ? "auto" : $_[2];
-       if ($_[1] =~ /LABEL=(.*)/) {
-               $cmd = "mount -t $fs -L ".quotemeta($1)." $opts ".quotemeta($_[0]);
-               }
-       elsif ($_[1] =~ /UUID=(\S+)/) {
-               $cmd = "mount -t $fs -U ".quotemeta($1)." $opts ".quotemeta($_[0]);
-               }
-       else {
-               $cmd = "mount -t $fs $opts ".quotemeta($_[1])." ".quotemeta($_[0]);
-               }
+       $cmd = "mount -t $fs $opts $devargs ".quotemeta($_[0]);
        $out = &backquote_logged("$cmd 2>&1 </dev/null");
        if ($?) { return "<pre>$out</pre>"; }
        }
@@ -983,21 +987,20 @@ elsif ($_[0] eq "autofs") {
        }
 elsif ($_[0] eq "swap") {
        # Swap file or device
-       &foreign_require("fdisk", "fdisk-lib.pl");
+       &foreign_require("fdisk");
        printf "<tr> <td valign=top><b>$text{'linux_swapfile'}</b></td>\n";
        print "<td colspan=3>\n";
        local ($found, $ufound);
 
        # Show partitions input
-       local $sel = &foreign_call("fdisk", "partition_select", "lnx_disk",
-                                  $_[1], 3, \$found);
+       local $sel = &fdisk::partition_select("lnx_disk", $_[1], 3, \$found);
        printf "<input type=radio name=lnx_dev value=0 %s> %s %s<br>\n",
                $found ? "checked" : "", $text{'linux_disk'}, $sel;
 
        # Show UUID input
        if ($has_volid || -d $uuid_directory) {
                local $u = $_[1] =~ /UUID=(\S+)/ ? $1 : undef;
-               local $usel = &fdisk::volid_select("lnx_volid", $u, \$ufound);
+               local $usel = &fdisk::volid_select("lnx_uuid", $u, \$ufound);
                if ($usel) {
                        printf "<input type=radio name=lnx_dev value=5 %s> %s %s<br>\n", $ufound ? "checked" : "", $text{'linux_usel'}, $usel;
                        }
@@ -1035,21 +1038,20 @@ elsif ($_[0] eq "bind") {
        }
 else {
        # This is some linux disk-based filesystem
-       &foreign_require("fdisk", "fdisk-lib.pl");
+       &foreign_require("fdisk");
        printf "<tr> <td valign=top><b>%s</b></td>\n", &fstype_name($_[0]);
        print "<td colspan=3>\n";
        local ($found, $rfound, $lfound, $vfound, $ufound, $rsel, $c);
 
        # Show regular partition input
-       local $sel = &foreign_call("fdisk", "partition_select", "lnx_disk",
-                                  $_[1], 0, \$found);
+       local $sel = &fdisk::partition_select("lnx_disk", $_[1], 0, \$found);
        printf "<input type=radio name=lnx_dev value=0 %s> %s %s<br>\n",
                $found ? "checked" : "", $text{'linux_disk'}, $sel;
 
        # Show RAID input
        if (&foreign_check("raid")) {
-               &foreign_require("raid", "raid-lib.pl");
-               local $conf = &foreign_call("raid", "get_raidtab");
+               &foreign_require("raid");
+               local $conf = &raid::get_raidtab();
                foreach $c (@$conf) {
                        if ($c->{'active'}) {
                                $rsel .= sprintf "<option value=%s %s>%s\n",
@@ -1068,12 +1070,11 @@ else {
 
        # Show LVM input
        if (&foreign_check("lvm")) {
-               &foreign_require("lvm", "lvm-lib.pl");
-               local @vgs = &foreign_call("lvm", "list_volume_groups");
+               &foreign_require("lvm");
+               local @vgs = &lvm::list_volume_groups();
                local @lvs;
                foreach $v (@vgs) {
-                       push(@lvs, &foreign_call("lvm",
-                                       "list_logical_volumes", $v->{'name'}));
+                       push(@lvs, &lvm::list_logical_volumes($v->{'name'}));
                        }
                if (@lvs) {
                        local $lsel;
index 61f54b6..b276a28 100644 (file)
@@ -2,9 +2,9 @@
 # Functions for handling the /etc/[v]fstab file. Some functions are defined in
 # here, and some in OS-specific files named <os_type>-lib.pl
 
-do '../web-lib.pl';
+BEGIN { push(@INC, ".."); };
+use WebminCore;
 &init_config();
-do '../ui-lib.pl';
 %access = &get_module_acl();
 $filesystem_users_file = "$module_config_directory/filesystem-users";
 @access_fs = split(/\s+/, $access{'fs'});
index 5f4a660..12586af 100644 (file)
@@ -469,7 +469,7 @@ elsif ($_[0] eq "ufs") {
        # somewhere else
        print "<tr> <td valign=top><b>$text{'solaris_ufs'}</b></td>\n";
        print "<td colspan=3>\n";
-       &foreign_require("format", "format-lib.pl");
+       &foreign_require("format");
 
        if ($_[1] =~ /^\/dev\/dsk\/c([0-9]+)t([0-9]+)d([0-9]+)s([0-9]+)$/ ||
            $_[1] =~ /^\/dev\/dsk\/c([0-9]+)d([0-9]+)s([0-9]+)$/) {
@@ -486,9 +486,8 @@ elsif ($_[0] eq "ufs") {
                }
 
        local $found;
-       local $sel = &foreign_call("format", "partition_select",
-                                  "ufs_disk", $_[1], 0,
-                                  $ufs_dev ? \$found : undef);
+       local $sel = &format::partition_select("ufs_disk", $_[1], 0,
+                                              $ufs_dev ? \$found : undef);
        printf "<input type=radio name=ufs_dev value=0 %s> %s : %s<br>\n",
                $ufs_dev == 0 ? "checked" : "", $text{'solaris_scsi'}, $sel;
 
@@ -509,7 +508,7 @@ elsif ($_[0] eq "swap") {
        # Swapping to a disk partition or a file
        print "<tr> <td valign=top><b>$text{'solaris_swapfile'}</b></td>\n";
        print "<td colspan=3>\n";
-       &foreign_require("format", "format-lib.pl");
+       &foreign_require("format");
 
        if ($_[1] =~ /^\/dev\/dsk\/c([0-9]+)t([0-9]+)d([0-9]+)s([0-9]+)$/ ||
            $_[1] =~ /^\/dev\/dsk\/c([0-9]+)d([0-9]+)s([0-9]+)$/) {
@@ -523,9 +522,8 @@ elsif ($_[0] eq "swap") {
                }
 
        local $found;
-       local $sel = &foreign_call("format", "partition_select",
-                                  "swap_disk", $_[1], 0,
-                                  $swap_dev ? \$found : undef);
+       local $sel = &format::partition_select("swap_disk", $_[1], 0,
+                                              $swap_dev ? \$found : undef);
        printf "<input type=radio name=swap_dev value=0 %s> %s : %s<br>\n",
                $swap_dev == 0 ? "checked" : "", $text{'solaris_scsi'}, $sel;
 
@@ -571,7 +569,7 @@ elsif ($_[0] eq "pcfs") {
        # Mounting a SCSI msdos filesystem
        print "<tr> <td valign=top><b>$text{'solaris_msdos'}</b></td>\n";
        print "<td colspan=3>\n";
-       &foreign_require("format", "format-lib.pl");
+       &foreign_require("format");
 
        if ($_[1] =~ /^\/dev\/dsk\/c([0-9]+)t([0-9]+)d([0-9]+)s([0-9]+)$/ ||
            $_[1] =~ /^\/dev\/dsk\/c([0-9]+)d([0-9]+)s([0-9]+)$/) {
@@ -585,9 +583,8 @@ elsif ($_[0] eq "pcfs") {
                }
 
        local $found;
-       local $sel = &foreign_call("format", "partition_select",
-                                  "ufs_disk", $_[1], 0,
-                                  $pcfs_dev ? \$found : undef);
+       local $sel = &format::partition_select("ufs_disk", $_[1], 0,
+                                              $pcfs_dev ? \$found : undef);
        printf "<input type=radio name=ufs_dev value=0 %s> %s : %s<br>\n",
                $pcfs_dev == 0 ? "checked" : "", $text{'solaris_scsi'}, $sel;
 
index c649e94..15c73a2 100755 (executable)
@@ -3,15 +3,14 @@
 # Create a new linux filesystem
 
 require './raid-lib.pl';
-&foreign_require("proc", "proc-lib.pl");
+&foreign_require("proc");
 
 &ReadParse();
 &error_setup($text{'mkfs_err'});
-&foreign_call("fdisk", "error_setup", $text{'mkfs_err'});
-&foreign_call("fdisk", "ReadParse");
+&fdisk::ReadParse();
 $conf = &get_raidtab();
 $raid = $conf->[$in{'idx'}];
-$cmd = &foreign_call("fdisk", "mkfs_parse", $in{'fs'}, $raid->{'value'});
+$cmd = &fdisk::mkfs_parse($in{'fs'}, $raid->{'value'});
 
 $lvl = &find_value('raid-level', $raid->{'members'});
 $chunk = &find_value('chunk-size', $raid->{'members'});
@@ -22,7 +21,7 @@ if ($lvl >= 4 && ($in{'fs'} eq 'ext2' || $in{'fs'} eq 'ext3')) {
 &ui_print_unbuffered_header(undef, $text{'mkfs_title'}, "");
 print &text('mkfs_exec', "<tt>$cmd</tt>"),"<p>\n";
 print "<pre>\n";
-&foreign_call("proc", "safe_process_exec_logged", $cmd, 0, 0, STDOUT, undef, 1);
+&proc::safe_process_exec_logged($cmd, 0, 0, STDOUT, undef, 1);
 print "</pre>\n";
 
 if ($?) { print "<b>$text{'mkfs_failed'}</b> <p>\n"; }
index 75071a5..b20f9dd 100644 (file)
@@ -1,10 +1,10 @@
 # raid-lib.pl
 # Functions for managing RAID
 
-do '../web-lib.pl';
+BEGIN { push(@INC, ".."); };
+use WebminCore;
 &init_config();
-do '../ui-lib.pl';
-&foreign_require("fdisk", "fdisk-lib.pl");
+&foreign_require("fdisk");
 
 open(MODE, "$module_config_directory/mode");
 chop($raid_mode = <MODE>);
@@ -468,8 +468,8 @@ else { return $v[0]->{'value'}; }
 # Returns an array of  directory, type, mounted
 sub device_status
 {
-@mounted = &foreign_call("mount", "list_mounted") if (!@mounted);
-@mounts = &foreign_call("mount", "list_mounts") if (!@mounts);
+@mounted = &mount::list_mounted() if (!@mounted);
+@mounts = &mount::list_mounts() if (!@mounts);
 local $label = &fdisk::get_label($_[0]);
 local $volid = &fdisk::get_volid($_[0]);
 
@@ -486,10 +486,9 @@ elsif ($mount) { return ($mount->[0], $mount->[2], 0,
                         &indexof($mount, @mounts)); }
 if (!defined(@physical_volumes)) {
        @physical_volumes = ();
-       foreach $vg (&foreign_call("lvm", "list_volume_groups")) {
+       foreach $vg (&lvm::list_volume_groups()) {
                push(@physical_volumes,
-                       &foreign_call("lvm", "list_physical_volumes",
-                                            $vg->{'name'}));
+                       &lvm::list_physical_volumes($vg->{'name'}));
                }
        }
 foreach $pv (@physical_volumes) {
@@ -503,9 +502,9 @@ return ();
 # Returns a list of options, suitable for ui_select
 sub find_free_partitions
 {
-&foreign_require("fdisk", "fdisk-lib.pl");
-&foreign_require("mount", "mount-lib.pl");
-&foreign_require("lvm", "lvm-lib.pl");
+&foreign_require("fdisk");
+&foreign_require("mount");
+&foreign_require("lvm");
 local %skip = map { $_, 1 } @{$_[0]};
 local %used;
 local $c;
@@ -523,7 +522,7 @@ foreach $d (&fdisk::list_disks_partitions()) {
                         $skip{$p->{'device'}});
                local @st = &device_status($p->{'device'});
                next if (@st);
-               $tag = &foreign_call("fdisk", "tag_name", $p->{'type'});
+               $tag = &fdisk::tag_name($p->{'type'});
                $p->{'blocks'} =~ s/\+$//;
                push(@disks, [ $p->{'device'},
                               $p->{'desc'}.
@@ -544,8 +543,7 @@ foreach $c (@$conf) {
 local $vg;
 foreach $vg (&lvm::list_volume_groups()) {
        local $lv;
-       foreach $lv (&foreign_call("lvm", "list_logical_volumes",
-                                  $vg->{'name'})) {
+       foreach $lv (&lvm::list_logical_volumes($vg->{'name'})) {
                next if ($lv->{'perm'} ne 'rw' || $used{$lv->{'device'}} ||
                         $skip->{$lv->{'device'}});
                local @st = &device_status($lv->{'device'});
@@ -624,7 +622,7 @@ foreach my $k (grep { !$done{$_} && defined($notif->{$_}) } keys %$notif) {
 sub get_mdadm_action
 {
 if (&foreign_installed("init")) {
-       &foreign_require("init", "init-lib.pl");
+       &foreign_require("init");
        foreach my $a ("mdmonitor", "mdadm", "mdadmd") {
                local $st = &init::action_status($a);
                return $a if ($st);
@@ -639,7 +637,7 @@ sub get_mdadm_monitoring
 {
 local $act = &get_mdadm_action();
 if ($act) {
-       &foreign_require("init", "init-lib.pl");
+       &foreign_require("init");
        local $st = &init::action_status($act);
        return $st == 2;
        }
@@ -654,7 +652,7 @@ sub save_mdadm_monitoring
 local ($enabled) = @_;
 local $act = &get_mdadm_action();
 if ($act) {
-       &foreign_require("init", "init-lib.pl");
+       &foreign_require("init");
        if ($enabled) {
                &init::enable_at_boot($act);
                &init::stop_action($act);
index 62f1546..737f723 100755 (executable)
@@ -3,8 +3,8 @@
 # Display a form for creating a raid device
 
 require './raid-lib.pl';
-&foreign_require("mount", "mount-lib.pl");
-&foreign_require("lvm", "lvm-lib.pl");
+&foreign_require("mount");
+&foreign_require("lvm");
 &ReadParse();
 $conf = &get_raidtab();
 
index 389c2b4..5a27568 100755 (executable)
@@ -3,8 +3,8 @@
 # Display information about a raid device
 
 require './raid-lib.pl';
-&foreign_require("mount", "mount-lib.pl");
-&foreign_require("lvm", "lvm-lib.pl");
+&foreign_require("mount");
+&foreign_require("lvm");
 &ReadParse();
 
 print "Refresh: $config{'refresh'}\r\n"
index 5363f9b..8e74211 100755 (executable)
@@ -757,6 +757,7 @@ my $charset = defined($force_charset) ? $force_charset : &get_charset();
 &PrintHeader($charset);
 &load_theme_library();
 if (defined(&theme_header)) {
+       $module_name = &get_module_name();
        &theme_header(@_);
        return;
        }
@@ -1069,11 +1070,13 @@ a link destination, and the second the link text. For example :
 sub footer
 {
 &load_theme_library();
+my %this_module_info = &get_module_info(&get_module_name());
 if (defined(&theme_footer)) {
+       $module_name = &get_module_name();      # Old themes use these
+       %module_info = %this_module_info;
        &theme_footer(@_);
        return;
        }
-my %this_module_info = &get_module_info(&get_module_name());
 for(my $i=0; $i+1<@_; $i+=2) {
        my $url = $_[$i];
        if ($url ne '/' || !$tconfig{'noindex'}) {