home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Caldera Network Desktop 1.0
/
caldera-network-desktop-1.0.bin
/
images
/
ramdisk2.img
/
usr
/
lib
/
perl
/
probe_cd
< prev
next >
Wrap
Text File
|
1995-09-29
|
5KB
|
233 lines
# CD-ROM Probing Routines -*-perl-*-
##
## Variables
##
# $rh_mountpath is point at which to mount the device
# with the RHS stuff on it.
# $rpppath is the path from $rhspath to the rpp directory,
# which is used to verify that this is indeed RHS stuff
# $rh_mountdevice is the device to use in the mount call
# $rh_mountdevicetype is the filesystem type to use in the mount call
$cddev = "";
$cddevenglish = "";
@cdroms = (
"mcd", "Mitsumi",
"scd0", "1st SCSI",
"scd1", "2nd SCSI",
"cdu535", "Sony CDU-535",
"sonycd", "Sony CDU-31A",
"hda", "First drive on primary IDE interface",
"hdb", "Second drive on primary IDE interface",
"hdc", "First drive on secondary IDE interface",
"hdd", "Second drive on secondary IDE interface",
"sbpcd0", "1st SoundBlaster PRO (or Panasonic?)",
"sbpcd1", "2nd SoundBlaster PRO (or Panasonic?)",
"sbpcd2", "3rd SoundBlaster PRO (or Panasonic?)",
"sbpcd3", "4th SoundBlaster PRO (or Panasonic?)",
"aztcd", "Aztech CD-268"
);
##
## Functions
##
## attempt_cd_mount will set $cddev, $cddevenglish
##
sub attempt_cd_mount {
local ($mode, $arg1, $arg2) = @_;
local ($cdi, $ret);
if ($mode eq "probe") {
print "Probing for Red Hat CD-ROM...\n";
$cdi = 0;
while ($cdi < @cdroms - 1) {
$cddev = "/dev/$cdroms[$cdi]";
$cddevenglish = $cdroms[$cdi + 1];
print "\nTrying $cddev...\n";
$hold_on_error = 0;
print "Invoking mount w/ path $rh_mountpath\n";
$ret = &invoke("mount -t iso9660 -o ro $cddev $rh_mountpath");
print "mount returned $ret\n";
$hold_on_error = 1;
if ($ret == 0) {
# We mounted it - is it our CD ?
$ret = &verify_rhs_files;
if ($ret == 1) {
print "Success!\n";
$rh_mountdevice = $cddev;
$rh_mountdevicetype = "iso9660";
return 1;
}
print "No Red Hat stuff here.\n";
&invoke_no_output("umount $rh_mountpath");
}
print "Failed\n";
$cdi += 2;
}
print "Total failure. Hit Enter to continue.";
<STDIN>;
return 0;
} elsif ($mode eq "device") {
# Try to mount $arg1
$hold_on_error = 0;
$ret = &invoke("mount -t $arg2 -o ro $arg1 $rh_mountpath");
$hold_on_error = 1;
if ($ret == 0) {
# We mounted it - is it our CD ?
$ret = &verify_rhs_files;
if ($ret == 1) {
$cddev = $arg1;
$cddevenglish = $arg1;
$rh_mountdevice = $cddev;
$rh_mountdevicetype = $arg2;
return 1;
}
print "No Red Hat stuff here.\n";
&invoke_no_output("umount $rh_mountpath");
}
<STDIN>;
return 0;
}
return -1;
}
sub get_device {
local ($device, $type);
while (!$device || !$type) {
$device = "";
$type = "";
if (! &rhs_inputbox ("Device name",
<<EOM
>
Please enter the full device name (including /dev/).
>
EOM
, 70, "/dev/")) {
next;
}
$device = $dialog_result;
if (! &rhs_inputbox ("Filesystem Type",
<<EOM
>
Please enter the filesystem type (iso9660, minix, ext2, msdos, hpfs, etc)
>
EOM
, 70, "")) {
next;
}
$type = $dialog_result;
}
return ($device, $type);
}
sub mount_partition {
local ($device, $type, $success);
($device, $type) = &get_device;
$success = 0;
while (1) {
$success = &attempt_cd_mount ("device", $device, $type);
if ($success == 1) {
# if respond OK return 1
if (&rhs_yesno ( "Success",
<<EOM
I think I\'ve found the Red Hat stuff
on the $device drive.
>
Is this correct?
EOM
, 50)) {
return 1;
}
}
$again = 1;
REPEAT:
while ($again) {
$ret = &rhs_menu ("Error",
<<EOM
>
>Red Hat file not found!
>What should I do now?
>
EOM
, 60, 2,
"Again", "Try again",
"Quit", "Give up");
next REPEAT if (! $ret);
if ($dialog_result eq "Quit") {
return 0;
} elsif ($dialog_result eq "Again") {
($device, $type) = &get_device;
} else {
next REPEAT;
}
$again = 0;
}
}
}
sub probe_rhs_cdrom {
local ($ret, $success, $mode, $again, $arg1, $arg2, $arg3);
$success = 0;
while (1) {
$success = &attempt_cd_mount ("probe");
if ($success == 1) {
# if respond OK return 1
if (&rhs_yesno ( "Success",
<<EOM
I think I\'ve found the Red Hat CD-ROM
in the $cddevenglish CD-ROM drive, which
I found on device $cddev.
>
Is this correct?
EOM
, 50)) {
return 1;
}
}
$again = 1;
REPEAT:
while ($again) {
$ret = &rhs_menu ("Error",
<<EOM
>
>Red Hat CD-ROM not found!
>What should I do now?
>
EOM
, 60, 2,
"Probe", "Probe again",
"Quit", "Give up");
next REPEAT if (! $ret);
if ($dialog_result eq "Quit") {
return 0;
} elsif ($dialog_result ne "Probe") {
next REPEAT;
}
$again = 0;
}
}
}
###################
1;