# 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, $arg3) = @_; 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; } elsif ($mode eq "majmin") { # mknod $arg1 $arg2 and try to mount that $ret = &invoke("mknod /dev/customcd b $arg1 $arg2"); if ($ret == 0) { $hold_on_error = 0; $ret = &invoke("mount -t $arg3 -o ro /dev/customcd $rh_mountpath"); $hold_on_error = 1; if ($ret == 0) { # We mounted it - is it our CD ? $ret = &verify_rhs_files; &invoke_no_output("umount $rh_mountpath"); if ($ret == 1) { $cddev = "/dev/customcd"; $cddevenglish = "major = $arg1, minor = $arg2"; $rh_mountdevice = $cddev; $rh_mountdevicetype = $arg3; return 1; } print "No Red Hat stuff here.\n"; } &invoke_no_output("rm -f /dev/customcd"); } <STDIN>; return 0; } return -1; } ## probe_rhs_cdrom does not do any critical variable setting ## sub probe_rhs_cdrom { local ($ret, $success, $mode, $again, $arg1, $arg2, $arg3); $success = 0; $mode = "probe"; while (1) { if ($mode eq "probe") { $success = &attempt_cd_mount ("probe"); } elsif ($mode eq "device") { $success = &attempt_cd_mount ("device", $arg1, $arg3); } else { $success = &attempt_cd_mount ("majmin", $arg1, $arg2, $arg3); } 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) { # ask probe again, get device name, get majmin, give up $ret = &rhs_menu ("Error", <<EOM > >Red Hat CD-ROM not found! >What should I do now? > EOM , 60, 4, "Probe", "Probe again", "Device", "Enter device name", "MajMin", "Enter major and minor numbers", "Quit", "Give up"); next REPEAT if (! $ret); if ($dialog_result eq "Quit") { return 0; } elsif ($dialog_result eq "Probe") { $mode = "probe"; } elsif ($dialog_result eq "Device") { $mode = "device"; if (! &rhs_inputbox ("Device name", <<EOM > Please enter the full device name (including /dev/). > EOM , 70, "/dev/")) { next REPEAT; } $arg1 = $dialog_result; } elsif ($dialog_result eq "MajMin") { $mode = "majmin"; if (! &rhs_inputbox ("Major device number", <<EOM > Please enter the MAJOR device number > EOM , 70, "")) { next REPEAT; } $arg1 = $dialog_result; if (! &rhs_inputbox ("Minor device number", <<EOM > Please enter the MINOR device number > EOM , 70, "")) { next REPEAT; } $arg2 = $dialog_result; } else { next REPEAT; } if (($mode eq "device") || ($mode eq "majmin")) { if (! &rhs_inputbox ("Device Type", <<EOM > Please enter the device type (iso9660, minix, ext2, msdos, etc) > EOM , 70, "")) { next REPEAT; } $arg3 = $dialog_result; } $again = 0; } } } ################### 1;