Fix problem report, in progress on hard disk install problems
I started in on getting the hard disk installation to work again. For
the first effort, I logically encapsulated the problem report
directory entry into its own function (getting a directory is really a
little different from getting a mountpoint). I also prevented the
partition from getting umounted immediately after being chosen, before
it had a chance for the problem report to be written. It still needs
to be umounted somewhere.
I also restated the get-a-mountpoint logic and added some comments to
make it clearer what is going on.
So far, it's an improvement; at least the problem report works
again. I'll continue work this weekend.
Index: choose_medium.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/choose_medium.c,v
retrieving revision 1.125
diff -u -r1.125 choose_medium.c
--- choose_medium.c 2002/01/13 00:15:23 1.125
+++ choose_medium.c 2002/01/26 02:49:14
@@ -207,6 +207,36 @@
return 0;
}
+/* Problem Report wants a directory, not a mountpoint */
+int choose_problem_dir(char *text, char *prefix)
+{
+ char buffer[PATH_MAX+1];
+ char buffer2[PATH_MAX+1];
+ int status;
+ struct stat statbuf;
+ char *preventry_prob = strdup(""); /* Previous entry doesn't matter here */
+ for(;;) {
+ status = enterDirBox(_("Select the target directory"),
+ text, prefix, preventry_prob, buffer2, PATH_MAX);
+ if (status == DLG_CANCEL)
+ return DLG_CANCEL;
+ else if (status != DLG_OKAY)
+ return 1;
+ snprintf(buffer, sizeof(buffer), "%s%s%s", prefix,
+ buffer2[0]=='/'?"":"/", buffer2);
+ if (NAME_ISDIR(buffer, &statbuf))
+ break;
+ else {
+ snprintf (prtbuf, sizeof (prtbuf),
+ _("The supplied directory %s does not exist. Please enter a new one."),
+ buffer2);
+ problemBox(prtbuf, _("Directory Error"));
+ }
+ }
+ Archive_Dir = strdup(buffer);
+ return 0;
+}
+
/*
text - the message displayed that tells the user what the directory will
be used for
@@ -218,7 +248,7 @@
{
char buffer[PATH_MAX+1];
char buffer2[PATH_MAX+1];
- int i, found;
+ int i, found, ask;
char *mountpoint, *descr = "", *def;
static char *preventry = NULL;
/* glob_t globbuf; */
@@ -245,18 +275,18 @@
preventry = strdup("");
}
- buffer2[0] = '\0';
+ buffer2[0] = '\0'; /* default directory guess */
+ if (is_cdrom_image() == 2) {
+ /* we've booted off a CD-ROM, live style */
+ strcpy(buffer2, "");
+ }
for(i=0 ;; i++) {
- if (i == 0 && bootargs.isquiet && disqtype != problem_report) {
- /* Try to guess a good directory. */
- if (is_cdrom_image() == 2)
- /* we've boot off a CD-ROM, live style */
- strcpy(buffer2, "");
- } else {
- i++; /* if we have to manually choose a dir, give us a warning
- when we are wrong, even if it is our first time through */
- status = enterDirBox(_("Choose Directory"),
+ /* Should we ask for user input on the mountpoint? */
+ ask = i; /* if we are looping (i>0) we MUST ask */
+ ask = (ask || bootargs.isverbose); /* if verbose we MUST ask */
+ if (ask) {
+ status = enterDirBox(_("Choose the Mount Point"),
text, prefix, preventry, buffer2, PATH_MAX);
if (status == DLG_CANCEL)
return DLG_CANCEL;
@@ -271,7 +301,7 @@
if (NAME_ISDIR(buffer, &statbuf))
break;
else {
- if (i==0 && ! bootargs.isverbose) {
+ if (! ask) {
/* We guessed wrong. Don't let the user see the directory
that didn't work out. */
free(preventry);
@@ -284,6 +314,7 @@
}
}
}
+ /* We have a valid directory path */
mountpoint = strdup(buffer);
switch (disqtype) {
@@ -308,11 +339,8 @@
break;
#endif
case problem_report:
- /* We are looking for a directory to write to, not searching
- for a file. We are done now. */
- Archive_Dir = strdup(mountpoint);
- return 0;
- break;
+ /* handled in choose_problem_dir */
+ DEBUGMSG("problem_report case reached in error");
}
def = NULL;
@@ -408,11 +436,13 @@
_("Please select the directory containing a file %s that you will use to install %s."),
pattern, descr);
}
- status = menuBox(prtbuf, disqtype==problem_report ? _("Select Target path") : _("Select Debian Archive path"),
+ status = menuBox(prtbuf, _("Select Debian Archive path"),
choices, items, 1);
}
- if (status != -1) {
+ if (status == -1) { /* It's the Cancel button again */
+ return DLG_CANCEL;
+ } else {
int data;
data = ilist[status];
status = 0;
@@ -574,11 +604,9 @@
status = -1;
}
}
- }
- break;
- }
- } else { /* It's the Cancel button again */
- return DLG_CANCEL;
+ }
+ break;
+ } /* end switch (data) */
}
free(mountpoint);
return status;
@@ -948,30 +976,34 @@
return 1;
}
#endif
- if (disqtype == problem_report)
+ if (disqtype == problem_report) {
snprintf(prtbuf, sizeof(prtbuf),
_("Please indicate where you would like to save your problem report "
"within the filesystem you just mounted.\n\nNote that the filesystem "
"you just mounted is located in the directory, %s, but you don't need "
"to give that directory here."),
CM_MOUNTPOINT_DIR);
- else
+ status = choose_problem_dir(prtbuf, CM_MOUNTPOINT_DIR);
+ } else {
snprintf(prtbuf, sizeof(prtbuf),
_("Please indicate the location of the Debian Archive within the filesystem "
"you just mounted.\n\nNote that the filesystem you just mounted is located "
"in the directory, %s, but you don't need to give that directory here."),
CM_MOUNTPOINT_DIR);
-
- status = choose_archive_dir(prtbuf, CM_MOUNTPOINT_DIR);
- if (! system("cat /proc/mounts | grep -q " CM_MOUNTPOINT_DIR))
- umount(CM_MOUNTPOINT_DIR);
+ status = choose_archive_dir(prtbuf, CM_MOUNTPOINT_DIR);
+ }
+ if (status) {
+ /* umount should happen later for status 0 */
+ if (! system("cat /proc/mounts | grep -q " CM_MOUNTPOINT_DIR))
+ umount(CM_MOUNTPOINT_DIR);
+ }
return status;
}
static int choose_mounted(void)
{
struct fdisk_partition *p;
-
+ int status;
if (disqtype == problem_report)
snprintf(prtbuf, sizeof(prtbuf),
_("Please choose the partition where you would like to save the problem report."));
@@ -983,14 +1015,21 @@
if (p == NULL)
return DLG_CANCEL;
- if (disqtype == problem_report )
+ if (disqtype == problem_report ) {
snprintf(prtbuf, sizeof(prtbuf),
_("Please choose the directory where you would like to save the problem report."));
- else
+ status = choose_problem_dir(prtbuf, p->mount_point);
+ } else {
snprintf(prtbuf, sizeof(prtbuf),
_("Please choose the directory where the Debian archive resides."));
-
- return choose_archive_dir(prtbuf, p->mount_point);
+ status = choose_archive_dir(prtbuf, p->mount_point);
+ }
+ if (status) {
+ /* umount should happen later for status 0 */
+ if (! system("cat /proc/mounts | grep -q " CM_MOUNTPOINT_DIR))
+ umount(CM_MOUNTPOINT_DIR);
+ }
+ return status;
}
struct execlog_env_s {
@@ -1088,13 +1127,20 @@
}
}
}
- if ((status = choose_archive_dir(disqtype == problem_report ?
- _("Please choose the path inside the mounted NFS filesystem to store the problem report.") :
+ if (disqtype == problem_report ) {
+ snprintf(prtbuf, sizeof(prtbuf),
+ _("Please choose the path inside the mounted NFS filesystem to store the problem report."));
+ status = choose_problem_dir(prtbuf, CM_MOUNTPOINT_DIR);
+ } else {
+ snprintf(prtbuf, sizeof(prtbuf),
_("Please choose the path inside the mounted "
- "NFS filesystem where the Debian Archive resides."), CM_MOUNTPOINT_DIR)))
- {
- if (!system("cat /proc/mounts | grep -q " CM_MOUNTPOINT_DIR))
- execlog("umount " CM_MOUNTPOINT_DIR, LOG_DEBUG);
+ "NFS filesystem where the Debian Archive resides."));
+ status = choose_archive_dir(prtbuf, CM_MOUNTPOINT_DIR);
+ }
+ if (status) {
+ /* umount should happen later for status 0 */
+ if (!system("cat /proc/mounts | grep -q " CM_MOUNTPOINT_DIR))
+ execlog("umount " CM_MOUNTPOINT_DIR, LOG_DEBUG);
}
return status;
}
--
*------v--------- Installing Debian GNU/Linux 3.0 --------v------*
| <http://www.debian.org/releases/woody/installmanual> |
| debian-imac (potato): <http://debian-imac.sourceforge.net> |
| Chris Tillman tillman@azstarnet.com |
| May the Source be with you |
*----------------------------------------------------------------*
Reply to: