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 (i0) 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 ==