home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Caldera Network Desktop 1.0
/
caldera-network-desktop-1.0.bin
/
images
/
ramdisk2.img
/
usr
/
lib
/
perl
/
makefs
< prev
next >
Wrap
Text File
|
1995-10-06
|
4KB
|
217 lines
###### -*-perl-*-
# routines to format partitions
# This variable will be used later to determine the
# filesystem type for each partition formatted here
%fsformat = ();
@selected_devices = ();
$fstype = "ext2";
$badblock_check = "";
sub select_format_disks {
local ( %fsinfolist, $dev, $devsize );
local ( %fsmenu, $msg );
local ( $p, $r );
if ($fs_mounted) {
&rhs_msgbox("Error",
<<EOM
>
Your filesystems are already mounted (and thus, they are
most likely formatted). If you still wish to format them,
unmount them first.
>
EOM
, 60);
return 0;
}
&rhs_infobox ( "Filesystems",
<<EOM
>
Looking for Linux partitions...
>
EOM
, 60);
%fsinfolist = ();
open(SAVEERR, ">&STDERR");
open(STDERR, ">/dev/null");
open(PROC, "fdisk -l |") || &newdie("Can't call fdisk!");
while (<PROC>) {
if (/^(.{10}).{5}(.{31}).*Linux native$/) {
$p = $1; $r = $2;
$p =~ s/\s$//;
$fsinfolist{$p} = "$r";
}
}
close PROC;
open(STDERR, ">&SAVEERR");
if (keys(%fsinfolist) == 0) {
&rhs_msgbox ( "Filesystems",
<<EOM
>
You do not appear to have any Linux partitions on your system.
You must create at least one before continuing.
>
EOM
, 60);
return 0;
}
do {
@selected_devices = ();
%fsformat = ();
%fs_menu = %fsinfolist;
foreach $dev (keys %fs_menu) {
$fs_menu{$dev} = sprintf("%7s %s", $fsformat{$dev}, $fs_menu{$dev});
}
if (! &rhs_checklista("Filesystems",
<<EOM
>
Use the spacebar to select all partitions to format. Then select OK.
>
> Device Type Begin Start End Blocks
EOM
, 65, %fs_menu)) {
return 0;
}
if (! scalar(@dialog_result)) {
next;
}
@selected_devices = sort @dialog_result;
foreach $dev (@selected_devices) {
$fsformat{$dev} = $fstype;
}
if ($express_install) {
$dialog_result = "No";
} else {
if (! &rhs_menu("Filesystems",
<<EOM
>
Check for bad blocks on the hard drive during formatting?
>
EOM
, 50, 2,
"Yes", "Check for bad blocks",
"No", "Do not check for bad blocks")) {
next;
}
}
if ($dialog_result eq "Yes") {
$badblock_check = "-c";
} else {
$badblock_check = "";
}
$msg =
<<EOM
>
Are you absolutely certain that you want to format?
>
EOM
;
foreach $dev (@selected_devices) {
$msg .=
<<EOM
>$dev
EOM
;
}
$msg .=
<<EOM
>
All data on these partitions will be lost!
>
EOM
;
} while (! &rhs_yesno("Filesystems", $msg, 70));
return 1;
}
sub format_disks {
local ( $dev, $devsize, %fsinfolist, $msg, $res, $retval );
$retval = 1;
%fsinfolist = ();
open(SAVEERR, ">&STDERR");
open(STDERR, ">/dev/null");
open(PROC, "fdisk -l |") || &newdie("Can't call fdisk!");
while (<PROC>) {
if (/^(.{10}).{5}(.{31}).*Linux native$/) {
$p = $1; $r = $2;
$p =~ s/\s$//;
$fsinfolist{$p} = "$r";
}
}
close PROC;
open(STDERR, ">&SAVEERR");
if (keys(%fsinfolist) == 0) {
&rhs_msgbox ( "Filesystems",
<<EOM
>
Your Linux partitions have disappeared.
>
You must create at least one before continuing.
>
EOM
, 60);
return 0;
}
foreach $dev (@selected_devices) {
$fsinfolist{$dev} =~ /^.*(.{9})$/;
$devsize = $1;
chop($devsize);
$msg =
<<EOM
>
Formatting $dev with $fstype filesystem.
>
EOM
;
if ($badblock_check eq "-c") {
$msg .=
<<EOM
Checking for bad blocks. This may take a minute or two.
>
EOM
;
}
&rhs_infobox("Formatting Filesystems", $msg, 65);
if ($express_install) {
$res = &invoke_no_output("mke2fs $badblock_check $dev");
} else {
$res = &invoke("mke2fs $badblock_check $dev");
}
if ($res) {
$retval = 0;
&rhs_msgbox("Error",
<<EOM
>
An error occurred while formatting $dev.
>
EOM
, 60);
delete $fsformat{$dev};
}
}
return $retval;
}
#############
1;